Portability | portable |
---|---|
Stability | experimental |
Maintainer | me@joelt.io |
Safe Haskell | Safe-Inferred |
A monad whose actions produce an output.
This module builds output strictly. For a lazy version, see Control.Monad.Writer.Concurrent.Lazy.
- module Control.Monad.Writer
- data WriterC w m a
- runWriterC :: MonadIO m => WriterC w m a -> TVar w -> m (a, w)
- execWriterC :: MonadIO m => WriterC w m a -> TVar w -> m w
- mapWriterC :: (m (a, TVar w) -> n (b, TVar w)) -> WriterC w m a -> WriterC w n b
- runWritersC :: (MonadFork m, Monoid w) => [WriterC w m a] -> m ([a], w)
- execWritersC :: (MonadFork m, Monoid w) => [WriterC w m a] -> m w
- liftCallCC :: ((((a, TVar w) -> m (b, TVar w)) -> m (a, TVar w)) -> m (a, TVar w)) -> ((a -> WriterC w m b) -> WriterC w m a) -> WriterC w m a
- liftCatch :: (m (a, TVar w) -> (e -> m (a, TVar w)) -> m (a, TVar w)) -> WriterC w m a -> (e -> WriterC w m a) -> WriterC w m a
Documentation
module Control.Monad.Writer
The WriterC monad transformer
A concurrent monad transformer collecting output of type w
.
This is very similar to transformers
' WriterT
, with the exception of
the MonadIO
constraint on every instance, which is necessary to
perform STM actions.
(Monoid w, MonadReader r m) => MonadReader r (WriterC w m) | |
(Monoid w, MonadIO m) => MonadWriter w (WriterC w m) | |
MonadTrans (WriterC w) | |
Monad m => Monad (WriterC w m) | |
Functor m => Functor (WriterC w m) | |
MonadFix m => MonadFix (WriterC w m) | |
MonadPlus m => MonadPlus (WriterC w m) | |
(Functor m, Monad m) => Applicative (WriterC w m) | |
(Functor m, MonadPlus m) => Alternative (WriterC w m) | |
(MonadIO m, MonadCatch m) => MonadCatch (WriterC w m) | |
MonadIO m => MonadIO (WriterC w m) | |
(Monoid w, MonadFork m) => MonadFork (WriterC w m) |
Running WriterC actions
:: MonadIO m | |
=> WriterC w m a | computation to execute |
-> TVar w | output channel |
-> m (a, w) | return value and collected output |
Unwrap a concurrent Writer monad computation as a function.
Unwrap a concurrent Writer monad computation as a function, discarding the return value.
execWriterC
m w =liftM
snd
(runWriterC
m w)
mapWriterC :: (m (a, TVar w) -> n (b, TVar w)) -> WriterC w m a -> WriterC w n bSource
Map both the return value and output of a computation using the given function.
Running concurrent operations on a single input
:: (MonadFork m, Monoid w) | |
=> [WriterC w m a] | writer computations to execute |
-> m ([a], w) | return values and output |
Run multiple Writer operations on the same value, returning the resultant output and the value produced by each operation.
Run multiple Writer operations on the same value, returning the resultant output.