ether-0.4.1.0: Monad transformers and classes

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Trans.Ether.Writer

Contents

Description

Synopsis

The Writer monad

type Writer tag w = WriterT tag w Identity Source #

The parametrizable writer monad.

Computations can accumulate a monoid value.

The return function produces the output mempty, while >>= combines the outputs of the subcomputations using mappend.

writer :: Monad m => proxy tag -> (a, w) -> WriterT tag w m a Source #

Constructor for computations in the writer monad (the inverse of runWriter).

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

type WriterT tag w = TaggedTrans tag (WriterT w) Source #

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.

Writer operations

tell :: Monad m => proxy tag -> w -> WriterT tag w m () Source #

Appends a value to the accumulator within the monad.

listen :: Monad m => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w) Source #

Executes an action and adds its accumulator to the value of the computation.

pass :: Monad m => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a Source #

Executes an action which returns a value and a function, and returns the value, applying the function to the accumulator.