Maintainer | Nickolay Kudasov <nickolay@getshoptv.com> |
---|---|
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
Declare monad transformer and associated functions.
- newtype DeclareT d m a = DeclareT {
- runDeclareT :: d -> m (d, a)
- class (Applicative m, Monad m) => MonadDeclare d m | m -> d where
- looks :: MonadDeclare d m => (d -> a) -> m a
- evalDeclareT :: Monad m => DeclareT d m a -> d -> m a
- execDeclareT :: Monad m => DeclareT d m a -> d -> m d
- undeclareT :: (Monad m, Monoid d) => DeclareT d m a -> m a
- type Declare d = DeclareT d Identity
- runDeclare :: Declare d a -> d -> (d, a)
- evalDeclare :: Declare d a -> d -> a
- execDeclare :: Declare d a -> d -> d
- undeclare :: Monoid d => Declare d a -> a
Documentation
newtype DeclareT d m a Source #
A declare monad transformer parametrized by:
d
— the output to accumulate (declarations);m
— the inner monad.
This monad transformer is similar to both state and writer monad transformers. Thus it can be seen as
- a restricted append-only version of a state monad transformer or
- a writer monad transformer with the extra ability to read all previous output.
DeclareT | |
|
(Applicative m, Monad m, Monoid d) => MonadDeclare d (DeclareT d m) Source # | |
Monoid d => MonadTrans (DeclareT d) Source # | |
(Applicative m, Monad m, Monoid d) => Monad (DeclareT d m) Source # | |
Functor m => Functor (DeclareT d m) Source # | |
(Applicative m, Monad m, Monoid d) => Applicative (DeclareT d m) Source # | |
class (Applicative m, Monad m) => MonadDeclare d m | m -> d where Source #
Definitions of declare
and look
must satisfy the following laws:
is an action that produces the output declare
xx
.
is an action that returns all the output so far.look
(Applicative m, Monad m, Monoid d) => MonadDeclare d (DeclareT d m) Source # | |
looks :: MonadDeclare d m => (d -> a) -> m a Source #
Retrieve a function of all the output so far.
evalDeclareT :: Monad m => DeclareT d m a -> d -> m a Source #
Evaluate
computation,
ignoring new output DeclareT
d m ad
.
execDeclareT :: Monad m => DeclareT d m a -> d -> m d Source #
Execute
computation,
ignoring result and only producing new output DeclateT
d m ad
.
undeclareT :: (Monad m, Monoid d) => DeclareT d m a -> m a Source #
Evaluate
computation,
starting with empty output history.DeclareT
d m a
type Declare d = DeclareT d Identity Source #
A declare monad parametrized by d
— the output to accumulate (declarations).
This monad is similar to both state and writer monads. Thus it can be seen as
- a restricted append-only version of a state monad or
- a writer monad with the extra ability to read all previous output.
runDeclare :: Declare d a -> d -> (d, a) Source #
Run
computation with output history Declare
d ad
,
producing result a
and new output d
.
evalDeclare :: Declare d a -> d -> a Source #
Evaluate
computation, ignoring output Declare
d ad
.
execDeclare :: Declare d a -> d -> d Source #
Execute
computation, ignoring result and only
producing output Declate
d ad
.