com.jnape.palatable.lambda.functor.builtin

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

- java.lang.Object
- - com.jnape.palatable.lambda.functor.builtin.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 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.

- - ### Constructor Summary

    Constructors
    Constructor and 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 and 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.monad.MonadRec

      `discardL, discardR, lazyZip`

    - ### Methods inherited from interface com.jnape.palatable.lambda.monad.Monad

      `join`

    - ### Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

      `coerce`

    - ### Methods inherited from interface com.jnape.palatable.lambda.functor.Cocartesian

      `choose`

- - ### 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>`

    - #### sta

          public Fn1<? super S,? extends Either<T,A>> sta()

      Extract the mapping `S -> `Either`<T, A>`.
      Returns:
        a ``Fn1`<S, `Either`<T, A>>`

    - #### 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<T,Market<A,B,S,?>>`
      Specified by:
        `pure` in interface `Monad<T,Market<A,B,S,?>>`
      Specified by:
        `pure` in interface `MonadRec<T,Market<A,B,S,?>>`
      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<T,Market<A,B,S,?>>`
      Specified by:
        `flatMap` in interface `MonadRec<T,Market<A,B,S,?>>`
      Type Parameters:
        `U` - the resulting monad parameter type
      Parameters:
        `f` - the dependent computation over A
      Returns:
        the new monad instance

    - #### trampolineM

          public <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.

      Stack-safety depends on implementations guaranteeing that the growth of the call stack is a constant factor independent of the number of invocations of the operation. For various examples of how this can be achieved in stereotypical circumstances, see the referenced types.

      Specified by:
        `trampolineM` in interface `MonadRec<T,Market<A,B,S,?>>`
      Type Parameters:
        `U` - the ultimate resulting carrier type
      Parameters:
        `fn` - the function to internally trampoline
      Returns:
        the trampolined `MonadRec`
      See Also:
        `for a basic implementation`, `for a {@link CoProduct2 coproduct} implementation`, `for an implementation leveraging an already stack-safe {@link Monad#flatMap(Fn1)}`, `for a {@link MonadT monad transformer} implementation`

    - #### 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<T,Market<A,B,S,?>>`
      Specified by:
        `zip` in interface `Monad<T,Market<A,B,S,?>>`
      Specified by:
        `zip` in interface `MonadRec<T,Market<A,B,S,?>>`
      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<T,Market<A,B,S,?>>`
      Specified by:
        `fmap` in interface `Functor<T,Market<A,B,S,?>>`
      Specified by:
        `fmap` in interface `Monad<T,Market<A,B,S,?>>`
      Specified by:
        `fmap` in interface `MonadRec<T,Market<A,B,S,?>>`
      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<S,T,Market<A,B,?,?>>`
      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<S,T,Market<A,B,?,?>>`
      Specified by:
        `diMap` in interface `Profunctor<S,T,Market<A,B,?,?>>`
      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<S,T,Market<A,B,?,?>>`
      Specified by:
        `diMapL` in interface `Profunctor<S,T,Market<A,B,?,?>>`
      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<S,T,Market<A,B,?,?>>`
      Specified by:
        `diMapR` in interface `Profunctor<S,T,Market<A,B,?,?>>`
      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<S,T,Market<A,B,?,?>>`
      Specified by:
        `contraMap` in interface `Contravariant<S,Profunctor<?,T,Market<A,B,?,?>>>`
      Specified by:
        `contraMap` in interface `Profunctor<S,T,Market<A,B,?,?>>`
      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