Class RecursiveResult<A,​B>

    • Constructor Detail

      • RecursiveResult

        private RecursiveResult()
    • Method Detail

      • biMapL

        public <C> RecursiveResult<C,​B> biMapL​(Fn1<? super A,​? extends C> fn)
        Covariantly map over the left parameter.
        Specified by:
        biMapL in interface Bifunctor<A,​B,​RecursiveResult<?,​?>>
        Specified by:
        biMapL in interface BoundedBifunctor<A,​B,​java.lang.Object,​java.lang.Object,​RecursiveResult<?,​?>>
        Type Parameters:
        C - the new left parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a bifunctor over C (the new left parameter) and B (the same right parameter)
      • biMapR

        public <C> RecursiveResult<A,​C> biMapR​(Fn1<? super B,​? extends C> fn)
        Covariantly map over the right parameter. For all bifunctors that are also functors, it should hold that biMapR(f) == fmap(f).
        Specified by:
        biMapR in interface Bifunctor<A,​B,​RecursiveResult<?,​?>>
        Specified by:
        biMapR in interface BoundedBifunctor<A,​B,​java.lang.Object,​java.lang.Object,​RecursiveResult<?,​?>>
        Type Parameters:
        C - the new right parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a bifunctor over A (the same left parameter) and C (the new right parameter)
      • biMap

        public <C,​D> RecursiveResult<C,​D> biMap​(Fn1<? super A,​? extends C> lFn,
                                                            Fn1<? super B,​? extends D> rFn)
        Dually map covariantly over both the left and right parameters. This is isomorphic to biMapL(lFn).biMapR(rFn).
        Specified by:
        biMap in interface Bifunctor<A,​B,​RecursiveResult<?,​?>>
        Specified by:
        biMap in interface BoundedBifunctor<A,​B,​java.lang.Object,​java.lang.Object,​RecursiveResult<?,​?>>
        Type Parameters:
        C - the new left parameter type
        D - the new right parameter type
        Parameters:
        lFn - the left parameter mapping function
        rFn - the right parameter mapping function
        Returns:
        a bifunctor over C (the new left parameter type) and D (the new right parameter type)
      • flatMap

        public <C> RecursiveResult<A,​C> flatMap​(Fn1<? super B,​? extends Monad<C,​RecursiveResult<A,​?>>> f)
        Chain dependent computations that may continue or short-circuit based on previous results.
        Specified by:
        flatMap in interface Monad<A,​B>
        Specified by:
        flatMap in interface MonadRec<A,​B>
        Type Parameters:
        C - the resulting monad parameter type
        Parameters:
        f - the dependent computation over A
        Returns:
        the new monad instance
      • pure

        public <C> RecursiveResult<A,​C> pure​(C c)
        Lift the value b into this applicative functor.
        Specified by:
        pure in interface Applicative<A,​B>
        Specified by:
        pure in interface Monad<A,​B>
        Specified by:
        pure in interface MonadRec<A,​B>
        Type Parameters:
        C - the type of the returned applicative's parameter
        Parameters:
        c - the value
        Returns:
        an instance of this applicative over b
      • fmap

        public <C> RecursiveResult<A,​C> fmap​(Fn1<? super B,​? extends C> fn)
        Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.
        Specified by:
        fmap in interface Applicative<A,​B>
        Specified by:
        fmap in interface Functor<A,​B>
        Specified by:
        fmap in interface Monad<A,​B>
        Specified by:
        fmap in interface MonadRec<A,​B>
        Specified by:
        fmap in interface Traversable<A,​B>
        Type Parameters:
        C - the new parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a functor over B (the new parameter type)
      • zip

        public <C> RecursiveResult<A,​C> zip​(Applicative<Fn1<? super B,​? extends C>,​RecursiveResult<A,​?>> appFn)
        Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
        Specified by:
        zip in interface Applicative<A,​B>
        Specified by:
        zip in interface Monad<A,​B>
        Specified by:
        zip in interface MonadRec<A,​B>
        Type Parameters:
        C - the resulting applicative parameter type
        Parameters:
        appFn - the other applicative instance
        Returns:
        the mapped applicative
      • discardL

        public <C> RecursiveResult<A,​C> discardL​(Applicative<C,​RecursiveResult<A,​?>> appB)
        Sequence both this Applicative and appB, discarding this Applicative's result and returning appB. This is generally useful for sequentially performing side-effects.
        Specified by:
        discardL in interface Applicative<A,​B>
        Specified by:
        discardL in interface Monad<A,​B>
        Specified by:
        discardL in interface MonadRec<A,​B>
        Type Parameters:
        C - the type of the returned Applicative's parameter
        Parameters:
        appB - the other Applicative
        Returns:
        appB
      • discardR

        public <C> RecursiveResult<A,​B> discardR​(Applicative<C,​RecursiveResult<A,​?>> appB)
        Sequence both this Applicative and appB, discarding appB's result and returning this Applicative. This is generally useful for sequentially performing side-effects.
        Specified by:
        discardR in interface Applicative<A,​B>
        Specified by:
        discardR in interface Monad<A,​B>
        Specified by:
        discardR in interface MonadRec<A,​B>
        Type Parameters:
        C - the type of appB's parameter
        Parameters:
        appB - the other Applicative
        Returns:
        this Applicative
      • traverse

        public <C,​App extends Applicative<?,​App>,​TravB extends Traversable<C,​RecursiveResult<A,​?>>,​AppTrav extends Applicative<TravB,​App>> AppTrav traverse​(Fn1<? super B,​? extends Applicative<C,​App>> fn,
                                                                                                                                                                                                      Fn1<? super TravB,​? extends AppTrav> pure)
        Apply fn to each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.
        Specified by:
        traverse in interface Traversable<A,​B>
        Type Parameters:
        C - the resulting element type
        App - the result applicative type
        TravB - this Traversable instance over B
        AppTrav - the full inferred resulting type from the traversal
        Parameters:
        fn - the function to apply
        pure - the applicative pure function
        Returns:
        the traversed Traversable, wrapped inside an applicative
      • recurse

        public static <A,​B> RecursiveResult<A,​B> recurse​(A a)
        Static factory method for creating a "recurse" value.
        Type Parameters:
        A - the recurse type
        B - the terminate type
        Parameters:
        a - the value
        Returns:
        the RecursiveResult
      • terminate

        public static <A,​B> RecursiveResult<A,​B> terminate​(B b)
        Static factory method for creating a "terminate" value.
        Type Parameters:
        A - the recurse type
        B - the terminate type
        Parameters:
        b - the value
        Returns:
        the RecursiveResult
      • pureRecursiveResult

        public static <A> Pure<RecursiveResult<A,​?>> pureRecursiveResult()
        The canonical Pure instance for RecursiveResult.
        Type Parameters:
        A - the recursive function's input type
        Returns:
        the Pure instance