Class Lazy<A>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  Lazy.Compose<A>  
      private static class  Lazy.Later<A>  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Lazy()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      <B> Lazy<B> discardL​(Applicative<B,​Lazy<?>> appB)
      Sequence both this Applicative and appB, discarding this Applicative's result and returning appB.
      <B> Lazy<A> discardR​(Applicative<B,​Lazy<?>> appB)
      Sequence both this Applicative and appB, discarding appB's result and returning this Applicative.
      boolean equals​(java.lang.Object other)  
      <B> Lazy<B> flatMap​(Fn1<? super A,​? extends Monad<B,​Lazy<?>>> f)
      Chain dependent computations that may continue or short-circuit based on previous results.
      <B> Lazy<B> fmap​(Fn1<? super A,​? extends B> fn)
      Covariantly transmute this functor's parameter using the given mapping function.
      int hashCode()  
      static <A> Lazy<A> lazy​(A value)
      Lift a pure value into a lazy computation.
      static <A> Lazy<A> lazy​(Fn0<A> fn0)
      Wrap a computation in a lazy computation.
      <B> Lazy<B> pure​(B b)
      Lift the value b into this applicative functor.
      static Pure<Lazy<?>> pureLazy()
      The canonical Pure instance for Lazy.
      java.lang.String toString()  
      <B> Lazy<B> trampolineM​(Fn1<? super A,​? extends MonadRec<RecursiveResult<A,​B>,​Lazy<?>>> fn)
      Given some operation yielding a RecursiveResult inside this MonadRec, internally trampoline the operation until it yields a termination instruction.
      <B,​App extends Applicative<?,​App>,​TravB extends Traversable<B,​Lazy<?>>,​AppTrav extends Applicative<TravB,​App>>
      AppTrav
      traverse​(Fn1<? super A,​? extends Applicative<B,​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.
      abstract A value()
      Returns the value represented by this lazy computation.
      <B> Lazy<B> zip​(Applicative<Fn1<? super A,​? extends B>,​Lazy<?>> appFn)
      Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

        coerce
      • Methods inherited from interface com.jnape.palatable.lambda.monad.MonadRec

        lazyZip
    • Constructor Detail

      • Lazy

        private Lazy()
    • Method Detail

      • value

        public abstract A value()
        Returns the value represented by this lazy computation.
        Returns:
        the value
      • flatMap

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

        public <B,​App extends Applicative<?,​App>,​TravB extends Traversable<B,​Lazy<?>>,​AppTrav extends Applicative<TravB,​App>> AppTrav traverse​(Fn1<? super A,​? extends Applicative<B,​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,​Lazy<?>>
        Type Parameters:
        B - 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
      • pure

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

        public final <B> Lazy<B> fmap​(Fn1<? super A,​? extends B> 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,​Lazy<?>>
        Specified by:
        fmap in interface Functor<A,​Lazy<?>>
        Specified by:
        fmap in interface Monad<A,​Lazy<?>>
        Specified by:
        fmap in interface MonadRec<A,​Lazy<?>>
        Specified by:
        fmap in interface Traversable<A,​Lazy<?>>
        Type Parameters:
        B - the new parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a functor over B (the new parameter type)
      • zip

        public <B> Lazy<B> zip​(Applicative<Fn1<? super A,​? extends B>,​Lazy<?>> 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,​Lazy<?>>
        Specified by:
        zip in interface Monad<A,​Lazy<?>>
        Specified by:
        zip in interface MonadRec<A,​Lazy<?>>
        Type Parameters:
        B - the resulting applicative parameter type
        Parameters:
        appFn - the other applicative instance
        Returns:
        the mapped applicative
      • discardL

        public final <B> Lazy<B> discardL​(Applicative<B,​Lazy<?>> 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,​Lazy<?>>
        Specified by:
        discardL in interface Monad<A,​Lazy<?>>
        Specified by:
        discardL in interface MonadRec<A,​Lazy<?>>
        Type Parameters:
        B - the type of the returned Applicative's parameter
        Parameters:
        appB - the other Applicative
        Returns:
        appB
      • discardR

        public final <B> Lazy<A> discardR​(Applicative<B,​Lazy<?>> 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,​Lazy<?>>
        Specified by:
        discardR in interface Monad<A,​Lazy<?>>
        Specified by:
        discardR in interface MonadRec<A,​Lazy<?>>
        Type Parameters:
        B - the type of appB's parameter
        Parameters:
        appB - the other Applicative
        Returns:
        this Applicative
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • lazy

        public static <A> Lazy<A> lazy​(A value)
        Lift a pure value into a lazy computation.
        Type Parameters:
        A - the value type
        Parameters:
        value - the value
        Returns:
        the new Lazy
      • lazy

        public static <A> Lazy<A> lazy​(Fn0<A> fn0)
        Wrap a computation in a lazy computation.
        Type Parameters:
        A - the value type
        Parameters:
        fn0 - the computation
        Returns:
        the new Lazy
      • pureLazy

        public static Pure<Lazy<?>> pureLazy()
        The canonical Pure instance for Lazy.
        Returns:
        the Pure instance