Package io.atlassian.fugue.optic
Class PIso<S,T,A,B>
- java.lang.Object
-
- io.atlassian.fugue.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:get reverse.get --------------------> --------------------> S A T B <-------------------- <-------------------- reverse.reverseGet reverseGetIn addition, if f and g forms an isomorphism between `A` and `B`, i.e. if `f . g = id` and `g . f = id`, then a
PIsodefines an isomorphism between `S` and `T`:S T S T | ↑ ↑ | | | | | get | | reverseGet reverse.reverseGet | | reverse.get | | | | ↓ f | | g ↓ A --------> B A <-------- BA
PIsois 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<Pair<S,C>,Pair<T,C>,Pair<A,C>,Pair<B,C>>first()abstract Aget(S s)get the target of aPIsojava.util.function.Function<S,T>modify(java.util.function.Function<A,B> f)modify polymorphically the target of aPIsowith a function<L> java.util.function.Function<S,Either<L,T>>modifyEitherF(java.util.function.Function<A,Either<L,B>> f)modify polymorphically the target of aPIsowith an Applicative function<C> java.util.function.Function<S,java.util.function.Function<C,T>>modifyFunctionF(java.util.function.Function<A,java.util.function.Function<C,B>> f)modify polymorphically the target of aPIsowith an Applicative functionjava.util.function.Function<S,java.lang.Iterable<T>>modifyIterableF(java.util.function.Function<A,java.lang.Iterable<B>> f)modify polymorphically the target of aPIsowith an Applicative functionjava.util.function.Function<S,Option<T>>modifyOptionF(java.util.function.Function<A,Option<B>> f)modify polymorphically the target of aPIsowith an Applicative functionjava.util.function.Function<S,Pair<T,T>>modifyPairF(java.util.function.Function<A,Pair<B,B>> f)modify polymorphically the target of aPIsowith an Applicative functionjava.util.function.Function<S,java.util.function.Supplier<T>>modifySupplierF(java.util.function.Function<A,java.util.function.Supplier<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(java.util.function.Function<S,A> get, java.util.function.Function<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<Pair<S,S1>,Pair<T,T1>,Pair<A,A1>,Pair<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<Pair<C,S>,Pair<C,T>,Pair<C,A>,Pair<C,B>>second()java.util.function.Function<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> java.util.function.Function<S,java.util.function.Function<C,T>> modifyFunctionF(java.util.function.Function<A,java.util.function.Function<C,B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyEitherF
public final <L> java.util.function.Function<S,Either<L,T>> modifyEitherF(java.util.function.Function<A,Either<L,B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyOptionF
public final java.util.function.Function<S,Option<T>> modifyOptionF(java.util.function.Function<A,Option<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyIterableF
public final java.util.function.Function<S,java.lang.Iterable<T>> modifyIterableF(java.util.function.Function<A,java.lang.Iterable<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifySupplierF
public final java.util.function.Function<S,java.util.function.Supplier<T>> modifySupplierF(java.util.function.Function<A,java.util.function.Supplier<B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modifyPairF
public final java.util.function.Function<S,Pair<T,T>> modifyPairF(java.util.function.Function<A,Pair<B,B>> f)
modify polymorphically the target of aPIsowith an Applicative function
-
modify
public final java.util.function.Function<S,T> modify(java.util.function.Function<A,B> f)
modify polymorphically the target of aPIsowith a function
-
set
public final java.util.function.Function<S,T> set(B b)
set polymorphically the target of aPIsowith a value
-
product
public <S1,T1,A1,B1> PIso<Pair<S,S1>,Pair<T,T1>,Pair<A,A1>,Pair<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(java.util.function.Function<S,A> get, java.util.function.Function<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, ...):o composeIso Iso.id == o Iso.id composeO o == o
(replace composeO by composeLens, composeIso, composePrism, ...)
-
-