Package fj.data.optic

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

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

    public abstract class POptional<S,​T,​A,​B>
    extends java.lang.Object
    A POptional can be seen as a pair of functions:
    • getOrModify: S => T \/ A
    • set : (B, S) => T

    A POptional could also be defined as a weaker PLens and weaker PPrism

    POptional stands for Polymorphic Optional as it set and modify methods change a type A to B and S to T. Optional is a POptional restricted to monomoprhic updates: type Optional[S, A] = POptional[S, S, A, A]

    • Constructor Detail

      • POptional

        POptional()
    • Method Detail

      • getOrModify

        public abstract Either<T,​A> getOrModify​(S s)
        get the target of a POptional or modify the source in case there is no target
      • set

        public abstract F<S,​T> set​(B b)
        get the modified source of a POptional
      • getOption

        public abstract Option<A> getOption​(S s)
        get the target of a POptional or nothing if there is no target
      • modifyFunctionF

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

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

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

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

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

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

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

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

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

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

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

        public abstract F<S,​T> modify​(F<A,​B> f)
        modify polymorphically the target of a POptional with a function
      • modifyOption

        public final F<S,​Option<T>> modifyOption​(F<A,​B> f)
        modify polymorphically the target of a POptional with a function. return empty if the POptional is not matching
      • setOption

        public final F<S,​Option<T>> setOption​(B b)
        set polymorphically the target of a POptional with a value. return empty if the POptional is not matching
      • isMatching

        public final boolean isMatching​(S s)
        check if a POptional has a target
      • pId

        public static <S,​T> POptional<S,​T,​S,​T> pId()
      • pOptional

        public static <S,​T,​A,​B> POptional<S,​T,​A,​B> pOptional​(F<S,​Either<T,​A>> getOrModify,
                                                                                                 F<B,​F<S,​T>> set)
        create a POptional using the canonical functions: getOrModify and set