Class Compose<F extends Applicative<?,​F>,​G extends Applicative<?,​G>,​A>

  • Type Parameters:
    F - The outer applicative
    G - The inner applicative
    A - The carrier type
    All Implemented Interfaces:
    Applicative<A,​Compose<F,​G,​?>>, Functor<A,​Compose<F,​G,​?>>

    public final class Compose<F extends Applicative<?,​F>,​G extends Applicative<?,​G>,​A>
    extends java.lang.Object
    implements Applicative<A,​Compose<F,​G,​?>>
    A functor representing the type-level composition of two Applicative functors; useful for preserving nested type-level transformations during traversal of a Traversable.
    • Method Detail

      • fmap

        public <B> Compose<F,​G,​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<F extends Applicative<?,​F>,​G extends Applicative<?,​G>>
        Specified by:
        fmap in interface Functor<F extends Applicative<?,​F>,​G extends Applicative<?,​G>>
        Type Parameters:
        B - the new parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a functor over B (the new parameter type)
      • pure

        public <B> Compose<F,​G,​B> pure​(B b)
        Lift the value b into this applicative functor.
        Specified by:
        pure in interface Applicative<F extends Applicative<?,​F>,​G extends Applicative<?,​G>>
        Type Parameters:
        B - the type of the returned applicative's parameter
        Parameters:
        b - the value
        Returns:
        an instance of this applicative over b
      • zip

        public <B> Compose<F,​G,​B> zip​(Applicative<Fn1<? super A,​? extends B>,​Compose<F,​G,​?>> 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<F extends Applicative<?,​F>,​G extends Applicative<?,​G>>
        Type Parameters:
        B - the resulting applicative parameter type
        Parameters:
        appFn - the other applicative instance
        Returns:
        the mapped applicative
      • lazyZip

        public <B> Lazy<Compose<F,​G,​B>> lazyZip​(Lazy<? extends Applicative<Fn1<? super A,​? extends B>,​Compose<F,​G,​?>>> lazyAppFn)
        Given a lazy instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. This is useful for applicatives that support lazy evaluation and early termination.
        Specified by:
        lazyZip in interface Applicative<F extends Applicative<?,​F>,​G extends Applicative<?,​G>>
        Type Parameters:
        B - the resulting applicative parameter type
        Parameters:
        lazyAppFn - the lazy other applicative instance
        Returns:
        the mapped applicative
        See Also:
        Maybe, Either
      • discardL

        public <B> Compose<F,​G,​B> discardL​(Applicative<B,​Compose<F,​G,​?>> 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<F extends Applicative<?,​F>,​G extends Applicative<?,​G>>
        Type Parameters:
        B - the type of the returned Applicative's parameter
        Parameters:
        appB - the other Applicative
        Returns:
        appB
      • discardR

        public <B> Compose<F,​G,​A> discardR​(Applicative<B,​Compose<F,​G,​?>> 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<F extends Applicative<?,​F>,​G extends Applicative<?,​G>>
        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