-
Creates a Fold that has no focus.
Declaration
Swift
public static var void: Fold<S, A> { get } -
Composes a
Foldwith aFold.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Fold<A, C>) -> Fold<S, C>Parameters
lhsLeft hand side of the composition.
rhsRight hand side of the composition.
Return Value
A
Foldresulting from the sequential application of the two provided optics. -
Composes a
Foldwith anIso.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Iso<A, C>) -> Fold<S, C>Parameters
lhsLeft hand side of the composition.
rhsRight hand side of the composition.
Return Value
A
Foldresulting from the sequential application of the two provided optics. -
Composes a
Foldwith aGetter.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Getter<A, C>) -> Fold<S, C>Parameters
lhsLeft hand side of the composition.
rhsRight hand side of the composition.
Return Value
A
Foldresulting from the sequential application of the two provided optics. -
Composes a
Foldwith aLens.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Lens<A, C>) -> Fold<S, C>Parameters
lhsLeft hand side of the composition.
rhsRight hand side of the composition.
Return Value
A
Foldresulting from the sequential application of the two provided optics. -
Composes a
Foldwith aPrism.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Prism<A, C>) -> Fold<S, C>Parameters
lhsLeft hand side of the composition.
rhsRight hand side of the composition.
Return Value
A
Foldresulting from the sequential application of the two provided optics. -
Composes a
Foldwith anAffineTraversal.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: AffineTraversal<A, C>) -> Fold<S, C>Parameters
lhsLeft hand side of the composition.
rhsRight hand side of the composition.
Return Value
A
Foldresulting from the sequential application of the two provided optics. -
Composes a
Foldwith aTraversal.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Traversal<A, C>) -> Fold<S, C>Parameters
lhsLeft hand side of the composition.
rhsRight hand side of the composition.
Return Value
A
Foldresulting from the sequential application of the two provided optics. -
Counts the number of foci in the source.
Declaration
Swift
public func size(_ s: S) -> IntParameters
sSource.
Return Value
Number of foci.
-
Checks if all foci match a predicate.
Declaration
Swift
public func forAll(_ s: S, _ predicate: @escaping (A) -> Bool) -> BoolParameters
sSource.
predicateTesting predicate.
Return Value
Boolean value indicating if all foci match the predicate.
-
Checks if a source is empty.
Declaration
Swift
public func isEmpty(_ s: S) -> BoolParameters
sSource.
Return Value
True if the source has no foci; false otherwise.
-
Checks if a source is non-empty.
Declaration
Swift
public func nonEmpty(_ s: S) -> BoolParameters
sSource.
Return Value
False is the source has no foci; true otherwise.
-
Retrieves the first focus, if any.
Declaration
Swift
public func headOption(_ s: S) -> Option<A>Parameters
sSource.
Return Value
An optional value with the first focus.
-
Retrieves the first focus, if any.
Declaration
Swift
public func headOptional(_ s: S) -> A?Parameters
sSource.
Return Value
An optional value with the first focus.
-
Retrieves the last focus, if any.
Declaration
Swift
public func lastOption(_ s: S) -> Option<A>Parameters
sSource.
Return Value
An optional value with the last focus.
-
Retrieves the last focus, if any.
Declaration
Swift
public func lastOptional(_ s: S) -> A?Parameters
sSource.
Return Value
An optional value with the last focus.
-
Joins to Fold with the same focus.
Declaration
Swift
public func choice<C>(_ other: Fold<C, A>) -> Fold<Either<S, C>, A>Parameters
otherFold to join with.
Return Value
A Fold that operates on either of the two original sources, with the same target.
-
Composes this
Foldwith aFold.Declaration
Swift
public func compose<C>(_ other: Fold<A, C>) -> Fold<S, C>Parameters
otherValue to compose with.
Return Value
A
Foldresulting from the sequential application of the two optics. -
Composes this
Foldwith anIso.Declaration
Swift
public func compose<C>(_ other: Iso<A, C>) -> Fold<S, C>Parameters
otherValue to compose with.
Return Value
A
Foldresulting from the sequential application of the two optics. -
Composes this
Foldwith aLens.Declaration
Swift
public func compose<C>(_ other: Lens<A, C>) -> Fold<S, C>Parameters
otherValue to compose with.
Return Value
A
Foldresulting from the sequential application of the two optics. -
Composes this
Foldwith aPrism.Declaration
Swift
public func compose<C>(_ other: Prism<A, C>) -> Fold<S, C>Parameters
otherValue to compose with.
Return Value
A
Foldresulting from the sequential application of the two optics. -
Composes this
Foldwith anAffineTraversal.Declaration
Swift
public func compose<C>(_ other: AffineTraversal<A, C>) -> Fold<S, C>Parameters
otherValue to compose with.
Return Value
A
Foldresulting from the sequential application of the two optics. -
Composes this
Foldwith aTraversal.Declaration
Swift
public func compose<C>(_ other: Traversal<A, C>) -> Fold<S, C>Parameters
otherValue to compose with.
Return Value
A
Foldresulting from the sequential application of the two optics. -
Finds the first focus that matches a predicate.
Declaration
Swift
public func find(_ s: S, _ predicate: @escaping (A) -> Bool) -> Option<A>Parameters
sSource.
predicateTesting predicate.
Return Value
An optional value containing the focus, if any.
-
Checks if any focus in the provided source match a predicate.
Declaration
Swift
public func exists(_ s: S, _ predicate: @escaping (A) -> Bool) -> BoolParameters
sSource.
predicateTesting predicate.
Return Value
True if any focus matches the predicate; false otherwise.
-
Focuses on a specific index of this fold.
Declaration
Swift
func at(_ i: A.AtIndex) -> Fold<S, A.AtFoci>Parameters
iIndex to focus.
Return Value
A fold from this structure to the focused index.
-
Provides a fold over all elements of the foci of this fold.
Declaration
Swift
var every: Fold<S, A.EachFoci> { get }
-
Provides a fold focused on an index of the focus of this fold.
Declaration
Swift
func index(_ i: A.IndexType) -> Fold<S, A.IndexFoci>Parameters
iIndex to focus.
Return Value
A fold focused on an index of the focus of this fold.
-
Provides a fold focused on an index of the focus of this fold.
Declaration
Swift
subscript(i: A.IndexType) -> Fold<S, A.IndexFoci> { get }Parameters
iIndex to focus.
Return Value
A fold focused on an index of the focus of this fold.
-
Provides an identity Fold.
Declaration
Swift
static var identity: Fold<S, S> { get } -
Provides a Fold that takes either an
Sor anSand strips the choice ofS.Declaration
Swift
static var codiagonal: Fold<Either<S, S>, S> { get } -
Provides a Fold based on a predicate on the source.
Declaration
Swift
static func select(_ predicate: @escaping (S) -> Bool) -> Fold<S, S>Parameters
predicateTesting predicate.
Return Value
A Fold based on the provided predicate.
-
Folds all foci into a summary value using its instance of
Monoid.Declaration
Swift
func fold(_ s: S) -> AParameters
sSource.
Return Value
Summary value.
-
Folds all foci into a summary value using its instance of
Monoid.Declaration
Swift
func combineAll(_ s: S) -> AParameters
sSource.
Return Value
Summary value.
Install in Dash
Fold Class Reference