Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module with a ReaderT
style monad specialized to holding a record.
- newtype ContextT c m a = ContextT {
- runContextT :: Record c -> 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
.
ContextT | |
|
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.
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.
Monad m => MonadContext c (ContextT c m) Source # | |
asksContext :: MonadContext c m => (Record c -> a) -> m a Source #
Project some value out of the context using a function.