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 returnedMonadRec
A
- 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 betweenReaderT
instances running under the same effect and compatible between their inputs and outputs.Given aPure
ask 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 typeC
to 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 thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
.discardR
(Applicative<B, ReaderT<R, M, ?>> appB) Sequence both thisApplicative
andappB
, discardingappB's
result 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 alazy
instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.Modify thisMonadReader's
environment after reading it but before running the effect.mapReaderT
(Fn1<? super MA, ? extends MonadRec<B, N>> fn) pure
(B b) Lift the valueb
into 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 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.
-
Field Details
-
f
-
-
Constructor Details
-
ReaderT
-
-
Method Details
-
runReaderT
Run the computation represented by thisReaderT
.- Type Parameters:
MA
- the witnessed target type- Parameters:
r
- the input- Returns:
- the embedded
MonadRec
-
mapReaderT
-
and
Left-to-right composition betweenReaderT
instances running under the same effect and compatible between their inputs and outputs. -
local
Modify thisMonadReader's
environment after reading it but before running the effect.- Specified by:
local
in interfaceMonadReader<R,
M extends MonadRec<?, M>, A> - Parameters:
fn
- the modification function- Returns:
- the
MonadReader
with a modified environment
-
lift
- Specified by:
lift
in interfaceMonadBase<R,
M extends MonadRec<?, M>, A> - Specified by:
lift
in interfaceMonadT<M extends MonadRec<?,
M>, A, ReaderT<R, M extends MonadRec<?, M>, ?>, ReaderT<R, ?, ?>> - Type Parameters:
B
- theMonadRec
carrier typeN
- the argumentMonadRec
witness- Parameters:
mb
- the argumentMonadRec
- Returns:
- the new
MonadBase
-
flatMap
Chain dependent computations that may continue or short-circuit based on previous results.- Specified by:
flatMap
in interfaceMonad<R,
M extends MonadRec<?, M>> - Specified by:
flatMap
in interfaceMonadReader<R,
M extends MonadRec<?, M>, A> - Specified by:
flatMap
in interfaceMonadRec<R,
M extends MonadRec<?, M>> - Specified by:
flatMap
in 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 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.
-
pure
Lift the valueb
into this applicative functor.- Specified by:
pure
in interfaceApplicative<R,
M extends MonadRec<?, M>> - Specified by:
pure
in interfaceMonad<R,
M extends MonadRec<?, M>> - Specified by:
pure
in interfaceMonadReader<R,
M extends MonadRec<?, M>, A> - Specified by:
pure
in interfaceMonadRec<R,
M extends MonadRec<?, M>> - Specified by:
pure
in 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:
fmap
in interfaceApplicative<R,
M extends MonadRec<?, M>> - Specified by:
fmap
in interfaceFunctor<R,
M extends MonadRec<?, M>> - Specified by:
fmap
in interfaceMonad<R,
M extends MonadRec<?, M>> - Specified by:
fmap
in interfaceMonadReader<R,
M extends MonadRec<?, M>, A> - Specified by:
fmap
in interfaceMonadRec<R,
M extends MonadRec<?, M>> - Specified by:
fmap
in 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:
zip
in interfaceApplicative<R,
M extends MonadRec<?, M>> - Specified by:
zip
in interfaceMonad<R,
M extends MonadRec<?, M>> - Specified by:
zip
in interfaceMonadReader<R,
M extends MonadRec<?, M>, A> - Specified by:
zip
in interfaceMonadRec<R,
M extends MonadRec<?, M>> - Specified by:
zip
in 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 alazy
instance 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:
lazyZip
in interfaceApplicative<R,
M extends MonadRec<?, M>> - Specified by:
lazyZip
in interfaceMonad<R,
M extends MonadRec<?, M>> - Specified by:
lazyZip
in interfaceMonadReader<R,
M extends MonadRec<?, M>, A> - Specified by:
lazyZip
in interfaceMonadRec<R,
M extends MonadRec<?, M>> - Specified by:
lazyZip
in 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 thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
. This is generally useful for sequentially performing side-effects.- Specified by:
discardL
in interfaceApplicative<R,
M extends MonadRec<?, M>> - Specified by:
discardL
in interfaceMonad<R,
M extends MonadRec<?, M>> - Specified by:
discardL
in interfaceMonadReader<R,
M extends MonadRec<?, M>, A> - Specified by:
discardL
in interfaceMonadRec<R,
M extends MonadRec<?, M>> - Specified by:
discardL
in 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 thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
. This is generally useful for sequentially performing side-effects.- Specified by:
discardR
in interfaceApplicative<R,
M extends MonadRec<?, M>> - Specified by:
discardR
in interfaceMonad<R,
M extends MonadRec<?, M>> - Specified by:
discardR
in interfaceMonadReader<R,
M extends MonadRec<?, M>, A> - Specified by:
discardR
in interfaceMonadRec<R,
M extends MonadRec<?, M>> - Specified by:
discardR
in 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:
diMap
in interfaceCartesian<R,
M extends MonadRec<?, M>, A> - Specified by:
diMap
in 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:
diMapL
in interfaceCartesian<R,
M extends MonadRec<?, M>, A> - Specified by:
diMapL
in 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:
diMapR
in interfaceCartesian<R,
M extends MonadRec<?, M>, A> - Specified by:
diMapR
in 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:
contraMap
in interfaceCartesian<R,
M extends MonadRec<?, M>, A> - Specified by:
contraMap
in interfaceContravariant<R,
M extends MonadRec<?, M>> - Specified by:
contraMap
in 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
Pair some typeC
to this profunctor's carrier types. -
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 aPure
ask will give you access to the input within the monadic embedding -
readerT
-
pureReaderT
-
liftReaderT
-