Package fj.data.optic

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

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

    public abstract class PTraversal<S,​T,​A,​B>
    extends java.lang.Object
    A PTraversal can be seen as a POptional generalised to 0 to n targets where n can be infinite.

    PTraversal stands for Polymorphic Traversal as it set and modify methods change a type A to B and S to T. Traversal is a PTraversal restricted to monomoprhic updates.

    • Constructor Detail

      • PTraversal

        public PTraversal()
    • Method Detail

      • modifyFunctionF

        public abstract <C> F<S,​F<C,​T>> modifyFunctionF​(F<A,​F<C,​B>> f)
        modify polymorphically the target of a PTraversal 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 PTraversal with an Applicative function
      • modifyIOF

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

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

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

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

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

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

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

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

        public abstract <M> F<S,​M> foldMap​(Monoid<M> monoid,
                                                 F<A,​M> f)
        map each target to a Monoid and combine the results
      • fold

        public final F<S,​A> fold​(Monoid<A> m)
        combine all targets using a target's Monoid
      • getAll

        public final List<A> getAll​(S s)
        get all the targets of a PTraversal
      • find

        public final F<S,​Option<A>> find​(F<A,​java.lang.Boolean> p)
        find the first target of a PTraversal matching the predicate
      • headOption

        public final Option<A> headOption​(S s)
        get the first target of a PTraversal
      • exist

        public final F<S,​java.lang.Boolean> exist​(F<A,​java.lang.Boolean> p)
        check if at least one target satisfies the predicate
      • all

        public final F<S,​java.lang.Boolean> all​(F<A,​java.lang.Boolean> p)
        check if all targets satisfy the predicate
      • modify

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

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

        public static <S,​T> PTraversal<S,​T,​S,​T> pId()
      • pTraversal

        public static <S,​T,​A,​B> PTraversal<S,​T,​A,​B> pTraversal​(F<S,​A> get1,
                                                                                                   F<S,​A> get2,
                                                                                                   F3<B,​B,​S,​T> set)
      • pTraversal

        public static <S,​T,​A,​B> PTraversal<S,​T,​A,​B> pTraversal​(F<S,​A> get1,
                                                                                                   F<S,​A> get2,
                                                                                                   F<S,​A> get3,
                                                                                                   F4<B,​B,​B,​S,​T> set)
      • pTraversal

        public static <S,​T,​A,​B> PTraversal<S,​T,​A,​B> pTraversal​(F<S,​A> get1,
                                                                                                   F<S,​A> get2,
                                                                                                   F<S,​A> get3,
                                                                                                   F<S,​A> get4,
                                                                                                   F5<B,​B,​B,​B,​S,​T> set)
      • pTraversal

        public static <S,​T,​A,​B> PTraversal<S,​T,​A,​B> pTraversal​(F<S,​A> get1,
                                                                                                   F<S,​A> get2,
                                                                                                   F<S,​A> get3,
                                                                                                   F<S,​A> get4,
                                                                                                   F<S,​A> get5,
                                                                                                   F6<B,​B,​B,​B,​B,​S,​T> set)
      • pTraversal

        public static <S,​T,​A,​B> PTraversal<S,​T,​A,​B> pTraversal​(F<S,​A> get1,
                                                                                                   F<S,​A> get2,
                                                                                                   F<S,​A> get3,
                                                                                                   F<S,​A> get4,
                                                                                                   F<S,​A> get5,
                                                                                                   F<S,​A> get6,
                                                                                                   F7<B,​B,​B,​B,​B,​B,​S,​T> set)
      • fromCurried

        private static <S,​T,​A,​B> PTraversal<S,​T,​A,​B> fromCurried​(PTraversal<S,​F<B,​T>,​A,​B> curriedTraversal,
                                                                                                     F<S,​A> lastGet)