ether-0.3.0.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

data WriterT tag w m a Source

The writer monad transformer.

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

Instances

(Monoid w, Monad m) => MonadWriter tag w (WriterT tag w m) 
(Monoid w, MonadState tag s m) => MonadState tag s (WriterT tag' w m) 
(Monoid w, MonadBase b m) => MonadBase b (WriterT tag w m) 
(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT tag w m) 
(Monoid w, MonadError e m) => MonadError e (WriterT tag w m) 
(Monoid w, MonadReader r m) => MonadReader r (WriterT tag w m) 
(Monoid w, MonadState s m) => MonadState s (WriterT tag w m) 
(Monoid w, MonadWriter w' m) => MonadWriter w' (WriterT tag w m) 
MFunctor (WriterT tag w) 
Monoid w => MMonad (WriterT tag w) 
Monoid w => MonadTrans (WriterT tag w) 
Monoid w => MonadTransControl (WriterT tag w) 
Monoid w => LiftLocal (WriterT tag w) 
Monoid w => LiftCallCC (WriterT tag w) 
Monoid w' => LiftPass (WriterT tag w') 
Monoid w => LiftListen (WriterT tag w) 
Monoid w => LiftCatch (WriterT tag w) 
(Alternative m, Monoid w) => Alternative (WriterT tag w m) 
(Monad m, Monoid w) => Monad (WriterT tag w m) 
Functor m => Functor (WriterT tag w m) 
(MonadFix m, Monoid w) => MonadFix (WriterT tag w m) 
(MonadPlus m, Monoid w) => MonadPlus (WriterT tag w m) 
(Applicative m, Monoid w) => Applicative (WriterT tag w m) 
(Monoid w, MonadIO m) => MonadIO (WriterT tag w m) 
(Monoid w, MonadCont m) => MonadCont (WriterT tag w m) 
Taggable (WriterT tag w m) 
Tagged (WriterT tag w m) tag 
Generic (WriterT tag w m a) 
Newtype (WriterT tag w m a) 
type StT (WriterT tag w) a = StT (WriterT w) a 
type StT (WriterT tag w) a = StT (WriterT tag w) a 
type Untagged (WriterT tag w m) = WriterT w m 
type Tag (WriterT tag w m) = Just * tag 
type Inner (WriterT tag w m) = Just (* -> *) m 
type StM (WriterT tag w m) a = ComposeSt (WriterT tag w) m a 
type Rep (WriterT tag w m a) 
type O (WriterT tag w m a) = GO (Rep (WriterT tag w m a)) 

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 :: (Monoid w, 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 :: (Monoid w, 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.