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.

the source of a Fold

the target of a Fold

DSL to compose a Prism with focus arrow.core.Some with a Fold with a focus of Option<S>

Check if all targets satisfy the predicate

Returns true if at least one focus matches the given predicate.

true

DSL to compose At with a Fold for a structure S to focus in on A at given index I.

Join two Fold with the same target

Compose a Fold with a Fold

DSL to compose Traversal with a Fold for a structure S to see all its foci A

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

Fold using the given empty element and combine.

Map each target to a type R and combine the results as a fold.

Get all targets of the Fold

DSL to compose Index with a Fold for a structure S to focus in on A at given index I

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