Safe Haskell | None |
---|---|
Language | Haskell2010 |
See Control.Monad.Writer.
- class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where
- listens :: MonadWriter tag w m => proxy tag -> (w -> b) -> m a -> m (a, b)
- censor :: MonadWriter tag w m => proxy tag -> (w -> w) -> m a -> m a
- type Writer tag w = WriterT tag w Identity
- runWriter :: proxy tag -> Writer tag w a -> (a, w)
- execWriter :: proxy tag -> Writer tag w a -> w
- data WriterT tag w m a
- writerT :: proxy tag -> m (a, w) -> WriterT tag w m a
- runWriterT :: proxy tag -> WriterT tag w m a -> m (a, w)
- execWriterT :: Monad m => proxy tag -> WriterT tag w m a -> m w
- mapWriterT :: proxy tag -> (m (a, w) -> n (b, w')) -> WriterT tag w m a -> WriterT tag w' n b
MonadWriter class
class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where Source
See MonadWriter
.
writer :: proxy tag -> (a, w) -> m a Source
Embed a simple writer action.
tell :: proxy tag -> w -> m () Source
Append a value to the accumulator within the monad.
listen :: proxy tag -> m a -> m (a, w) Source
Execute an action and add its accumulator to the value of the computation.
pass :: proxy tag -> m (a, w -> w) -> m a Source
Execute an action which returns a value and a function, and return the value, applying the function to the accumulator.
MonadWriter tag w m => MonadWriter tag w (MaybeT m) Source | |
MonadWriter tag w m => MonadWriter tag w (IdentityT m) Source | |
(Monoid w', MonadWriter tag w m) => MonadWriter tag w (WriterT w' m) Source | |
MonadWriter tag w m => MonadWriter tag w (StateT s m) Source | |
MonadWriter tag w m => MonadWriter tag w (StateT s m) Source | |
MonadWriter tag w m => MonadWriter tag w (ReaderT r m) Source | |
MonadWriter tag w m => MonadWriter tag w (ExceptT e m) Source | |
MonadWriter tag w m => MonadWriter tag w (WrappedEther tag' m) Source | |
MonadWriter tag w m => MonadWriter tag w (StateT tag' e m) Source | |
MonadWriter tag w m => MonadWriter tag w (StateT tag' e m) Source | |
MonadWriter tag w m => MonadWriter tag w (ExceptT tag' e m) Source | |
MonadWriter tag w m => MonadWriter tag w (ReaderT tag' r m) Source | |
(Monoid w', MonadWriter tag w m) => MonadWriter tag w (WriterT tag' w' m) Source | |
(Monoid w, Monad m) => MonadWriter tag w (WriterT tag w m) Source |
listens :: MonadWriter tag w m => proxy tag -> (w -> b) -> m a -> m (a, b) Source
Execute an action and add the result of applying the given function to its accumulator to the value of the computation.
censor :: MonadWriter tag w m => proxy tag -> (w -> w) -> m a -> m a Source
Execute an action and apply a function to its accumulator.
The Writer monad
runWriter :: proxy tag -> Writer tag w a -> (a, w) Source
Runs a Writer
and returns both the normal value
and the final accumulator.
execWriter :: proxy tag -> Writer tag w a -> w Source
Runs a Writer
and returns the final accumulator,
discarding the normal value.
The WriterT monad transformer
The writer monad transformer.
The return
function produces the output mempty
, while >>=
combines
the outputs of the subcomputations using mappend
.
writerT :: proxy tag -> m (a, w) -> WriterT tag w m a Source
Constructor for computations in the writer monad transformer.
runWriterT :: proxy tag -> WriterT tag w m a -> m (a, w) Source
Runs a WriterT
and returns both the normal value
and the final accumulator.
execWriterT :: Monad m => proxy tag -> WriterT tag w m a -> m w Source
Runs a WriterT
and returns the final accumulator,
discarding the normal value.
mapWriterT :: proxy tag -> (m (a, w) -> n (b, w')) -> WriterT tag w m a -> WriterT tag w' n b Source
Transform the computation inside a WriterT
.
runWriterT
tag (mapWriterT
tag f m) = f (runWriterT
tag m)