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 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbt()
Extract the mappingB -> T
.Choose some typeC
or this profunctor's carrier types.Contravariantly mapA <- B
.Dually map contravariantly over the left parameter and covariantly over the right parameter.Contravariantly map over the left parameter.Covariantly map over the right parameter.Chain dependent computations that may continue or short-circuit based on previous results.Covariantly transmute this functor's parameter using the given mapping function.pure
(U u) Lift the valueb
into this applicative functor.sta()
Extract the mappingS ->
.Either
<T, A>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.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
-
Field Details
-
bt
-
sta
-
-
Constructor Details
-
Market
-
-
Method Details
-
bt
Extract the mappingB -> T
.- Returns:
- a
Fn1
<B, T>
-
sta
Extract the mappingS ->
.Either
<T, A> -
pure
Lift the valueb
into this applicative functor. -
flatMap
Chain dependent computations that may continue or short-circuit based on previous results. -
trampolineM
public <U> Market<A,B, trampolineMS, U> (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:
-
zip
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. -
fmap
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
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
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
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
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
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
-
pureMarket
- 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 output- Returns:
- the
Pure
instance
-