//arrow-optics/arrow.optics/Getter

Getter

common fun interface Getter<S, A> : Fold<S, A>

A Getter is an optic that allows to see into a structure and getting a focus.

A Getter can be seen as a get function:

  • get: (S) -> A meaning we can look into an S and get an A

Parameters

common

   
S the source of a Getter
A the focus of a Getter

Types

Name Summary
Companion common object Companion

Functions

Name Summary
all common open fun all(source: S, predicate: (A) -> Boolean): Boolean
Check if all targets satisfy the predicate
any common open fun any(source: S, predicate: (A) -> Boolean): Boolean
Returns true if at least one focus matches the given predicate.
choice common open infix fun <C> choice(other: Fold<C, A>): Fold<Either<S, C>, A>
Join two Fold with the same target
common open infix fun <C> choice(other: Getter<C, A>): Getter<Either<S, C>, A>
Join two Getter with the same focus
combineAll common open fun combineAll(M: Monoid<A>, source: S): A
Alias for fold.
compose common open infix fun <C> compose(other: Fold<in A, out C>): Fold<S, C>
Compose a Fold with a Fold
common open infix fun <C> compose(other: Getter<in A, out C>): Getter<S, C>
Compose a Getter with a Getter
exists common open fun exists(source: S, predicate: (A) -> Boolean): Boolean
Check whether at least one element satisfies the predicate.
findOrNull common open fun findOrNull(source: S, predicate: (A) -> Boolean): A?
Find the first element matching the predicate, if one exists.
first common open fun <C> first(): Getter<Pair<S, C>, Pair<A, C»
Create a product of the Getter and a type C
firstOrNull common open fun firstOrNull(source: S): A?
Get the first target or null
fold common open fun fold(M: Monoid<A>, source: S): A
Fold using the given Monoid instance.
foldMap common open override fun <R> foldMap(M: Monoid<R>, source: S, map: (A) -> R): R
Map each target to a type R and use a Monoid to fold the results
get common abstract fun get(source: S): A
Get the focus of a Getter
getAll common open fun getAll(source: S): List<A>
Get all targets of the Fold
isEmpty common open fun isEmpty(source: S): Boolean
Check if there is no target
isNotEmpty common open fun isNotEmpty(source: S): Boolean
Check if there is at least one target
lastOrNull common open fun lastOrNull(source: S): A?
Get the last target or null
left common open override fun <C> left(): Getter<Either<S, C>, Either<A, C»
Create a sum of the Getter and type C
plus common open operator fun <C> plus(other: Fold<in A, out C>): Fold<S, C>
open operator fun <C> plus(other: Getter<in A, out C>): Getter<S, C>
right common open override fun <C> right(): Getter<Either<C, S>, Either<C, A»
Create a sum of type C and the Getter
second common open fun <C> second(): Getter<Pair<C, S>, Pair<C, A»
Create a product of type C and the Getter
size common open fun size(source: S): Int
Calculate the number of targets
split common open infix fun <C, D> split(other: Getter<C, D>): Getter<Pair<S, C>, Pair<A, D»
Pair two disjoint Getter
zip common open infix fun <C> zip(other: Getter<S, C>): Getter<S, Pair<A, C»
Zip two Getter optics with the same source S

Inheritors

Name
PIso
PLens

Extensions

Name Summary
at common fun <T, S, I, A> Getter<T, S>.at(AT: At<S, I, A>, i: I): Getter<T, A>
DSL to compose At with a Getter for a structure S to focus in on A at given index I.

Do you like Arrow?

Arrow Org
<