Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype ReaderT r (m :: k -> Type) (a :: k) :: forall k. Type -> (k -> Type) -> k -> Type = 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 :: (r' -> r) -> ReaderT r m a -> ReaderT r' m a
- asks :: Monad m => (r -> a) -> ReaderT r m a
- local :: (r -> r) -> ReaderT r m a -> ReaderT r m a
- ask :: Monad m => ReaderT r m r
- reader :: 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 :: k -> Type) (a :: k) :: forall k. Type -> (k -> Type) -> k -> Type #
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
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
:: (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
:: (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 :: 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
.