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> 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 a PIso with 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 a PIso with 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 a PIso with 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 a PIso with 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 a PIso with 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 a PIso with 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 a PIso with a function
      • set

        public final java.util.function.Function<S,​T> set​(B b)
        set polymorphically the target of a PIso with 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 disjoint PIso
      • 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​(java.util.function.Function<S,​A> get,
                                                                                       java.util.function.Function<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, ...)