-
Creates a Fold that has no focus.
Declaration
Swift
public static var void: Fold<S, A> { get }
-
Composes a
Fold
with aFold
.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Fold<A, C>) -> Fold<S, C>
Parameters
lhs
Left hand side of the composition.
rhs
Right hand side of the composition.
Return Value
A
Fold
resulting from the sequential application of the two provided optics. -
Composes a
Fold
with anIso
.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Iso<A, C>) -> Fold<S, C>
Parameters
lhs
Left hand side of the composition.
rhs
Right hand side of the composition.
Return Value
A
Fold
resulting from the sequential application of the two provided optics. -
Composes a
Fold
with aGetter
.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Getter<A, C>) -> Fold<S, C>
Parameters
lhs
Left hand side of the composition.
rhs
Right hand side of the composition.
Return Value
A
Fold
resulting from the sequential application of the two provided optics. -
Composes a
Fold
with aLens
.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Lens<A, C>) -> Fold<S, C>
Parameters
lhs
Left hand side of the composition.
rhs
Right hand side of the composition.
Return Value
A
Fold
resulting from the sequential application of the two provided optics. -
Composes a
Fold
with aPrism
.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Prism<A, C>) -> Fold<S, C>
Parameters
lhs
Left hand side of the composition.
rhs
Right hand side of the composition.
Return Value
A
Fold
resulting from the sequential application of the two provided optics. -
Composes a
Fold
with anAffineTraversal
.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: AffineTraversal<A, C>) -> Fold<S, C>
Parameters
lhs
Left hand side of the composition.
rhs
Right hand side of the composition.
Return Value
A
Fold
resulting from the sequential application of the two provided optics. -
Composes a
Fold
with aTraversal
.Declaration
Swift
public static func + <C>(lhs: Fold<S, A>, rhs: Traversal<A, C>) -> Fold<S, C>
Parameters
lhs
Left hand side of the composition.
rhs
Right hand side of the composition.
Return Value
A
Fold
resulting from the sequential application of the two provided optics. -
Counts the number of foci in the source.
Declaration
Swift
public func size(_ s: S) -> Int
Parameters
s
Source.
Return Value
Number of foci.
-
Checks if all foci match a predicate.
Declaration
Swift
public func forAll(_ s: S, _ predicate: @escaping (A) -> Bool) -> Bool
Parameters
s
Source.
predicate
Testing 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) -> Bool
Parameters
s
Source.
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) -> Bool
Parameters
s
Source.
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
s
Source.
Return Value
An optional value with the first focus.
-
Retrieves the first focus, if any.
Declaration
Swift
public func headOptional(_ s: S) -> A?
Parameters
s
Source.
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
s
Source.
Return Value
An optional value with the last focus.
-
Retrieves the last focus, if any.
Declaration
Swift
public func lastOptional(_ s: S) -> A?
Parameters
s
Source.
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
other
Fold to join with.
Return Value
A Fold that operates on either of the two original sources, with the same target.
-
Composes this
Fold
with aFold
.Declaration
Swift
public func compose<C>(_ other: Fold<A, C>) -> Fold<S, C>
Parameters
other
Value to compose with.
Return Value
A
Fold
resulting from the sequential application of the two optics. -
Composes this
Fold
with anIso
.Declaration
Swift
public func compose<C>(_ other: Iso<A, C>) -> Fold<S, C>
Parameters
other
Value to compose with.
Return Value
A
Fold
resulting from the sequential application of the two optics. -
Composes this
Fold
with aLens
.Declaration
Swift
public func compose<C>(_ other: Lens<A, C>) -> Fold<S, C>
Parameters
other
Value to compose with.
Return Value
A
Fold
resulting from the sequential application of the two optics. -
Composes this
Fold
with aPrism
.Declaration
Swift
public func compose<C>(_ other: Prism<A, C>) -> Fold<S, C>
Parameters
other
Value to compose with.
Return Value
A
Fold
resulting from the sequential application of the two optics. -
Composes this
Fold
with anAffineTraversal
.Declaration
Swift
public func compose<C>(_ other: AffineTraversal<A, C>) -> Fold<S, C>
Parameters
other
Value to compose with.
Return Value
A
Fold
resulting from the sequential application of the two optics. -
Composes this
Fold
with aTraversal
.Declaration
Swift
public func compose<C>(_ other: Traversal<A, C>) -> Fold<S, C>
Parameters
other
Value to compose with.
Return Value
A
Fold
resulting 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
s
Source.
predicate
Testing 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) -> Bool
Parameters
s
Source.
predicate
Testing 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
i
Index 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
i
Index 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
i
Index 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
S
or anS
and 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
predicate
Testing 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) -> A
Parameters
s
Source.
Return Value
Summary value.
-
Folds all foci into a summary value using its instance of
Monoid
.Declaration
Swift
func combineAll(_ s: S) -> A
Parameters
s
Source.
Return Value
Summary value.