Package fj.data.optic
Class PLens<S,T,A,B>
- java.lang.Object
-
- fj.data.optic.PLens<S,T,A,B>
-
- Type Parameters:
S- the source of aPLensT- the modified source of aPLensA- the target of aPLensB- the modified target of aPLens
- Direct Known Subclasses:
Lens
public abstract class PLens<S,T,A,B> extends java.lang.ObjectAPLenscan be seen as a pair of functions:get: S => Ai.e. from anS, we can extract anAset: (B, S) => Ti.e. if we replace anAby aBin anS, we obtain aT
A
PLenscould also be defined as a weakerPIsowhere set requires an additional parameter than reverseGet.PLensstands for Polymorphic Lens as it set and modify methods change a typeAtoBandStoT.Lensis aPLensrestricted to monomoprhic updates.A
PLensis also a validGetter,Fold,POptional,PTraversalandPSetterTypically a
PLensorLenscan be defined between a Product (e.g. case class, tuple, HList) and one of it is component.
-
-
Constructor Summary
Constructors Constructor Description PLens()
-
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()POptional<S,T,A,B>asOptional()PSetter<S,T,A,B>asSetter()PTraversal<S,T,A,B>asTraversal()view aPLensas aPTraversal<C> Fold<S,C>composeFold(Fold<A,C> other)<C> Getter<S,C>composeGetter(Getter<A,C> other)<C,D>
PLens<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>
POptional<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 aPLenswith aPTraversalabstract Aget(S s)get the target of aPLensabstract F<S,T>modify(F<A,B> f)modify polymorphically the target of aPLensusing a functionabstract <L> F<S,Either<L,T>>modifyEitherF(F<A,Either<L,B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract <C> F<S,F<C,T>>modifyFunctionF(F<A,F<C,B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract F<S,IO<T>>modifyIOF(F<A,IO<B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract F<S,List<T>>modifyListF(F<A,List<B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract F<S,Option<T>>modifyOptionF(F<A,Option<B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract F<S,P1<T>>modifyP1F(F<A,P1<B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract F<S,Promise<T>>modifyPromiseF(F<A,Promise<B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract F<S,Stream<T>>modifyStreamF(F<A,Stream<B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract F<S,Trampoline<T>>modifyTrampolineF(F<A,Trampoline<B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract F<S,V2<T>>modifyV2F(F<A,V2<B>> f)modify polymorphically the target of aPLenswith an Applicative functionabstract <E> F<S,Validation<E,T>>modifyValidationF(F<A,Validation<E,B>> f)modify polymorphically the target of aPLenswith an Applicative functionstatic <S,T>
PLens<S,T,S,T>pId()static <S,T,A,B>
PLens<S,T,A,B>pLens(F<S,A> get, F<B,F<S,T>> set)create aPLensusing a pair of functions: one to get the target, one to set the target.abstract F<S,T>set(B b)set polymorphically the target of aPLensusing a function<S1,T1>
PLens<Either<S,S1>,Either<T,T1>,A,B>sum(PLens<S1,T1,A,B> other)join twoPLenswith the same target
-
-
-
Method Detail
-
modifyFunctionF
public abstract <C> F<S,F<C,T>> modifyFunctionF(F<A,F<C,B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyEitherF
public abstract <L> F<S,Either<L,T>> modifyEitherF(F<A,Either<L,B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyIOF
public abstract F<S,IO<T>> modifyIOF(F<A,IO<B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyTrampolineF
public abstract F<S,Trampoline<T>> modifyTrampolineF(F<A,Trampoline<B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyPromiseF
public abstract F<S,Promise<T>> modifyPromiseF(F<A,Promise<B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyListF
public abstract F<S,List<T>> modifyListF(F<A,List<B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyOptionF
public abstract F<S,Option<T>> modifyOptionF(F<A,Option<B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyStreamF
public abstract F<S,Stream<T>> modifyStreamF(F<A,Stream<B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyP1F
public abstract F<S,P1<T>> modifyP1F(F<A,P1<B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyValidationF
public abstract <E> F<S,Validation<E,T>> modifyValidationF(F<A,Validation<E,B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modifyV2F
public abstract F<S,V2<T>> modifyV2F(F<A,V2<B>> f)
modify polymorphically the target of aPLenswith an Applicative function
-
modify
public abstract F<S,T> modify(F<A,B> f)
modify polymorphically the target of aPLensusing a function
-
sum
public final <S1,T1> PLens<Either<S,S1>,Either<T,T1>,A,B> sum(PLens<S1,T1,A,B> other)
join twoPLenswith the same target
-
composeTraversal
public final <C,D> PTraversal<S,T,C,D> composeTraversal(PTraversal<A,B,C,D> other)
compose aPLenswith 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 aPLensas aPTraversal
-
pId
public static <S,T> PLens<S,T,S,T> pId()
-
-