S
- the source of a PIso
T
- the modified source of a PIso
A
- the target of a PIso
B
- the modified target of a PIso
public abstract class PIso<S,T,A,B>
extends java.lang.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<P2<S,C>,P2<T,C>,P2<A,C>,P2<B,C>> |
first() |
abstract A |
get(S s)
get the target of a
PIso |
F<S,T> |
modify(F<A,B> f)
modify polymorphically the target of a
PIso with a function |
<L> F<S,Either<L,T>> |
modifyEitherF(F<A,Either<L,B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
<C> F<S,F<C,T>> |
modifyFunctionF(F<A,F<C,B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
F<S,IO<T>> |
modifyIOF(F<A,IO<B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
F<S,List<T>> |
modifyListF(F<A,List<B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
F<S,Option<T>> |
modifyOptionF(F<A,Option<B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
F<S,P1<T>> |
modifyP1F(F<A,P1<B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
F<S,Promise<T>> |
modifyPromiseF(F<A,Promise<B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
F<S,Stream<T>> |
modifyStreamF(F<A,Stream<B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
F<S,Trampoline<T>> |
modifyTrampolineF(F<A,Trampoline<B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
F<S,V2<T>> |
modifyV2F(F<A,V2<B>> f)
modify polymorphically the target of a
PIso with an Applicative function |
<E> F<S,Validation<E,T>> |
modifyValidationF(F<A,Validation<E,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(F<S,A> get,
F<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<P2<C,S>,P2<C,T>,P2<C,A>,P2<C,B>> |
second() |
F<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> F<S,F<C,T>> modifyFunctionF(F<A,F<C,B>> f)
PIso
with an Applicative functionpublic final <L> F<S,Either<L,T>> modifyEitherF(F<A,Either<L,B>> f)
PIso
with an Applicative functionpublic final F<S,IO<T>> modifyIOF(F<A,IO<B>> f)
PIso
with an Applicative functionpublic final F<S,Trampoline<T>> modifyTrampolineF(F<A,Trampoline<B>> f)
PIso
with an Applicative functionpublic final F<S,Promise<T>> modifyPromiseF(F<A,Promise<B>> f)
PIso
with an Applicative functionpublic final F<S,List<T>> modifyListF(F<A,List<B>> f)
PIso
with an Applicative functionpublic final F<S,Option<T>> modifyOptionF(F<A,Option<B>> f)
PIso
with an Applicative functionpublic final F<S,Stream<T>> modifyStreamF(F<A,Stream<B>> f)
PIso
with an Applicative functionpublic final F<S,P1<T>> modifyP1F(F<A,P1<B>> f)
PIso
with an Applicative functionpublic final <E> F<S,Validation<E,T>> modifyValidationF(F<A,Validation<E,B>> f)
PIso
with an Applicative functionpublic final F<S,V2<T>> modifyV2F(F<A,V2<B>> f)
PIso
with an Applicative functionpublic final F<S,T> modify(F<A,B> f)
PIso
with a functionpublic final <S1,T1,A1,B1> PIso<P2<S,S1>,P2<T,T1>,P2<A,A1>,P2<B,B1>> product(PIso<S1,T1,A1,B1> other)
PIso
public final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
PIso
with a PTraversal
public PTraversal<S,T,A,B> asTraversal()
PIso
as a PTraversal
public static <S,T,A,B> PIso<S,T,A,B> pIso(F<S,A> get, F<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, ...)