Class ReaderT<R, M extends MonadRec<?,M>, A>
java.lang.Object
com.jnape.palatable.lambda.monad.transformer.builtin.ReaderT<R,M,A>
- Type Parameters:
R- the input typeM- the returnedMonadRecA- the embedded output type
- All Implemented Interfaces:
Applicative<A, ReaderT<R,M, ?>>, Cartesian<R, A, ReaderT<?, M, ?>>, Contravariant<R, Profunctor<?, A, ReaderT<?, M, ?>>>, Functor<A, ReaderT<R, M, ?>>, Profunctor<R, A, ReaderT<?, M, ?>>, Monad<A, ReaderT<R, M, ?>>, MonadBase<M, A, ReaderT<R, ?, ?>>, MonadReader<R, A, ReaderT<R, M, ?>>, MonadRec<A, ReaderT<R, M, ?>>, MonadT<M, A, ReaderT<R, M, ?>, ReaderT<R, ?, ?>>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionLeft-to-right composition betweenReaderTinstances running under the same effect and compatible between their inputs and outputs.Given aPureask will give you access to the input within the monadic embeddingcarry()Pair the covariantly-positioned carrier type with the contravariantly-positioned carrier type.Pair some typeCto 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.discardL(Applicative<B, ReaderT<R, M, ?>> appB) Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB.discardR(Applicative<B, ReaderT<R, M, ?>> appB) Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative.Chain dependent computations that may continue or short-circuit based on previous results.Covariantly transmute this functor's parameter using the given mapping function.Given alazyinstance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.Modify thisMonadReader'senvironment after reading it but before running the effect.mapReaderT(Fn1<? super MA, ? extends MonadRec<B, N>> fn) pure(B b) Lift the valuebinto this applicative functor.pureReaderT(Pure<M> pureM) runReaderT(R r) Run the computation represented by thisReaderT.trampolineM(Fn1<? super A, ? extends MonadRec<RecursiveResult<A, B>, ReaderT<R, M, ?>>> fn) Given some operation yielding aRecursiveResultinside thisMonadRec, internally trampoline the operation until it yields aterminationinstruction.Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
-
Field Details
-
f
-
-
Constructor Details
-
ReaderT
-
-
Method Details
-
runReaderT
-
mapReaderT
-
and
-
local
Modify thisMonadReader'senvironment after reading it but before running the effect.- Specified by:
localin interfaceMonadReader<R, M extends MonadRec<?,M>, A> - Parameters:
fn- the modification function- Returns:
- the
MonadReaderwith a modified environment
-
lift
- Specified by:
liftin interfaceMonadBase<R, M extends MonadRec<?,M>, A> - Specified by:
liftin interfaceMonadT<M extends MonadRec<?,M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B- theMonadReccarrier typeN- the argumentMonadRecwitness- Parameters:
mb- the argumentMonadRec- Returns:
- the new
MonadBase
-
flatMap
Chain dependent computations that may continue or short-circuit based on previous results.- Specified by:
flatMapin interfaceMonad<R, M extends MonadRec<?,M>> - Specified by:
flatMapin interfaceMonadReader<R, M extends MonadRec<?,M>, A> - Specified by:
flatMapin interfaceMonadRec<R, M extends MonadRec<?,M>> - Specified by:
flatMapin interfaceMonadT<M extends MonadRec<?,M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B- the resulting monad parameter type- Parameters:
f- the dependent computation over A- Returns:
- the new monad instance
-
trampolineM
public <B> ReaderT<R,M, trampolineMB> (Fn1<? super A, ? extends MonadRec<RecursiveResult<A, B>, ReaderT<R, M, ?>>> fn) Given some operation yielding aRecursiveResultinside thisMonadRec, internally trampoline the operation until it yields aterminationinstruction.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.
-
pure
Lift the valuebinto this applicative functor.- Specified by:
purein interfaceApplicative<R, M extends MonadRec<?,M>> - Specified by:
purein interfaceMonad<R, M extends MonadRec<?,M>> - Specified by:
purein interfaceMonadReader<R, M extends MonadRec<?,M>, A> - Specified by:
purein interfaceMonadRec<R, M extends MonadRec<?,M>> - Specified by:
purein interfaceMonadT<M extends MonadRec<?,M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B- the type of the returned applicative's parameter- Parameters:
b- the value- Returns:
- an instance of this applicative over b
-
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:
fmapin interfaceApplicative<R, M extends MonadRec<?,M>> - Specified by:
fmapin interfaceFunctor<R, M extends MonadRec<?,M>> - Specified by:
fmapin interfaceMonad<R, M extends MonadRec<?,M>> - Specified by:
fmapin interfaceMonadReader<R, M extends MonadRec<?,M>, A> - Specified by:
fmapin interfaceMonadRec<R, M extends MonadRec<?,M>> - Specified by:
fmapin interfaceMonadT<M extends MonadRec<?,M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B- the new parameter type- Parameters:
fn- the mapping function- Returns:
- a functor over B (the new parameter type)
-
zip
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:
zipin interfaceApplicative<R, M extends MonadRec<?,M>> - Specified by:
zipin interfaceMonad<R, M extends MonadRec<?,M>> - Specified by:
zipin interfaceMonadReader<R, M extends MonadRec<?,M>, A> - Specified by:
zipin interfaceMonadRec<R, M extends MonadRec<?,M>> - Specified by:
zipin interfaceMonadT<M extends MonadRec<?,M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B- the resulting applicative parameter type- Parameters:
appFn- the other applicative instance- Returns:
- the mapped applicative
-
lazyZip
public <B> Lazy<ReaderT<R,M, lazyZipB>> (Lazy<? extends Applicative<Fn1<? super A, ? extends B>, ReaderT<R, M, ?>>> lazyAppFn) Given alazyinstance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. This is useful for applicatives that support lazy evaluation and early termination.- Specified by:
lazyZipin interfaceApplicative<R, M extends MonadRec<?,M>> - Specified by:
lazyZipin interfaceMonad<R, M extends MonadRec<?,M>> - Specified by:
lazyZipin interfaceMonadReader<R, M extends MonadRec<?,M>, A> - Specified by:
lazyZipin interfaceMonadRec<R, M extends MonadRec<?,M>> - Specified by:
lazyZipin interfaceMonadT<M extends MonadRec<?,M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B- the resulting applicative parameter type- Parameters:
lazyAppFn- the lazy other applicative instance- Returns:
- the mapped applicative
- See Also:
-
discardL
Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB. This is generally useful for sequentially performing side-effects.- Specified by:
discardLin interfaceApplicative<R, M extends MonadRec<?,M>> - Specified by:
discardLin interfaceMonad<R, M extends MonadRec<?,M>> - Specified by:
discardLin interfaceMonadReader<R, M extends MonadRec<?,M>, A> - Specified by:
discardLin interfaceMonadRec<R, M extends MonadRec<?,M>> - Specified by:
discardLin interfaceMonadT<M extends MonadRec<?,M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B- the type of the returned Applicative's parameter- Parameters:
appB- the other Applicative- Returns:
- appB
-
discardR
Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative. This is generally useful for sequentially performing side-effects.- Specified by:
discardRin interfaceApplicative<R, M extends MonadRec<?,M>> - Specified by:
discardRin interfaceMonad<R, M extends MonadRec<?,M>> - Specified by:
discardRin interfaceMonadReader<R, M extends MonadRec<?,M>, A> - Specified by:
discardRin interfaceMonadRec<R, M extends MonadRec<?,M>> - Specified by:
discardRin interfaceMonadT<M extends MonadRec<?,M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B- the type of appB's parameter- Parameters:
appB- the other Applicative- Returns:
- this Applicative
-
diMap
Dually map contravariantly over the left parameter and covariantly over the right parameter. This is isomorphic todiMapL(lFn).diMapR(rFn).- Specified by:
diMapin interfaceCartesian<R, M extends MonadRec<?,M>, A> - Specified by:
diMapin interfaceProfunctor<R, M extends MonadRec<?,M>, A> - Type Parameters:
Q- the new left parameter typeB- 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:
diMapLin interfaceCartesian<R, M extends MonadRec<?,M>, A> - Specified by:
diMapLin interfaceProfunctor<R, M extends MonadRec<?,M>, A> - Type Parameters:
Q- 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:
diMapRin interfaceCartesian<R, M extends MonadRec<?,M>, A> - Specified by:
diMapRin interfaceProfunctor<R, M extends MonadRec<?,M>, A> - Type Parameters:
B- 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:
contraMapin interfaceCartesian<R, M extends MonadRec<?,M>, A> - Specified by:
contraMapin interfaceContravariant<R, M extends MonadRec<?,M>> - Specified by:
contraMapin interfaceProfunctor<R, M extends MonadRec<?,M>, A> - Type Parameters:
Q- the new parameter type- Parameters:
fn- the mapping function- Returns:
- the mapped Contravariant functor instance
-
cartesian
-
carry
Pair the covariantly-positioned carrier type with the contravariantly-positioned carrier type. This can be thought of as "carrying" or "inspecting" the left parameter. -
ask
Given aPureask will give you access to the input within the monadic embedding -
readerT
-
pureReaderT
-
liftReaderT
-