Safe Haskell | None |
---|
This module exports:
- The
MonadReader
type class and its operationsreader
,ask
andlocal
. - An instance of
MonadReader
for the->
type. - Instances of
MonadReader
for the relevant monad transformers from thetransformers
package (ReaderT', lazyRWST
and strictRWST
). - A universal pass-through instance of
MonadReader
for any existingMonadReader
wrapped by aMonadLayer
. - The utility operations
asks
.
- class Monad m => MonadReader r m | m -> r where
- asks :: MonadReader r m => (r -> a) -> m a
Documentation
class Monad m => MonadReader r m | m -> r whereSource
The 'MonadReader interface monad represents computations which can read
values from a shared environment, pass values from function to function
and execute sub-computations in a modified environment. Using the
MonadReader
interface for such computations is often clearer and easier
than using the MonadState
interface.
Minimal complete definition: local
and one of either reader
or ask
.
reader :: (r -> a) -> m aSource
Embed a simple reader action into the monad.
Retrieves the monad environment.
local :: (r -> r) -> m a -> m aSource
Executes a computation in a modified environment.
(MonadLayer m, MonadReader r (Inner m)) => MonadReader r m | |
MonadReader r ((->) r) | |
(MonadReader r f, MonadReader r g) => MonadReader r (Product f g) | |
Monad m => MonadReader r (ReaderT r m) | |
(Monad m, Monoid w) => MonadReader r (RWST r w s m) | |
(Monad m, Monoid w) => MonadReader r (RWST r w s m) |
asks :: MonadReader r m => (r -> a) -> m aSource
Retrieves a function of the current environment.