| Copyright | (c) Andy Gill 2001 (c) Oregon Graduate Institute of Science and Technology 2001 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | libraries@haskell.org |
| Stability | experimental |
| Portability | non-portable (multi-param classes, functional dependencies) |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Control.Monad.Writer.Strict
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.
- module Control.Monad.Writer.Class
- type Writer w = WriterT w Identity
- 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
Documentation
module Control.Monad.Writer.Class
execWriter :: Writer w a -> w #
Extract the output from a writer computation.
execWriterm =snd(runWriterm)
newtype WriterT w (m :: * -> *) a :: * -> (* -> *) -> * -> * #
A writer monad parameterized by:
w- the output to accumulate.m- The inner monad.
The return function produces the output mempty, while >>=
combines the outputs of the subcomputations using mappend.
Constructors
| WriterT | |
Fields
| |
Instances
execWriterT :: Monad m => WriterT w m a -> m w #
Extract the output from a writer computation.
execWriterTm =liftMsnd(runWriterTm)
mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b #
Map both the return value and output of a computation using the given function.
runWriterT(mapWriterTf m) = f (runWriterTm)
module Control.Monad
module Control.Monad.Fix
module Control.Monad.Trans
module Data.Monoid