A Fold is an optic that allows to focus into structure and get multiple results.
Fold is a generalisation of an instance of Foldable and is implemented in terms of foldMap.
Check if all targets satisfy the predicate
true if at least one focus matches the given predicate.
Join two Fold with the same target
Check whether at least one element satisfies the predicate.
Find the first element matching the predicate, if one exists.
Get the first target or null
open fun fold(M: Monoid<A>, source: S): A
Fold using the given Monoid instance.
abstract fun <R> foldMap(M: Monoid<R>, source: S, map: (focus: A) -> R): R
Map each target to a type R and use a Monoid to fold the results
Get all targets of the Fold
Check if there is no target
Check if there is at least one target
Get the last target or null
Create a sum of the Fold and a type C
Create a sum of a type C and the Fold
Calculate the number of targets
DSL to compose At with a Fold for a structure S to focus in on A at given index I.
DSL to compose Traversal with a Fold for a structure S to see all its foci A
DSL to compose Index with a Fold for a structure S to focus in on A at given index I
DSL to compose a Prism with focus arrow.core.Some with a Fold with a focus of Option<S>