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