| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Monad.Composite.Context
Description
Module with a ReaderT style monad specialized to holding a record.
- newtype ContextT c m a = ContextT {
- runContextT :: Record c -> m a
- runInContext :: Record c -> ContextT c m a -> m a
- withContext :: (Record c' -> Record c) -> ContextT c m a -> ContextT c' m a
- mapContextT :: (m a -> n b) -> ContextT c m a -> ContextT c n b
- class Monad m => MonadContext c m | m -> c where
- asksContext :: MonadContext c m => (Record c -> a) -> m a
- askField :: MonadContext c m => Getter (Record c) a -> m a
Documentation
newtype ContextT c m a Source #
Monad transformer which adds an implicit environment which is a record. Isomorphic to ReaderT (Record c) m.
Constructors
| ContextT | |
Fields
| |
Instances
runInContext :: Record c -> ContextT c m a -> m a Source #
Run some action in a given context, equivalent to runContextT but with the arguments flipped.
withContext :: (Record c' -> Record c) -> ContextT c m a -> ContextT c' m a Source #
Permute the current context with a function and then run some action with that modified context.
mapContextT :: (m a -> n b) -> ContextT c m a -> ContextT c n b Source #
Transform the monad underlying a ContextT using a natural transform.
class Monad m => MonadContext c m | m -> c where Source #
Class of monad (stacks) which have context reading functionality baked in. Similar to MonadReader but can coexist with a
another monad that provides MonadReader and requires the context to be a record.
Minimal complete definition
Methods
askContext :: m (Record c) Source #
Fetch the context record from the environment.
localContext :: (Record c -> Record c) -> m a -> m a Source #
Run some action which has the same type of context with the context modified.
Instances
| MonadContext c m => MonadContext c (MaybeT m) Source # | |
| MonadContext c ((->) (Record c)) Source # | |
| Monad m => MonadContext c (ContextT c m) Source # | |
| MonadContext c m => MonadContext c (ExceptT e m) Source # | |
| MonadContext c m => MonadContext c (IdentityT * m) Source # | |
| MonadContext c m => MonadContext c (StateT s m) Source # | |
| MonadContext c m => MonadContext c (StateT s m) Source # | |
| (MonadContext c m, Monoid w) => MonadContext c (WriterT w m) Source # | |
| (MonadContext c m, Monoid w) => MonadContext c (WriterT w m) Source # | |
| MonadContext c m => MonadContext c (ContT * r m) Source # | |
| MonadContext c m => MonadContext c (ReaderT * r m) Source # | |
| (MonadContext c m, Monoid w) => MonadContext c (RWST r w s m) Source # | |
| (MonadContext c m, Monoid w) => MonadContext c (RWST r w s m) Source # | |
asksContext :: MonadContext c m => (Record c -> a) -> m a Source #
Project some value out of the context using a function.