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 producedB
- the input that guarantees its outputS
- the input that might fail to map to its outputT
- 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 aPrism
is composed of.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Fn1<? super B,? extends T>
bt()
Extract the mappingB -> T
.<C> Market<A,B,Choice2<C,S>,Choice2<C,T>>
cocartesian()
Choose some typeC
or this profunctor's carrier types.<R> Market<A,B,R,T>
contraMap(Fn1<? super R,? extends S> fn)
Contravariantly mapA <- 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 valueb
into this applicative functor.static <A,B,S>
Pure<Market<A,B,S,?>>pureMarket()
Fn1<? super S,? extends Either<T,A>>
sta()
Extract the mappingS ->
.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 aRecursiveResult
inside thisMonadRec
, internally trampoline the operation until it yields atermination
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.Cocartesian
choose
-
-
-
-
Method Detail
-
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.
-
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 aRecursiveResult
inside thisMonadRec
, internally trampoline the operation until it yields atermination
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 interfaceMonadRec<A,B>
- 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 implementation
,for an implementation leveraging an already stack-safe
,for a 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.
-
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 interfaceApplicative<A,B>
- Specified by:
fmap
in interfaceFunctor<A,B>
- Specified by:
fmap
in interfaceMonad<A,B>
- Specified by:
fmap
in interfaceMonadRec<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 typeC
or this profunctor's carrier types.- Specified by:
cocartesian
in interfaceCocartesian<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 todiMapL(lFn).diMapR(rFn)
.- Specified by:
diMap
in interfaceCocartesian<A,B,S>
- Specified by:
diMap
in interfaceProfunctor<A,B,S>
- Type Parameters:
R
- the new left parameter typeU
- the new right parameter type- Parameters:
lFn
- the left parameter mapping functionrFn
- 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 interfaceCocartesian<A,B,S>
- Specified by:
diMapL
in interfaceProfunctor<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 thatdiMapR(f) == fmap(f)
.- Specified by:
diMapR
in interfaceCocartesian<A,B,S>
- Specified by:
diMapR
in interfaceProfunctor<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 mapA <- B
.- Specified by:
contraMap
in interfaceCocartesian<A,B,S>
- Specified by:
contraMap
in interfaceContravariant<A,B>
- Specified by:
contraMap
in interfaceProfunctor<A,B,S>
- Type Parameters:
R
- the new parameter type- Parameters:
fn
- the mapping function- Returns:
- the mapped Contravariant functor instance
-
-