Package-level declarations

Types

Link copied to clipboard
interface Copy<A>
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class DelicateOptic
Link copied to clipboard
object Every
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
annotation class OpticsCopyMarker
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
interface PIso<S, T, A, B> : PPrism<S, T, A, B> , PLens<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> : POptional<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> : PTraversal<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 PPrism<S, T, A, B> : POptional<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
interface PTraversal<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 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 <S, T, A, B, C, D> PLens<S, T, A?, B?>.composeNull(other: PLens<A, B, C, D>): PLens<S, T, C?, D?>

Compose two lenses, where the first one has a nullable focus, keeping the nullability in the types.

Link copied to clipboard
infix fun <A> A.cons(tail: List<A>): List<A>
Link copied to clipboard
fun <A> A.copy(f: Copy<A>.() -> Unit): A

Small DSL which parallel Kotlin's built-in copy, but using optics instead of field names. See Copy for the operations allowed inside the block.

Link copied to clipboard
fun <S> POptional.Companion.filter(predicate: (S) -> Boolean): Optional<S, S>

Focuses on the value only if the predicate is true. This optics The optic is perfectly OK when used to get values using getOrNull or getAll; but requires some caution using modify with it.

Link copied to clipboard
fun <S, A, B> PTraversal.Companion.fromLenses(lens1: PLens<S, S, A, B>, vararg lenses: PLens<S, S, A, B>): PTraversal<S, S, A, B>

Focuses on a sequence of lenses.

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: (source: S) -> Option<A>, set: (source: S, focus: A) -> S): Optional<S, A>
Link copied to clipboard
fun <S, A> Prism(getOption: (source: S) -> Option<A>, reverseGet: (focus: 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>?