monads-fd-0.0.0.0: Monad classes, using functional dependenciesSource codeContentsIndex
Control.Monad.Writer.Lazy
Portabilitynon-portable (multi-param classes, functional dependencies)
Stabilityexperimental
Maintainerlibraries@haskell.org
Contents
MonadWriter class
The Writer monad
The WriterT monad transformer
Description

Lazy 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
class (Monoid w, Monad m) => MonadWriter w m | m -> w where
tell :: w -> m ()
listen :: m a -> m (a, w)
pass :: m (a, w -> w) -> m a
listens :: MonadWriter w m => (w -> b) -> m a -> m (a, b)
censor :: MonadWriter w m => (w -> w) -> m a -> m a
type Writer w = WriterT w Identity
runWriter :: Writer w a -> (a, w)
execWriter :: Writer w a -> w
mapWriter :: ((a, w) -> (b, w')) -> Writer w a -> Writer w' b
newtype WriterT w m a = WriterT {
runWriterT :: m (a, w)
}
execWriterT :: Monad m => WriterT w m a -> m w
mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
module Control.Monad
module Control.Monad.Fix
module Control.Monad.Trans
module Data.Monoid
MonadWriter class
class (Monoid w, Monad m) => MonadWriter w m | m -> w whereSource
Methods
tell :: w -> m ()Source
listen :: m a -> m (a, w)Source
pass :: m (a, w -> w) -> m aSource
show/hide Instances
MonadWriter w m => MonadWriter w (StateT s m)
MonadWriter w m => MonadWriter w (StateT s m)
MonadWriter w m => MonadWriter w (ReaderT r m)
(Error e, MonadWriter w m) => MonadWriter w (ErrorT e m)
(Monoid w, Monad m) => MonadWriter w (WriterT w m)
(Monoid w, Monad m) => MonadWriter w (WriterT w m)
(Monoid w, Monad m) => MonadWriter w (RWST r w s m)
(Monoid w, Monad m) => MonadWriter w (RWST r w s m)
listens :: MonadWriter w m => (w -> b) -> m a -> m (a, b)Source
censor :: MonadWriter w m => (w -> w) -> m a -> m aSource
The Writer monad
type Writer w = WriterT w IdentitySource
runWriter :: Writer w a -> (a, w)Source
execWriter :: Writer w a -> wSource
mapWriter :: ((a, w) -> (b, w')) -> Writer w a -> Writer w' bSource
The WriterT monad transformer
newtype WriterT w m a Source
Constructors
WriterT
runWriterT :: m (a, w)
show/hide Instances
execWriterT :: Monad m => WriterT w m a -> m wSource
mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n bSource
module Control.Monad
module Control.Monad.Fix
module Control.Monad.Trans
module Data.Monoid
Produced by Haddock version 2.6.0