Package fj.data.optic
Class PIso<S,T,A,B>
- java.lang.Object
-
- fj.data.optic.PIso<S,T,A,B>
-
- Type Parameters:
S- the source of aPIsoT- the modified source of aPIsoA- the target of aPIsoB- the modified target of aPIso
- Direct Known Subclasses:
Iso
public abstract class PIso<S,T,A,B> extends java.lang.ObjectAPIsodefines an isomorphism between types S, A and B, T:
In addition, if f and g forms an isomorphism betweenget reverse.get --------------------> --------------------> S A T B <-------------------- <-------------------- reverse.reverseGet reverseGetAandB, i.e. iff . g = idandg . f = id, then aPIsodefines an isomorphism betweenSandT:
AS T S T | | | | | | | | get | | reverseGet reverse.reverseGet | | reverse.get | | | | | f | | g | A --------> B A <-------- BPIsois also a validGetter,Fold,PLens,PPrism,POptional,PTraversalandPSetter
-
-
Constructor Summary
Constructors Constructor Description PIso()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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 aPIsoas aPTraversal<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 aPIsowith aPTraversal<C> PIso<P2<S,C>,P2<T,C>,P2<A,C>,P2<B,C>>first()abstract Aget(S s)get the target of aPIsoF<S,T>modify(F<A,B> f)modify polymorphically the target of aPIsowith a function<L> F<S,Either<L,T>>modifyEitherF(F<A,Either<L,B>> f)modify polymorphically the target of aPIsowith an Applicative function<C> F<S,F<C,T>>modifyFunctionF(F<A,F<C,B>> f)modify polymorphically the target of aPIsowith an Applicative functionF<S,IO<T>>modifyIOF(F<A,IO<B>> f)modify polymorphically the target of aPIsowith an Applicative functionF<S,List<T>>modifyListF(F<A,List<B>> f)modify polymorphically the target of aPIsowith an Applicative functionF<S,Option<T>>modifyOptionF(F<A,Option<B>> f)modify polymorphically the target of aPIsowith an Applicative functionF<S,P1<T>>modifyP1F(F<A,P1<B>> f)modify polymorphically the target of aPIsowith an Applicative functionF<S,Promise<T>>modifyPromiseF(F<A,Promise<B>> f)modify polymorphically the target of aPIsowith an Applicative functionF<S,Stream<T>>modifyStreamF(F<A,Stream<B>> f)modify polymorphically the target of aPIsowith an Applicative functionF<S,Trampoline<T>>modifyTrampolineF(F<A,Trampoline<B>> f)modify polymorphically the target of aPIsowith an Applicative functionF<S,V2<T>>modifyV2F(F<A,V2<B>> f)modify polymorphically the target of aPIsowith an Applicative function<E> F<S,Validation<E,T>>modifyValidationF(F<A,Validation<E,B>> f)modify polymorphically the target of aPIsowith an Applicative functionstatic <S,T>
PIso<S,T,S,T>pId()create aPIsobetween any type and itself.static <S,T,A,B>
PIso<S,T,A,B>pIso(F<S,A> get, F<B,T> reverseGet)create aPIsousing a pair of functions: one to get the target and one to get the source.<S1,T1,A1,B1>
PIso<P2<S,S1>,P2<T,T1>,P2<A,A1>,P2<B,B1>>product(PIso<S1,T1,A1,B1> other)pair two disjointPIsoabstract PIso<B,A,T,S>reverse()reverse aPIso: the source becomes the target and the target becomes the sourceabstract TreverseGet(B b)get the modified source of aPIso<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 aPIsowith a value
-
-
-
Method Detail
-
reverse
public abstract PIso<B,A,T,S> reverse()
reverse aPIso: the source becomes the target and the target becomes the source
-
modifyFunctionF
public final <C> F<S,F<C,T>> modifyFunctionF(F<A,F<C,B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyEitherF
public final <L> F<S,Either<L,T>> modifyEitherF(F<A,Either<L,B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyIOF
public final F<S,IO<T>> modifyIOF(F<A,IO<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyTrampolineF
public final F<S,Trampoline<T>> modifyTrampolineF(F<A,Trampoline<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyPromiseF
public final F<S,Promise<T>> modifyPromiseF(F<A,Promise<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyListF
public final F<S,List<T>> modifyListF(F<A,List<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyOptionF
public final F<S,Option<T>> modifyOptionF(F<A,Option<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyStreamF
public final F<S,Stream<T>> modifyStreamF(F<A,Stream<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyP1F
public final F<S,P1<T>> modifyP1F(F<A,P1<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyValidationF
public final <E> F<S,Validation<E,T>> modifyValidationF(F<A,Validation<E,B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyV2F
public final F<S,V2<T>> modifyV2F(F<A,V2<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modify
public final F<S,T> modify(F<A,B> f)
modify polymorphically the target of aPIsowith a function
-
product
public 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)
pair two disjointPIso
-
composeTraversal
public final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
compose aPIsowith aPTraversal
-
composeOptional
public final <C,D> POptional<S,T,C,D> composeOptional(POptional<A,B,C,D> other)
-
asTraversal
public PTraversal<S,T,A,B> asTraversal()
view aPIsoas aPTraversal
-
pIso
public static <S,T,A,B> PIso<S,T,A,B> pIso(F<S,A> get, F<B,T> reverseGet)
create aPIsousing a pair of functions: one to get the target and one to get the source.
-
pId
public static <S,T> PIso<S,T,S,T> pId()
create aPIsobetween any type and itself. id is the zero element of optics composition, for all optics o of type O (e.g. Lens, Iso, Prism, ...):
(replace composeO by composeLens, composeIso, composePrism, ...)o composeIso Iso.id == o Iso.id composeO o == o
-
-