S - the source of a PIsoT - the modified source of a PIsoA - the target of a PIsoB - the modified target of a PIsopublic abstract class PIso<S,T,A,B> extends Object
PIso defines an isomorphism between types S, A and B, T:
get reverse.get
--------------------> -------------------->
S A T B
<-------------------- <--------------------
reverse.reverseGet reverseGet
In addition, if f and g forms an isomorphism between `A` and `B`, i.e. if `f
. g = id` and `g . f = id`, then a PIso defines an isomorphism
between `S` and `T`:
S T S T
| ↑ ↑ |
| | | |
get | | reverseGet reverse.reverseGet | | reverse.get
| | | |
↓ f | | g ↓
A --------> B A <-------- B
A PIso is also a valid Getter, Fold, PLens,
PPrism, POptional, PTraversal and PSetter
| Modifier and Type | Method and Description |
|---|---|
Fold<S,A> |
asFold()
|
Getter<S,A> |
asGetter()
|
PLens<S,T,A,B> |
asLens()
|
POptional<S,T,A,B> |
asOptional()
|
PPrism<S,T,A,B> |
asPrism()
|
PSetter<S,T,A,B> |
asSetter()
|
PTraversal<S,T,A,B> |
asTraversal()
view a
PIso as a PTraversal |
<C> Fold<S,C> |
composeFold(Fold<A,C> other)
|
<C> Getter<S,C> |
composeGetter(Getter<A,C> other)
|
<C,D> PIso<S,T,C,D> |
composeIso(PIso<A,B,C,D> other)
|
<C,D> PLens<S,T,C,D> |
composeLens(PLens<A,B,C,D> other)
|
<C,D> POptional<S,T,C,D> |
composeOptional(POptional<A,B,C,D> other)
|
<C,D> PPrism<S,T,C,D> |
composePrism(PPrism<A,B,C,D> other)
|
<C,D> PSetter<S,T,C,D> |
composeSetter(PSetter<A,B,C,D> other)
|
<C,D> PTraversal<S,T,C,D> |
composeTraversal(PTraversal<A,B,C,D> other)
compose a
PIso with a PTraversal |
<C> PIso<Pair<S,C>,Pair<T,C>,Pair<A,C>,Pair<B,C>> |
first() |
abstract A |
get(S s)
get the target of a
PIso |
Function<S,T> |
modify(Function<A,B> f)
modify polymorphically the target of a
PIso with a function |
<L> Function<S,Either<L,T>> |
modifyEitherF(Function<A,Either<L,B>> f)
modify polymorphically the target of a
PIso with an Applicative
function |
<C> Function<S,Function<C,T>> |
modifyFunctionF(Function<A,Function<C,B>> f)
modify polymorphically the target of a
PIso with an Applicative
function |
Function<S,Iterable<T>> |
modifyIterableF(Function<A,Iterable<B>> f)
modify polymorphically the target of a
PIso with an Applicative
function |
Function<S,Option<T>> |
modifyOptionF(Function<A,Option<B>> f)
modify polymorphically the target of a
PIso with an Applicative
function |
Function<S,Pair<T,T>> |
modifyPairF(Function<A,Pair<B,B>> f)
modify polymorphically the target of a
PIso with an Applicative
function |
Function<S,Supplier<T>> |
modifySupplierF(Function<A,Supplier<B>> f)
modify polymorphically the target of a
PIso with an Applicative
function |
static <S,T> PIso<S,T,S,T> |
pId()
create a
PIso between any type and itself. |
static <S,T,A,B> PIso<S,T,A,B> |
pIso(Function<S,A> get,
Function<B,T> reverseGet)
create a
PIso using a pair of functions: one to get the target and
one to get the source. |
<S1,T1,A1,B1> |
product(PIso<S1,T1,A1,B1> other)
pair two disjoint
PIso |
abstract PIso<B,A,T,S> |
reverse()
reverse a
PIso: the source becomes the target and the target
becomes the source |
abstract T |
reverseGet(B b)
get the modified source of a
PIso |
<C> PIso<Pair<C,S>,Pair<C,T>,Pair<C,A>,Pair<C,B>> |
second() |
Function<S,T> |
set(B b)
set polymorphically the target of a
PIso with a value |
public abstract PIso<B,A,T,S> reverse()
PIso: the source becomes the target and the target
becomes the sourcepublic final <C> Function<S,Function<C,T>> modifyFunctionF(Function<A,Function<C,B>> f)
PIso with an Applicative
functionpublic final <L> Function<S,Either<L,T>> modifyEitherF(Function<A,Either<L,B>> f)
PIso with an Applicative
functionpublic final Function<S,Option<T>> modifyOptionF(Function<A,Option<B>> f)
PIso with an Applicative
functionpublic final Function<S,Iterable<T>> modifyIterableF(Function<A,Iterable<B>> f)
PIso with an Applicative
functionpublic final Function<S,Supplier<T>> modifySupplierF(Function<A,Supplier<B>> f)
PIso with an Applicative
functionpublic final Function<S,Pair<T,T>> modifyPairF(Function<A,Pair<B,B>> f)
PIso with an Applicative
functionpublic final Function<S,T> modify(Function<A,B> f)
PIso with a functionpublic <S1,T1,A1,B1> PIso<Pair<S,S1>,Pair<T,T1>,Pair<A,A1>,Pair<B,B1>> product(PIso<S1,T1,A1,B1> other)
PIsopublic final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
PIso with a PTraversalpublic PTraversal<S,T,A,B> asTraversal()
PIso as a PTraversalpublic static <S,T,A,B> PIso<S,T,A,B> pIso(Function<S,A> get, Function<B,T> reverseGet)
PIso using a pair of functions: one to get the target and
one to get the source.public static <S,T> PIso<S,T,S,T> pId()
PIso between any type and itself. id is the zero element
of optics composition, for all optics o of type O (e.g. Lens, Iso, Prism,
...):
o composeIso Iso.id == o Iso.id composeO o == o
(replace composeO by composeLens, composeIso, composePrism, ...)
Copyright © 2018 Atlassian. All rights reserved.