arrow-optics / arrow.optics / PLens
interface PLens<S, T, A, B> :
PLensOf
<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).
A (polymorphic) PLens is useful when setting or modifying a value for a constructed type i.e. PLens<Tuple2<Double, Int>, Tuple2<String, Int>, Double, String>
A PLens can be seen as a pair of functions:
get: (S) -> A
meaning we can focus into an S
and extract an A
set: (B) -> (S) -> T
meaning we can focus into an S
and set a value B
for a target A
and obtain a modified source T
S
- the source of a PLens
T
- the modified source of a PLens
A
- the focus of a PLens
B
- the modified focus of a PLens
| asFold | View a PLens as a Foldopen fun asFold():
Fold
<S, A>
|
| asGetter | View PLens as a Getteropen fun asGetter():
Getter
<S, A>
|
| asOptional | View a PLens as a POptionalopen fun asOptional():
POptional
<S, T, A, B>
|
| asSetter | View a PLens as a PSetteropen fun asSetter():
PSetter
<S, T, A, B>
|
| asTraversal | View a PLens as a PTraversalopen fun asTraversal():
PTraversal
<S, T, A, B>
|
| choice | Join two PLens with the same focus in Aopen infix fun <S1, T1> choice(other:
PLens
<S1, T1, A, B>):
PLens
<Either<S, S1>, Either<T, T1>, A, B>
|
| compose | Compose a PLens with another PLensopen infix fun <C, D> compose(l:
PLens
<A, B, C, D>):
PLens
<S, T, C, D>
Compose a PLens with a POptionalopen infix fun <C, D> compose(other:
POptional
<A, B, C, D>):
POptional
<S, T, C, D>
Compose an PLens with a PIsoopen infix fun <C, D> compose(other:
PIso
<A, B, C, D>):
PLens
<S, T, C, D>
Compose an PLens with a Getteropen infix fun <C> compose(other:
Getter
<A, C>):
Getter
<S, C>
Compose an PLens with a PSetteropen infix fun <C, D> compose(other:
PSetter
<A, B, C, D>):
PSetter
<S, T, C, D>
Compose an PLens with a PPrismopen infix fun <C, D> compose(other:
PPrism
<A, B, C, D>):
POptional
<S, T, C, D>
Compose an PLens with a Foldopen infix fun <C> compose(other:
Fold
<A, C>):
Fold
<S, C>
Compose an PLens with a PTraversalopen infix fun <C, D> compose(other:
PTraversal
<A, B, C, D>):
PTraversal
<S, T, C, D>
|
| exist | Verify if the focus of a PLens satisfies the predicateopen fun exist(s: S, p: (A) ->
Boolean
):
Boolean
|
| find | Find a focus that satisfies the predicateopen fun find(s: S, p: (A) ->
Boolean
): Option<A>
|
| first | Create a product of the PLens and a type Copen fun <C> first():
PLens
<Tuple2<S, C>, Tuple2<T, C>, Tuple2<A, C>, Tuple2<B, C>>
|
| get | abstract fun get(s: S): A
|
| lift | Lift a function f: (A) -> B to the context of
S:
(S) -> Topen fun lift(f: (A) -> B): (S) -> T` |
| [liftF](lift-f.html) | Lift a function [f](lift-f.html#arrow.optics.PLens$liftF(arrow.typeclasses.Functor((arrow.optics.PLens.liftF.F)), kotlin.Function1((arrow.optics.PLens.A, arrow.Kind((arrow.optics.PLens.liftF.F, arrow.optics.PLens.B)))))/f): `(A) -> Kind<F, B> to the context of `S`: `(S) -> Kind<F, T>
open fun
`open operator fun <C, D> plus(other: `[`PIso`](../-p-iso/index.html)`<A, B, C, D>): `[`PLens`](./index.html)`<S, T, C, D>`
`open operator fun
`open operator fun <C, D> plus(other: `[`PSetter`](../-p-setter/index.html)`<A, B, C, D>): `[`PSetter`](../-p-setter/index.html)`<S, T, C, D>`
`open operator fun <C, D> plus(other: `[`PPrism`](../-p-prism/index.html)`<A, B, C, D>): `[`POptional`](../-p-optional/index.html)`<S, T, C, D>`
`open operator fun
`open operator fun <C, D> plus(other: `[`PTraversal`](../-p-traversal/index.html)`<A, B, C, D>): `[`PTraversal`](../-p-traversal/index.html)`<S, T, C, D>` |
| [second](second.html) | Create a product of a type [C](second.html#C) and the [PLens](./index.html)`open fun
codiagonal | PLens that takes either S or S and strips the choice of S.fun <S> codiagonal(): Lens <Either<S, S>, S> |
id | fun <S> id(): PLens <S, S, S, S> |
invoke | Invoke operator overload to create a PLens of type S with target A . Can also be used to construct Lensoperator fun <S, T, A, B> invoke(get: (S) -> A, set: (S, B) -> T): PLens <S, T, A, B> |
nonEmptyListHead | Lens to operate on the head of a NonEmptyListfun <A> nonEmptyListHead(): Lens <NonEmptyList<A>, A> |
nonEmptyListTail | Lens to operate on the tail of a NonEmptyListfun <A> nonEmptyListTail(): Lens <NonEmptyList<A>, List <A>> |
pairFirst | Lens to focus into the first value of a Pairfun <A, B> pairFirst(): Lens < Pair <A, B>, A> |
pairPFirst | PLens to focus into the first value of a Pairfun <A, B, R> pairPFirst(): PLens < Pair <A, B>, Pair <R, B>, A, R> |
pairPSecond | PLens to focus into the second value of a Pairfun <A, B, R> pairPSecond(): PLens < Pair <A, B>, Pair <A, R>, B, R> |
pairSecond | Lens to focus into the second value of a Pairfun <A, B> pairSecond(): Lens < Pair <A, B>, B> |
tripleFirst | Lens to focus into the first value of a Triplefun <A, B, C> tripleFirst(): Lens < Triple <A, B, C>, A> |
triplePFirst | PLens to focus into the first value of a Triplefun <A, B, C, R> triplePFirst(): PLens < Triple <A, B, C>, Triple <R, B, C>, A, R> |
triplePSecond | PLens to focus into the second value of a Triplefun <A, B, C, R> triplePSecond(): PLens < Triple <A, B, C>, Triple <A, R, C>, B, R> |
triplePThird | PLens to focus into the third value of a Triplefun <A, B, C, R> triplePThird(): PLens < Triple <A, B, C>, Triple <A, B, R>, C, R> |
tripleSecond | Lens to focus into the second value of a Triplefun <A, B, C> tripleSecond(): Lens < Triple <A, B, C>, B> |
tripleThird | Lens to focus into the third value of a Triplefun <A, B, C> tripleThird(): Lens < Triple <A, B, C>, C> |
some | DSL to compose a Prism with focus arrow.core.Some with a Lens with a focus of Option<S>val <T, S> Lens <T, Option<S>>.some: Optional <T, S> |
at | DSL to compose At with a Lens for a structure S to focus in on A at given index I.fun <T, S, I, A> Lens <T, S>.at(AT: At <S, I, A>, i: I): Lens <T, A> |
at | fun <K, V, T> PLens <T, T, MapK<K, V>, MapK<K, V>>.~~at~~(i: K): PLens <T, T, Option<V>, Option<V>> |
at | fun <K, V, T> PLens <T, T, MapK<K, V>, MapK<K, V>>.~~at~~(i: K): PLens <T, T, Option<V>, Option<V>> |
at | fun <A, T> PLens <T, T, SetK<A>, SetK<A>>.~~at~~(i: A): PLens <T, T, Boolean , Boolean > |
at | fun <A, T> PLens <T, T, SetK<A>, SetK<A>>.~~at~~(i: A): PLens <T, T, Boolean , Boolean > |
every | DSL to compose Each with a Lens for a structure S to see all its foci Afun <T, S, A> Lens <T, S>.~~every~~(EA: Each <S, A>): Traversal <T, A> DSL to compose Traversal with a Lens for a structure S to see all its foci A fun <T, S, A> Lens <T, S>.every(TR: Traversal <S, A>): Traversal <T, A> |
get | operator fun <A, T> PLens <T, T, List <A>, List <A>>.get(i: Int ): POptional <T, T, A, A> |
get | operator fun <A, T> PLens <T, T, ListK<A>, ListK<A>>.~~get~~(i: Int ): POptional <T, T, A, A> |
get | operator fun <K, V, T> PLens <T, T, MapK<K, V>, MapK<K, V>>.~~get~~(i: K): POptional <T, T, V, V> |
get | operator fun <A, T> PLens <T, T, NonEmptyList<A>, NonEmptyList<A>>.~~get~~(i: Int ): POptional <T, T, A, A> |
get | operator fun <A, T> PLens <T, T, SequenceK<A>, SequenceK<A>>.~~get~~(i: Int ): POptional <T, T, A, A> |
get | operator fun <A, T> PLens <T, T, SequenceK<A>, SequenceK<A>>.~~get~~(i: Int ): POptional <T, T, A, A> |
index | DSL to compose Index with a Lens for a structure S to focus in on A at given index Ifun <T, S, I, A> Lens <T, S>.index(ID: Index <S, I, A>, i: I): Optional <T, A> |
index | fun <K, V, T> PLens <T, T, MapK<K, V>, MapK<K, V>>.~~index~~(i: K): POptional <T, T, V, V> |
index | fun <K, V, T> PLens <T, T, MapK<K, V>, MapK<K, V>>.~~index~~(i: K): POptional <T, T, V, V> |
Do you like Arrow?
✖