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

  • Type Parameters:
    A - the output that might fail to be produced
    B - the input that guarantees its output
    S - the input that might fail to map to its output
    T - the guaranteed output
    All Implemented Interfaces:
    Applicative<T,​Market<A,​B,​S,​?>>, Cocartesian<S,​T,​Market<A,​B,​?,​?>>, Contravariant<S,​Profunctor<?,​T,​Market<A,​B,​?,​?>>>, Functor<T,​Market<A,​B,​S,​?>>, Profunctor<S,​T,​Market<A,​B,​?,​?>>, Monad<T,​Market<A,​B,​S,​?>>, MonadRec<T,​Market<A,​B,​S,​?>>

    public final class Market<A,​B,​S,​T>
    extends java.lang.Object
    implements MonadRec<T,​Market<A,​B,​S,​?>>, Cocartesian<S,​T,​Market<A,​B,​?,​?>>
    A profunctor used to extract the isomorphic functions a Prism is composed of.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Fn1<? super B,​? extends T> bt  
      private Fn1<? super S,​? extends Either<T,​A>> sta  
    • Constructor Summary

      Constructors 
      Constructor Description
      Market​(Fn1<? super B,​? extends T> bt, Fn1<? super S,​? extends Either<T,​A>> sta)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Fn1<? super B,​? extends T> bt()
      Extract the mapping B -> T.
      <C> Market<A,​B,​Choice2<C,​S>,​Choice2<C,​T>> cocartesian()
      Choose some type C or this profunctor's carrier types.
      <R> Market<A,​B,​R,​T> contraMap​(Fn1<? super R,​? extends S> fn)
      Contravariantly map A <- B.
      <R,​U>
      Market<A,​B,​R,​U>
      diMap​(Fn1<? super R,​? extends S> lFn, Fn1<? super T,​? extends U> rFn)
      Dually map contravariantly over the left parameter and covariantly over the right parameter.
      <R> Market<A,​B,​R,​T> diMapL​(Fn1<? super R,​? extends S> fn)
      Contravariantly map over the left parameter.
      <U> Market<A,​B,​S,​U> diMapR​(Fn1<? super T,​? extends U> fn)
      Covariantly map over the right parameter.
      <U> Market<A,​B,​S,​U> flatMap​(Fn1<? super T,​? extends Monad<U,​Market<A,​B,​S,​?>>> f)
      Chain dependent computations that may continue or short-circuit based on previous results.
      <U> Market<A,​B,​S,​U> fmap​(Fn1<? super T,​? extends U> fn)
      Covariantly transmute this functor's parameter using the given mapping function.
      <U> Market<A,​B,​S,​U> pure​(U u)
      Lift the value b into this applicative functor.
      static <A,​B,​S>
      Pure<Market<A,​B,​S,​?>>
      pureMarket()
      The canonical Pure instance for Market.
      Fn1<? super S,​? extends Either<T,​A>> sta()
      Extract the mapping S -> Either<T, A>.
      <U> Market<A,​B,​S,​U> trampolineM​(Fn1<? super T,​? extends MonadRec<RecursiveResult<T,​U>,​Market<A,​B,​S,​?>>> fn)
      Given some operation yielding a RecursiveResult inside this MonadRec, internally trampoline the operation until it yields a termination instruction.
      <U> Market<A,​B,​S,​U> zip​(Applicative<Fn1<? super T,​? extends U>,​Market<A,​B,​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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

        coerce
    • Field Detail

      • bt

        private final Fn1<? super B,​? extends T> bt
      • sta

        private final Fn1<? super S,​? extends Either<T,​A>> sta
    • Constructor Detail

      • Market

        public Market​(Fn1<? super B,​? extends T> bt,
                      Fn1<? super S,​? extends Either<T,​A>> sta)
    • Method Detail

      • bt

        public Fn1<? super B,​? extends T> bt()
        Extract the mapping B -> T.
        Returns:
        a Fn1<B, T>
      • pure

        public <U> Market<A,​B,​S,​U> pure​(U u)
        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:
        U - the type of the returned applicative's parameter
        Parameters:
        u - the value
        Returns:
        an instance of this applicative over b
      • flatMap

        public <U> Market<A,​B,​S,​U> flatMap​(Fn1<? super T,​? extends Monad<U,​Market<A,​B,​S,​?>>> 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:
        U - the resulting monad parameter type
        Parameters:
        f - the dependent computation over A
        Returns:
        the new monad instance
      • zip

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

        public <U> Market<A,​B,​S,​U> fmap​(Fn1<? super T,​? extends U> 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>
        Type Parameters:
        U - the new parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a functor over B (the new parameter type)
      • cocartesian

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

        public <R,​U> Market<A,​B,​R,​U> diMap​(Fn1<? super R,​? extends S> lFn,
                                                                   Fn1<? super T,​? extends U> 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<A,​B,​S>
        Specified by:
        diMap in interface Profunctor<A,​B,​S>
        Type Parameters:
        R - the new left parameter type
        U - 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 <R> Market<A,​B,​R,​T> diMapL​(Fn1<? super R,​? extends S> fn)
        Contravariantly map over the left parameter.
        Specified by:
        diMapL in interface Cocartesian<A,​B,​S>
        Specified by:
        diMapL in interface Profunctor<A,​B,​S>
        Type Parameters:
        R - 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 <U> Market<A,​B,​S,​U> diMapR​(Fn1<? super T,​? extends U> 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<A,​B,​S>
        Specified by:
        diMapR in interface Profunctor<A,​B,​S>
        Type Parameters:
        U - 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 <R> Market<A,​B,​R,​T> contraMap​(Fn1<? super R,​? extends S> fn)
        Contravariantly map A <- B.
        Specified by:
        contraMap in interface Cocartesian<A,​B,​S>
        Specified by:
        contraMap in interface Contravariant<A,​B>
        Specified by:
        contraMap in interface Profunctor<A,​B,​S>
        Type Parameters:
        R - the new parameter type
        Parameters:
        fn - the mapping function
        Returns:
        the mapped Contravariant functor instance
      • pureMarket

        public static <A,​B,​S> Pure<Market<A,​B,​S,​?>> pureMarket()
        The canonical Pure instance for Market.
        Type Parameters:
        A - the output that might fail to be produced
        B - the input that guarantees its output
        S - the input that might fail to map to its output
        Returns:
        the Pure instance