Package fj.data.optic

Class PIso<S,​T,​A,​B>

  • Type Parameters:
    S - the source of a PIso
    T - the modified source of a PIso
    A - the target of a PIso
    B - the modified target of a PIso
    Direct Known Subclasses:
    Iso

    public abstract class PIso<S,​T,​A,​B>
    extends java.lang.Object
    A PIso defines an isomorphism between types S, A and B, T:
    
                  get                           reverse.get
         -------------------->             -------------------->
       S                       A         T                       B
         <--------------------             <--------------------
           reverse.reverseGet                   reverseGet
     
    In addition, if f and g forms an isomorphism between A and B, i.e. if f . g = id and g . f = id, then a PIso defines an isomorphism between S and T:
    
         S           T                                   S           T
         |           |                                   |           |
         |           |                                   |           |
     get |           | reverseGet     reverse.reverseGet |           | reverse.get
         |           |                                   |           |
         |     f     |                                   |     g     |
         A --------> B                                   A <-------- B
     
    A PIso is also a valid Getter, Fold, PLens, PPrism, POptional, PTraversal and PSetter
    • Constructor Detail

      • PIso

        PIso()
    • Method Detail

      • get

        public abstract A get​(S s)
        get the target of a PIso
      • reverseGet

        public abstract T reverseGet​(B b)
        get the modified source of a PIso
      • reverse

        public abstract PIso<B,​A,​T,​S> reverse()
        reverse a PIso: the source becomes the target and the target becomes the source
      • modifyFunctionF

        public final <C> F<S,​F<C,​T>> modifyFunctionF​(F<A,​F<C,​B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyEitherF

        public final <L> F<S,​Either<L,​T>> modifyEitherF​(F<A,​Either<L,​B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyIOF

        public final F<S,​IO<T>> modifyIOF​(F<A,​IO<B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyTrampolineF

        public final F<S,​Trampoline<T>> modifyTrampolineF​(F<A,​Trampoline<B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyPromiseF

        public final F<S,​Promise<T>> modifyPromiseF​(F<A,​Promise<B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyListF

        public final F<S,​List<T>> modifyListF​(F<A,​List<B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyOptionF

        public final F<S,​Option<T>> modifyOptionF​(F<A,​Option<B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyStreamF

        public final F<S,​Stream<T>> modifyStreamF​(F<A,​Stream<B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyP1F

        public final F<S,​P1<T>> modifyP1F​(F<A,​P1<B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyValidationF

        public final <E> F<S,​Validation<E,​T>> modifyValidationF​(F<A,​Validation<E,​B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modifyV2F

        public final F<S,​V2<T>> modifyV2F​(F<A,​V2<B>> f)
        modify polymorphically the target of a PIso with an Applicative function
      • modify

        public final F<S,​T> modify​(F<A,​B> f)
        modify polymorphically the target of a PIso with a function
      • set

        public final F<S,​T> set​(B b)
        set polymorphically the target of a PIso with a value
      • product

        public final <S1,​T1,​A1,​B1> PIso<P2<S,​S1>,​P2<T,​T1>,​P2<A,​A1>,​P2<B,​B1>> product​(PIso<S1,​T1,​A1,​B1> other)
        pair two disjoint PIso
      • first

        public <C> PIso<P2<S,​C>,​P2<T,​C>,​P2<A,​C>,​P2<B,​C>> first()
      • second

        public <C> PIso<P2<C,​S>,​P2<C,​T>,​P2<C,​A>,​P2<C,​B>> second()
      • composeFold

        public final <C> Fold<S,​C> composeFold​(Fold<A,​C> other)
        compose a PIso with a Fold
      • composeSetter

        public final <C,​D> PSetter<S,​T,​C,​D> composeSetter​(PSetter<A,​B,​C,​D> other)
        compose a PIso with a PSetter
      • composePrism

        public final <C,​D> PPrism<S,​T,​C,​D> composePrism​(PPrism<A,​B,​C,​D> other)
        compose a PIso with a PPrism
      • composeLens

        public final <C,​D> PLens<S,​T,​C,​D> composeLens​(PLens<A,​B,​C,​D> other)
        compose a PIso with a PLens
      • composeIso

        public final <C,​D> PIso<S,​T,​C,​D> composeIso​(PIso<A,​B,​C,​D> other)
        compose a PIso with a PIso
      • pIso

        public static <S,​T,​A,​B> PIso<S,​T,​A,​B> pIso​(F<S,​A> get,
                                                                                       F<B,​T> reverseGet)
        create a PIso using 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 a PIso between 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, ...)