Class PLens<S,T,A,B>
java.lang.Object
io.atlassian.fugue.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
A
PLens can be seen as a pair of functions: - `get: S => A` i.e.
from an `S`, we can extract an `A` - `set: (B, S) => T` i.e. if we replace
an `A` by a `B` in an `S`, we obtain a `T`
A PLens could also be defined as a weaker PIso where set
requires an additional parameter than reverseGet.
PLens stands for Polymorphic Lens as it set and modify methods change
a type `A` to `B` and `S` to `T`. Lens is a PLens restricted
to monomorphic updates.
A PLens is also a valid Getter, Fold,
POptional, PTraversal and PSetter
Typically a PLens or Lens can be defined between a Product
(e.g. case class, tuple, HList) and one of it is component.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasFold()asGetter()asSetter()PTraversal<S, T, A, B> view aPLensas aPTraversalcomposeFold(Fold<A, C> other) composeGetter(Getter<A, C> other) composeIso(PIso<A, B, C, D> other) composeLens(PLens<A, B, C, D> other) composeOptional(POptional<A, B, C, D> other) composePrism(PPrism<A, B, C, D> other) composeSetter(PSetter<A, B, C, D> other) final <C,D> PTraversal <S, T, C, D> composeTraversal(PTraversal<A, B, C, D> other) compose aPLenswith aPTraversalabstract Aget the target of aPLensmodify polymorphically the target of aPLensusing a functionmodifyEitherF(Function<A, Either<L, B>> f) modify polymorphically the target of aPLenswith an Applicative functionmodifyFunctionF(Function<A, Function<C, B>> f) modify polymorphically the target of aPLenswith an Applicative functionmodifyIterableF(Function<A, Iterable<B>> f) modify polymorphically the target of aPLenswith an Applicative functionmodifyOptionF(Function<A, Option<B>> f) modify polymorphically the target of aPLenswith an Applicative functionmodify polymorphically the target of aPLenswith an Applicative functionmodifySupplierF(Function<A, Supplier<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> create aPLensusing a pair of functions: one to get the target, one to set the target.set polymorphically the target of aPLensusing a functionjoin twoPLenswith the same target
-
Constructor Details
-
PLens
PLens()
-
-
Method Details
-
get
-
set
-
modifyFunctionF
-
modifyEitherF
-
modifyOptionF
-
modifyIterableF
-
modifySupplierF
-
modifyPairF
-
modify
-
sum
-
composeFold
-
composeGetter
-
composeSetter
-
composeTraversal
compose aPLenswith aPTraversal -
composeOptional
-
composePrism
-
composeLens
-
composeIso
-
asFold
-
asGetter
-
asSetter
-
asTraversal
view aPLensas aPTraversal -
asOptional
-
pId
-
pLens
-