Package io.atlassian.fugue.optic
Class PPrism<S,T,A,B>
java.lang.Object
io.atlassian.fugue.optic.PPrism<S,T,A,B>
- Type Parameters:
S- the source of aPPrismT- the modified source of aPPrismA- the target of aPPrismB- the modified target of aPPrism
- Direct Known Subclasses:
Prism
A
PPrism can be seen as a pair of functions: - `getOrModify: S =>
T \/ A` - `reverseGet : B => T`
A PPrism could also be defined as a weaker PIso where get can
fail.
Typically a PPrism or Prism encodes the relation between a
Sum or CoProduct type (e.g. sealed trait) and one of it is element.
PPrism stands for Polymorphic Prism as it set and modify methods
change a type `A` to `B` and `S` to `T`. Prism is a PPrism
where the type of target cannot be modified.
A PPrism is also a valid Fold, POptional,
PTraversal and PSetter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasFold()asSetter()PTraversal<S, T, A, B> view aPPrismas 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 aPPrismwith aPTraversalget the target of aPPrismor nothing if there is no targetgetOrModify(S s) get the target of aPPrismor modify the source in case there is no targetfinal booleanisMatching(S s) check if aPPrismhas a targetmodify polymorphically the target of aPPrismwith a functionmodifyEitherF(Function<A, Either<L, B>> f) modify polymorphically the target of aPPrismwith an Applicative functionmodifyFunctionF(Function<A, Function<C, B>> f) modify polymorphically the target of aPPrismwith an Applicative functionmodifyIterableF(Function<A, Iterable<B>> f) modify polymorphically the target of aPPrismwith an Applicative functionmodifyOption(Function<A, B> f) modify polymorphically the target of aPPrismwith a function.modifyOptionF(Function<A, Option<B>> f) modify polymorphically the target of aPPrismwith an Applicative functionmodify polymorphically the target of aPPrismwith an Applicative functionmodifySupplierF(Function<A, Supplier<B>> f) modify polymorphically the target of aPPrismwith an Applicative functionstatic <S,T> PPrism <S, T, S, T> pId()static <S,T, A, B>
PPrism<S, T, A, B> create aPPrismusing the canonical functions: getOrModify and reverseGetre()abstract TreverseGet(B b) get the modified source of aPPrismset polymorphically the target of aPPrismwith a valueset polymorphically the target of aPPrismwith a value.
-
Constructor Details
-
PPrism
PPrism()
-
-
Method Details
-
getOrModify
get the target of aPPrismor modify the source in case there is no target -
reverseGet
get the modified source of aPPrism -
getOption
get the target of aPPrismor nothing if there is no target -
modifyFunctionF
modify polymorphically the target of aPPrismwith an Applicative function -
modifyEitherF
modify polymorphically the target of aPPrismwith an Applicative function -
modifyOptionF
modify polymorphically the target of aPPrismwith an Applicative function -
modifyPairF
modify polymorphically the target of aPPrismwith an Applicative function -
modifySupplierF
modify polymorphically the target of aPPrismwith an Applicative function -
modifyIterableF
modify polymorphically the target of aPPrismwith an Applicative function -
modify
modify polymorphically the target of aPPrismwith a function -
modifyOption
-
set
set polymorphically the target of aPPrismwith a value -
setOption
-
isMatching
check if aPPrismhas a target -
re
-
composeFold
-
composeGetter
-
composeSetter
-
composeTraversal
compose aPPrismwith aPTraversal -
composeOptional
-
composeLens
-
composePrism
-
composeIso
-
asFold
-
asSetter
-
asTraversal
view aPPrismas aPTraversal -
asOptional
-
pId
-
pPrism
public static <S,T, PPrism<S,A, B> T, pPrismA, B> (Function<S, Either<T, A>> getOrModify, Function<B, T> reverseGet) create aPPrismusing the canonical functions: getOrModify and reverseGet
-