concurrent-state-0.6.0.0: MTL-like library using TVars

Portabilityportable
Stabilityexperimental
Maintainerme@joelt.io
Safe HaskellSafe-Inferred

Control.Monad.Writer.Concurrent.Strict

Contents

Description

A monad whose actions produce an output.

This module builds output strictly. For a lazy version, see Control.Monad.Writer.Concurrent.Lazy.

Synopsis

Documentation

The WriterC monad transformer

data WriterC w m a Source

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.

Instances

(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

runWriterCSource

Arguments

:: 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.

execWriterCSource

Arguments

:: MonadIO m 
=> WriterC w m a

computation to execute

-> TVar w

output channel

-> m w

collected output

Unwrap a concurrent Writer monad computation as a function, discarding the return value.

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

runWritersCSource

Arguments

:: (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.

execWritersCSource

Arguments

:: (MonadFork m, Monoid w) 
=> [WriterC w m a]

writer computations to execute

-> m w

output

Run multiple Writer operations on the same value, returning the resultant output.

Lifting other operations

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 aSource

Lift a callCC operation to the new monad.

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 aSource

Lift a catchError operation to the new monad.