Package fj.data.optic
Class PPrism<S,T,A,B>
java.lang.Object
fj.data.optic.PPrism<S,T,A,B>
- Type Parameters:
S
- the source of aPPrism
T
- the modified source of aPPrism
A
- the target of aPPrism
B
- 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 aPPrism
as aPTraversal
composeFold
(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 aPPrism
with aPTraversal
get the target of aPPrism
or nothing if there is no targetgetOrModify
(S s) get the target of aPPrism
or modify the source in case there is no targetfinal boolean
isMatching
(S s) check if aPPrism
has a targetmodify polymorphically the target of aPPrism
with a functionmodifyEitherF
(F<A, Either<L, B>> f) modify polymorphically the target of aPPrism
with an Applicative functionmodifyFunctionF
(F<A, F<C, B>> f) modify polymorphically the target of aPPrism
with an Applicative functionmodify polymorphically the target of aPPrism
with an Applicative functionmodifyListF
(F<A, List<B>> f) modify polymorphically the target of aPPrism
with an Applicative functionmodifyOption
(F<A, B> f) modify polymorphically the target of aPPrism
with a function.modifyOptionF
(F<A, Option<B>> f) modify polymorphically the target of aPPrism
with an Applicative functionmodify polymorphically the target of aPPrism
with an Applicative functionmodifyPromiseF
(F<A, Promise<B>> f) modify polymorphically the target of aPPrism
with an Applicative functionmodifyStreamF
(F<A, Stream<B>> f) modify polymorphically the target of aPPrism
with an Applicative functionfinal F
<S, Trampoline<T>> modifyTrampolineF
(F<A, Trampoline<B>> f) modify polymorphically the target of aPPrism
with an Applicative functionmodify polymorphically the target of aPPrism
with an Applicative functionfinal <E> F
<S, Validation<E, T>> modifyValidationF
(F<A, Validation<E, B>> f) modify polymorphically the target of aPPrism
with an Applicative functionstatic <S,
T> PPrism <S, T, S, T> pId()
static <S,
T, A, B>
PPrism<S, T, A, B> create aPPrism
using the canonical functions: getOrModify and reverseGetre()
abstract T
reverseGet
(B b) get the modified source of aPPrism
set polymorphically the target of aPPrism
with a valueset polymorphically the target of aPPrism
with a value.
-
Constructor Details
-
PPrism
PPrism()
-
-
Method Details
-
getOrModify
get the target of aPPrism
or modify the source in case there is no target -
reverseGet
get the modified source of aPPrism
-
getOption
get the target of aPPrism
or nothing if there is no target -
modifyFunctionF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyEitherF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyIOF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyTrampolineF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyPromiseF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyListF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyOptionF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyStreamF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyP1F
modify polymorphically the target of aPPrism
with an Applicative function -
modifyValidationF
modify polymorphically the target of aPPrism
with an Applicative function -
modifyV2F
modify polymorphically the target of aPPrism
with an Applicative function -
modify
modify polymorphically the target of aPPrism
with a function -
modifyOption
-
set
set polymorphically the target of aPPrism
with a value -
setOption
-
isMatching
check if aPPrism
has a target -
re
-
composeFold
-
composeGetter
-
composeSetter
-
composeTraversal
compose aPPrism
with aPTraversal
-
composeOptional
-
composeLens
-
composePrism
-
composeIso
-
asFold
-
asSetter
-
asTraversal
view aPPrism
as aPTraversal
-
asOptional
-
pId
-
pPrism
create aPPrism
using the canonical functions: getOrModify and reverseGet
-