Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype ReaderT r (m :: Type -> Type) a = ReaderT {
- runReaderT :: r -> m a
- type Reader r = ReaderT r Identity
- runReader :: Reader r a -> r -> a
- mapReader :: (a -> b) -> Reader r a -> Reader r b
- withReader :: (r' -> r) -> Reader r a -> Reader r' a
- mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b
- withReaderT :: forall r' r (m :: Type -> Type) a. (r' -> r) -> ReaderT r m a -> ReaderT r' m a
- asks :: forall (m :: Type -> Type) r a. Monad m => (r -> a) -> ReaderT r m a
- local :: forall r (m :: Type -> Type) a. (r -> r) -> ReaderT r m a -> ReaderT r m a
- ask :: forall (m :: Type -> Type) r. Monad m => ReaderT r m r
- reader :: forall (m :: Type -> Type) r a. Monad m => (r -> a) -> ReaderT r m a
- readerS :: Monad m => MSF m (r, a) b -> MSF (ReaderT r m) a b
- runReaderS :: Monad m => MSF (ReaderT r m) a b -> MSF m (r, a) b
- runReaderS_ :: Monad m => MSF (ReaderT s m) a b -> s -> MSF m a b
Documentation
newtype ReaderT r (m :: Type -> Type) a #
The reader monad transformer, which adds a read-only environment to the given monad.
The return
function ignores the environment, while >>=
passes
the inherited environment to both subcomputations.
ReaderT | |
|
Instances
MonadSplit g m => MonadSplit g (ReaderT r m) | |
Defined in Control.Monad.Random.Class | |
MonadBase b m => MonadBase b (ReaderT r m) | |
Defined in Control.Monad.Base | |
MonadTrans (ReaderT r) | |
Defined in Control.Monad.Trans.Reader | |
Monad m => Monad (ReaderT r m) | |
Functor m => Functor (ReaderT r m) | |
MonadFix m => MonadFix (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader | |
MonadFail m => MonadFail (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader | |
Applicative m => Applicative (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader | |
MonadPlus m => MonadPlus (ReaderT r m) | |
MonadIO m => MonadIO (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader | |
MonadRandom m => MonadRandom (ReaderT r m) | |
Defined in Control.Monad.Random.Class | |
MonadInterleave m => MonadInterleave (ReaderT r m) | |
Defined in Control.Monad.Random.Class interleave :: ReaderT r m a -> ReaderT r m a # | |
Contravariant m => Contravariant (ReaderT r m) | |
MonadZip m => MonadZip (ReaderT r m) | |
Alternative m => Alternative (ReaderT r m) | |
type Reader r = ReaderT r Identity #
The parameterizable reader monad.
Computations are functions of a shared environment.
The return
function ignores the environment, while >>=
passes
the inherited environment to both subcomputations.
:: Reader r a | A |
-> r | An initial environment. |
-> a |
Runs a Reader
and extracts the final value from it.
(The inverse of reader
.)
:: (r' -> r) | The function to modify the environment. |
-> Reader r a | Computation to run in the modified environment. |
-> Reader r' a |
Execute a computation in a modified environment
(a specialization of withReaderT
).
runReader
(withReader
f m) =runReader
m . f
mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b #
Transform the computation inside a ReaderT
.
runReaderT
(mapReaderT
f m) = f .runReaderT
m
:: forall r' r (m :: Type -> Type) a. (r' -> r) | The function to modify the environment. |
-> ReaderT r m a | Computation to run in the modified environment. |
-> ReaderT r' m a |
Execute a computation in a modified environment
(a more general version of local
).
runReaderT
(withReaderT
f m) =runReaderT
m . f
:: forall r (m :: Type -> Type) a. (r -> r) | The function to modify the environment. |
-> ReaderT r m a | Computation to run in the modified environment. |
-> ReaderT r m a |
Execute a computation in a modified environment
(a specialization of withReaderT
).
runReaderT
(local
f m) =runReaderT
m . f
reader :: forall (m :: Type -> Type) r a. Monad m => (r -> a) -> ReaderT r m a #
Constructor for computations in the reader monad (equivalent to asks
).
Reader
MSF
running and wrapping.
readerS :: Monad m => MSF m (r, a) b -> MSF (ReaderT r m) a b Source #
Build an MSF
in the Reader
monad from one that takes the reader
environment as an extra input. This is the opposite of runReaderS
.