monads-tf-0.0.0.0: Monad classes, using type familiesSource codeContentsIndex
Control.Monad.Writer.Strict
Portabilitynon-portable (type families)
Stabilityexperimental
Maintainerlibraries@haskell.org
Contents
MonadWriter class
The Writer monad
The WriterT monad transformer
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
class (Monoid (WriterType m), Monad m) => MonadWriter m where
type WriterType m
tell :: WriterType m -> m ()
listen :: m a -> m (a, WriterType m)
pass :: m (a, WriterType m -> WriterType m) -> m a
listens :: MonadWriter m => (WriterType m -> b) -> m a -> m (a, b)
censor :: MonadWriter m => (WriterType m -> WriterType m) -> 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 (WriterType m), Monad m) => MonadWriter m whereSource
Associated Types
type WriterType m Source
Methods
tell :: WriterType m -> m ()Source
listen :: m a -> m (a, WriterType m)Source
pass :: m (a, WriterType m -> WriterType m) -> m aSource
show/hide Instances
listens :: MonadWriter m => (WriterType m -> b) -> m a -> m (a, b)Source
censor :: MonadWriter m => (WriterType m -> WriterType m) -> 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