transformers-0.1.1.0: Concrete monad transformers

Portabilityportable
Stabilityexperimental
Maintainerlibraries@haskell.org

Control.Monad.Trans.Writer.Strict

Contents

Description

Strict writer monads.

Inspired by the paper /Functional Programming with Overloading and Higher-Order Polymorphism/, Mark P Jones (http://web.cecs.pdx.edu/~mpj/pubs/springschool.html) Advanced School of Functional Programming, 1995.

Synopsis

The Writer monad

writer :: (a, w) -> Writer w aSource

runWriter :: Writer w a -> (a, w)Source

mapWriter :: ((a, w) -> (b, w')) -> Writer w a -> Writer w' bSource

The WriterT monad transformer

newtype WriterT w m a Source

Constructors

WriterT 

Fields

runWriterT :: m (a, w)
 

Instances

Monoid w => MonadTrans (WriterT w) 
(Monoid w, Monad m) => Monad (WriterT w m) 
Functor m => Functor (WriterT w m) 
(Monoid w, MonadFix m) => MonadFix (WriterT w m) 
(Monoid w, MonadPlus m) => MonadPlus (WriterT w m) 
(Monoid w, Applicative m) => Applicative (WriterT w m) 
(Monoid w, Alternative m) => Alternative (WriterT w m) 
(Monoid w, MonadIO m) => MonadIO (WriterT w m) 

execWriterT :: Monad m => WriterT w m a -> m wSource

mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n bSource

Writer operations

tell :: (Monoid w, Monad m) => w -> WriterT w m ()Source

listen :: (Monoid w, Monad m) => WriterT w m a -> WriterT w m (a, w)Source

pass :: (Monoid w, Monad m) => WriterT w m (a, w -> w) -> WriterT w m aSource

listens :: (Monoid w, Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b)Source

censor :: (Monoid w, Monad m) => (w -> w) -> WriterT w m a -> WriterT w m aSource

Lifting other operations

liftCallCC :: Monoid w => ((((a, w) -> m (b, w)) -> m (a, w)) -> m (a, w)) -> ((a -> WriterT w m b) -> WriterT w m a) -> WriterT w m aSource

Lift a callCC operation to the new monad.

liftCatch :: (m (a, w) -> (e -> m (a, w)) -> m (a, w)) -> WriterT w m a -> (e -> WriterT w m a) -> WriterT w m aSource

Lift a catchError operation to the new monad.