| Safe Haskell | None |
|---|
Control.Monad.Interface.Reader
Description
This module exports:
- The
MonadReadertype class and its operationsreader,askandlocal. - An instance of
MonadReaderfor the->type. - Instances of
MonadReaderfor the relevant monad transformers from thetransformerspackage (ReaderT', lazyRWSTand strictRWST). - A universal pass-through instance of
MonadReaderfor any existingMonadReaderwrapped 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.
Methods
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.
Instances
| (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.