Package arrow.optics

Types

Link copied to clipboard
typealias Every<S, A> = PEvery<S, S, A, A>
Link copied to clipboard
interface Fold<S, A>

A Fold is an optic that allows to focus into structure and get multiple results.

Link copied to clipboard
fun interface Getter<S, A> : Fold<S, A>

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

Link copied to clipboard
typealias Iso<S, A> = PIso<S, S, A, A>

Iso is a type alias for PIso which fixes the type arguments and restricts the PIso to monomorphic updates.

Link copied to clipboard
typealias Lens<S, A> = PLens<S, S, A, A>

Lens is a type alias for PLens which fixes the type arguments and restricts the PLens to monomorphic updates.

Link copied to clipboard
typealias Optional<S, A> = POptional<S, S, A, A>

Optional is a type alias for POptional which fixes the type arguments and restricts the POptional to monomorphic updates.

Link copied to clipboard
typealias OptionalGetter<S, A> = POptionalGetter<S, S, A>

OptionalGetter is a type alias for POptionalGetter which fixes the type arguments and restricts the POptionalGetter to monomorphic updates.

Link copied to clipboard
interface PEvery<S, T, A, B> : PTraversal<S, T, A, B> , Fold<S, A> , PSetter<S, T, A, B>

Composition of Fold and Traversal It combines their powers

Link copied to clipboard
interface PIso<S, T, A, B> : PPrism<S, T, A, B> , PLens<S, T, A, B> , Getter<S, A> , POptional<S, T, A, B> , PSetter<S, T, A, B> , Fold<S, A> , PTraversal<S, T, A, B> , PEvery<S, T, A, B>

An Iso is a loss less invertible optic that defines an isomorphism between a type S and A i.e. a data class and its properties represented by TupleN

Link copied to clipboard
interface PLens<S, T, A, B> : Getter<S, A> , POptional<S, T, A, B> , PSetter<S, T, A, B> , PTraversal<S, T, A, B> , PEvery<S, T, A, B>

A Lens (or Functional Reference) is an optic that can focus into a structure for getting, setting or modifying the focus (target).

Link copied to clipboard
interface POptional<S, T, A, B> : PSetter<S, T, A, B> , POptionalGetter<S, T, A> , PTraversal<S, T, A, B> , PEvery<S, T, A, B>

Optional is an optic that allows to focus into a structure and querying or copy'ing an optional focus.

Link copied to clipboard
interface POptionalGetter<S, T, A> : Fold<S, A>

An OptionalGetter is an optic that allows into a structure and querying an optional focus.

Link copied to clipboard
interface PPrism<S, T, A, B> : POptional<S, T, A, B> , PSetter<S, T, A, B> , POptionalGetter<S, T, A> , PTraversal<S, T, A, B> , PEvery<S, T, A, B>

A Prism is a loss less invertible optic that can look into a structure and optionally find its focus. Mostly used for finding a focus that is only present under certain conditions i.e. list head Prism, Int>

Link copied to clipboard
typealias Prism<S, A> = PPrism<S, S, A, A>

Prism is a type alias for PPrism which fixes the type arguments and restricts the PPrism to monomorphic updates.

Link copied to clipboard
fun interface PSetter<S, T, A, B>

A Setter is an optic that allows to see into a structure and set or modify its focus.

Link copied to clipboard
fun interface PTraversal<S, T, A, B> : PSetter<S, T, A, B>

A Traversal is an optic that allows to see into a structure with 0 to N foci.

Link copied to clipboard
typealias Setter<S, A> = PSetter<S, S, A, A>

Setter is a type alias for PSetter which fixes the type arguments and restricts the PSetter to monomorphic updates.

Link copied to clipboard
typealias Traversal<S, A> = PTraversal<S, S, A, A>

Traversal is a type alias for PTraversal which fixes the type arguments and restricts the PTraversal to monomorphic updates.

Functions

Link copied to clipboard
infix fun <A> A.cons(tail: List<A>): List<A>
Link copied to clipboard
operator fun <A, T> PLens<T, T, List<A>, List<A>>.get(i: Int): POptional<T, T, A, A>
Link copied to clipboard
fun <S, A> Optional(getOption: (S) -> <ERROR CLASS><A>, set: (S, A) -> S): Optional<S, A>
Link copied to clipboard
fun <S, A> OptionalGetter(getOption: (S) -> <ERROR CLASS><A>): OptionalGetter<S, A>
Link copied to clipboard
fun <S, A> Prism(getOption: (S) -> <ERROR CLASS><A>, reverseGet: (A) -> S): Prism<S, A>

Invoke operator overload to create a PPrism of type S with a focus A where A is a subtype of S Can also be used to construct Prism

Link copied to clipboard
infix fun <A> List<A>.snoc(last: A): List<A>
Link copied to clipboard
fun <A> List<A>.uncons(): Pair<A, List<A>>?
Link copied to clipboard
fun <A> List<A>.unsnoc(): Pair<List<A>, A>?