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

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

    public abstract class PLens<S,​T,​A,​B>
    extends java.lang.Object
    A PLens can be seen as a pair of functions: - `get: S => A` i.e. from an `S`, we can extract an `A` - `set: (B, S) => T` i.e. if we replace an `A` by a `B` in an `S`, we obtain a `T`

    A PLens could also be defined as a weaker PIso where set requires an additional parameter than reverseGet.

    PLens stands for Polymorphic Lens as it set and modify methods change a type `A` to `B` and `S` to `T`. Lens is a PLens restricted to monomorphic updates.

    A PLens is also a valid Getter, Fold, POptional, PTraversal and PSetter

    Typically a PLens or Lens can be defined between a Product (e.g. case class, tuple, HList) and one of it is component.

    • Constructor Detail

      • PLens

        PLens()
    • Method Detail

      • get

        public abstract A get​(S s)
        get the target of a PLens
      • set

        public abstract java.util.function.Function<S,​T> set​(B b)
        set polymorphically the target of a PLens using a function
      • modifyFunctionF

        public abstract <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 PLens with an Applicative function
      • modifyEitherF

        public abstract <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 PLens with an Applicative function
      • modifyOptionF

        public abstract java.util.function.Function<S,​Option<T>> modifyOptionF​(java.util.function.Function<A,​Option<B>> f)
        modify polymorphically the target of a PLens with an Applicative function
      • modifyIterableF

        public abstract 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 PLens with an Applicative function
      • modifySupplierF

        public abstract 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 PLens with an Applicative function
      • modifyPairF

        public abstract java.util.function.Function<S,​Pair<T,​T>> modifyPairF​(java.util.function.Function<A,​Pair<B,​B>> f)
        modify polymorphically the target of a PLens with an Applicative function
      • modify

        public abstract java.util.function.Function<S,​T> modify​(java.util.function.Function<A,​B> f)
        modify polymorphically the target of a PLens using a function
      • composeFold

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

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

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

        public static <S,​T> PLens<S,​T,​S,​T> pId()
      • pLens

        public static <S,​T,​A,​B> PLens<S,​T,​A,​B> pLens​(java.util.function.Function<S,​A> get,
                                                                                         java.util.function.Function<B,​java.util.function.Function<S,​T>> set)
        create a PLens using a pair of functions: one to get the target, one to set the target.