arrow-optics / arrow.optics / Fold
interface Fold<S, A> :
FoldOf
<S, A>
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.
S
- the source of a Fold
A
- the target of a Fold
choice | Join two Fold with the same targetopen infix fun <C> choice(other: Fold <C, A>): Fold <Either<S, C>, A> |
combineAll | Alias for fold.open fun combineAll(M: Monoid<A>, s: S): A |
compose | Compose a Fold with a Foldopen infix fun <C> compose(other: Fold <A, C>): Fold <S, C> Compose a Fold with a Getter open infix fun <C> compose(other: Getter <A, C>): Fold <S, C> Compose a Fold with a Optional open infix fun <C> compose(other: Optional <A, C>): Fold <S, C> Compose a Fold with a Prism open infix fun <C> compose(other: Prism <A, C>): Fold <S, C> Compose a Fold with a Lens open infix fun <C> compose(other: Lens <A, C>): Fold <S, C> Compose a Fold with a Iso open infix fun <C> compose(other: Iso <A, C>): Fold <S, C> Compose a Fold with a Traversal open infix fun <C> compose(other: Traversal <A, C>): Fold <S, C> |
exists | Check whether at least one element satisfies the predicate.open fun exists(s: S, p: (A) -> Boolean ): Boolean |
find | Find the first element matching the predicate, if one exists.open fun find(s: S, p: (A) -> Boolean ): Option<A> |
fold | Fold using the given Monoid instance.open fun fold(M: Monoid<A>, s: S): A |
foldMap | Map each target to a type R and use a Monoid to fold the resultsabstract fun <R> foldMap(M: Monoid<R>, s: S, f: (A) -> R): R |
forall | Check if all targets satisfy the predicateopen fun forall(s: S, p: (A) -> Boolean ): Boolean |
getAll | Get all targets of the Foldopen fun getAll(s: S): ListK<A> |
headOption | Get the first targetopen fun headOption(s: S): Option<A> |
isEmpty | Check if there is no targetopen fun isEmpty(s: S): Boolean |
lastOption | Get the last targetopen fun lastOption(s: S): Option<A> |
left | Create a sum of the Fold and a type Copen fun <C> left(): Fold <Either<S, C>, Either<A, C>> |
nonEmpty | Check if there is at least one targetopen fun nonEmpty(s: S): Boolean |
plus | Plus operator overload to compose lensesopen operator fun <C> plus(other: Fold <A, C>): Fold <S, C> open operator fun <C> plus(other: Optional <A, C>): Fold <S, C> open operator fun <C> plus(other: Getter <A, C>): Fold <S, C> open operator fun <C> plus(other: Prism <A, C>): Fold <S, C> open operator fun <C> plus(other: Lens <A, C>): Fold <S, C> open operator fun <C> plus(other: Iso <A, C>): Fold <S, C> open operator fun <C> plus(other: Traversal <A, C>): Fold <S, C> |
right | Create a sum of a type C and the Foldopen fun <C> right(): Fold <Either<C, S>, Either<C, A>> |
size | Calculate the number of targetsopen fun size(s: S): Int |
codiagonal | Fold that takes either S or S and strips the choice of S.fun <S> codiagonal(): Fold <Either<S, S>, S> |
fromFoldable | Create a Fold from a arrow.Foldablefun <F, S> fromFoldable(foldable: Foldable<F>): Fold <Kind<F, S>, S> |
id | fun <A> id(): Fold <A, A> |
select | Creates a Fold based on a predicate of the source Sfun <S> select(p: (S) -> Boolean ): Fold <S, S> |
void | Fold that points to nothingfun <A, B> void(): Fold <A, B> |
some | DSL to compose a Prism with focus arrow.core.Some with a Fold with a focus of Option<S>val <T, S> Fold <T, Option<S>>.some: Fold <T, S> |
at | DSL to compose At with a Fold for a structure S to focus in on A at given index I.fun <T, S, I, A> Fold <T, S>.at(AT: At <S, I, A>, i: I): Fold <T, A> |
every | DSL to compose Each with a Fold for a structure S to see all its foci Afun <T, S, A> Fold <T, S>.~~every~~(EA: Each <S, A>): Fold <T, A> DSL to compose Traversal with a Fold for a structure S to see all its foci A fun <T, S, A> Fold <T, S>.every(TR: Traversal <S, A>): Fold <T, A> |
index | DSL to compose Index with a Fold for a structure S to focus in on A at given index Ifun <T, S, I, A> Fold <T, S>.index(ID: Index <S, I, A>, i: I): Fold <T, A> |
Do you like Arrow?
✖