Class Tagged<S,​B>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private B b  
    • Constructor Summary

      Constructors 
      Constructor Description
      Tagged​(B b)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <C> Tagged<Choice2<C,​S>,​Choice2<C,​B>> cocartesian()
      Choose some type C or this profunctor's carrier types.
      <Z> Tagged<Z,​B> contraMap​(Fn1<? super Z,​? extends S> fn)
      Contravariantly map A <- B.
      <Z,​C>
      Tagged<Z,​C>
      diMap​(Fn1<? super Z,​? extends S> lFn, Fn1<? super B,​? extends C> rFn)
      Dually map contravariantly over the left parameter and covariantly over the right parameter.
      <Z> Tagged<Z,​B> diMapL​(Fn1<? super Z,​? extends S> fn)
      Contravariantly map over the left parameter.
      <C> Tagged<S,​C> diMapR​(Fn1<? super B,​? extends C> fn)
      Covariantly map over the right parameter.
      <C> Tagged<S,​C> discardL​(Applicative<C,​Tagged<S,​?>> appB)
      Sequence both this Applicative and appB, discarding this Applicative's result and returning appB.
      <C> Tagged<S,​B> discardR​(Applicative<C,​Tagged<S,​?>> appB)
      Sequence both this Applicative and appB, discarding appB's result and returning this Applicative.
      boolean equals​(java.lang.Object other)  
      <C> Tagged<S,​C> flatMap​(Fn1<? super B,​? extends Monad<C,​Tagged<S,​?>>> f)
      Chain dependent computations that may continue or short-circuit based on previous results.
      <C> Tagged<S,​C> fmap​(Fn1<? super B,​? extends C> fn)
      Covariantly transmute this functor's parameter using the given mapping function.
      int hashCode()  
      <C> Tagged<S,​C> pure​(C c)
      Lift the value b into this applicative functor.
      static <S> Pure<Tagged<S,​?>> pureTagged()
      The canonical Pure instance for Tagged.
      java.lang.String toString()  
      <C> Tagged<S,​C> trampolineM​(Fn1<? super B,​? extends MonadRec<RecursiveResult<B,​C>,​Tagged<S,​?>>> fn)
      Given some operation yielding a RecursiveResult inside this MonadRec, internally trampoline the operation until it yields a termination instruction.
      <C,​App extends Applicative<?,​App>,​TravC extends Traversable<C,​Tagged<S,​?>>,​AppTrav extends Applicative<TravC,​App>>
      AppTrav
      traverse​(Fn1<? super B,​? extends Applicative<C,​App>> fn, Fn1<? super TravC,​? 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.
      B unTagged()
      Extract the contained value.
      <C> Tagged<S,​C> zip​(Applicative<Fn1<? super B,​? extends C>,​Tagged<S,​?>> 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
    • Field Detail

      • b

        private final B b
    • Constructor Detail

      • Tagged

        public Tagged​(B b)
    • Method Detail

      • unTagged

        public B unTagged()
        Extract the contained value.
        Returns:
        the value
      • flatMap

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

        public <C> Tagged<S,​C> pure​(C c)
        Lift the value b into this applicative functor.
        Specified by:
        pure in interface Applicative<S,​B>
        Specified by:
        pure in interface Monad<S,​B>
        Specified by:
        pure in interface MonadRec<S,​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> Tagged<S,​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<S,​B>
        Specified by:
        fmap in interface Functor<S,​B>
        Specified by:
        fmap in interface Monad<S,​B>
        Specified by:
        fmap in interface MonadRec<S,​B>
        Specified by:
        fmap in interface Traversable<S,​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> Tagged<S,​C> zip​(Applicative<Fn1<? super B,​? extends C>,​Tagged<S,​?>> 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<S,​B>
        Specified by:
        zip in interface Monad<S,​B>
        Specified by:
        zip in interface MonadRec<S,​B>
        Type Parameters:
        C - the resulting applicative parameter type
        Parameters:
        appFn - the other applicative instance
        Returns:
        the mapped applicative
      • discardL

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

        public <C> Tagged<S,​B> discardR​(Applicative<C,​Tagged<S,​?>> 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<S,​B>
        Specified by:
        discardR in interface Monad<S,​B>
        Specified by:
        discardR in interface MonadRec<S,​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>,​TravC extends Traversable<C,​Tagged<S,​?>>,​AppTrav extends Applicative<TravC,​App>> AppTrav traverse​(Fn1<? super B,​? extends Applicative<C,​App>> fn,
                                                                                                                                                                                             Fn1<? super TravC,​? 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<S,​B>
        Type Parameters:
        C - the resulting element type
        App - the result applicative type
        TravC - 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
      • cocartesian

        public <C> Tagged<Choice2<C,​S>,​Choice2<C,​B>> cocartesian()
        Choose some type C or this profunctor's carrier types.
        Specified by:
        cocartesian in interface Cocartesian<S,​B,​Tagged<?,​?>>
        Type Parameters:
        C - the choice type
        Returns:
        the cocartesian-costrengthened profunctor
      • diMap

        public <Z,​C> Tagged<Z,​C> diMap​(Fn1<? super Z,​? extends S> lFn,
                                                   Fn1<? super B,​? extends C> rFn)
        Dually map contravariantly over the left parameter and covariantly over the right parameter. This is isomorphic to diMapL(lFn).diMapR(rFn).
        Specified by:
        diMap in interface Cocartesian<S,​B,​Tagged<?,​?>>
        Specified by:
        diMap in interface Profunctor<S,​B,​Tagged<?,​?>>
        Type Parameters:
        Z - the new left parameter type
        C - the new right parameter type
        Parameters:
        lFn - the left parameter mapping function
        rFn - the right parameter mapping function
        Returns:
        a profunctor over Z (the new left parameter type) and C (the new right parameter type)
      • diMapL

        public <Z> Tagged<Z,​B> diMapL​(Fn1<? super Z,​? extends S> fn)
        Contravariantly map over the left parameter.
        Specified by:
        diMapL in interface Cocartesian<S,​B,​Tagged<?,​?>>
        Specified by:
        diMapL in interface Profunctor<S,​B,​Tagged<?,​?>>
        Type Parameters:
        Z - the new left parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a profunctor over Z (the new left parameter type) and C (the same right parameter type)
      • diMapR

        public <C> Tagged<S,​C> diMapR​(Fn1<? super B,​? extends C> fn)
        Covariantly map over the right parameter. For all profunctors that are also functors, it should hold that diMapR(f) == fmap(f).
        Specified by:
        diMapR in interface Cocartesian<S,​B,​Tagged<?,​?>>
        Specified by:
        diMapR in interface Profunctor<S,​B,​Tagged<?,​?>>
        Type Parameters:
        C - the new right parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a profunctor over A (the same left parameter type) and C (the new right parameter type)
      • contraMap

        public <Z> Tagged<Z,​B> contraMap​(Fn1<? super Z,​? extends S> fn)
        Contravariantly map A <- B.
        Specified by:
        contraMap in interface Cocartesian<S,​B,​Tagged<?,​?>>
        Specified by:
        contraMap in interface Contravariant<S,​B>
        Specified by:
        contraMap in interface Profunctor<S,​B,​Tagged<?,​?>>
        Type Parameters:
        Z - the new parameter type
        Parameters:
        fn - the mapping function
        Returns:
        the mapped Contravariant functor instance
      • 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
      • pureTagged

        public static <S> Pure<Tagged<S,​?>> pureTagged()
        The canonical Pure instance for Tagged.
        Type Parameters:
        S - the phantom type
        Returns:
        the Pure instance