-- Module : Control.Monad.Writer
-- Copyright : (c) Andy Gill 2001,
-- (c) Oregon Graduate Institute of Science and Technology, 2001
--- License : BSD-style (see the file libraries/core/LICENSE)
+-- License : BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
--- Portability : non-portable ( requires mulit-parameter type classes,
--- requires functional dependencies )
---
--- $Id: Writer.hs,v 1.2 2002/04/24 16:31:38 simonmar Exp $
+-- Portability : non-portable (multi-param classes, functional dependencies)
--
-- The MonadWriter class.
--
-- Inspired by the paper
--- \em{Functional Programming with Overloading and
--- Higher-Order Polymorphism},
--- \A[HREF="http://www.cse.ogi.edu/~mpj"]{Mark P Jones},
--- Advanced School of Functional Programming, 1995.}
+-- /Functional Programming with Overloading and
+-- Higher-Order Polymorphism/,
+-- Mark P Jones (<http://www.cse.ogi.edu/~mpj/>)
+-- Advanced School of Functional Programming, 1995.
-----------------------------------------------------------------------------
module Control.Monad.Writer (
listens,
censor,
Writer(..),
- runWriter,
execWriter,
mapWriter,
WriterT(..),
- runWriterT,
execWriterT,
mapWriterT,
module Control.Monad,
- module Control.Monad.Monoid,
module Control.Monad.Fix,
module Control.Monad.Trans,
+ module Data.Monoid,
) where
import Prelude
import Control.Monad
-import Control.Monad.Monoid
import Control.Monad.Fix
import Control.Monad.Trans
import Control.Monad.Reader
+import Data.Monoid
-- ---------------------------------------------------------------------------
-- MonadWriter class
listen :: m a -> m (a, w)
pass :: m (a, w -> w) -> m a
-listens :: (MonadWriter w m) => (w -> w) -> m a -> m (a, w)
+listens :: (MonadWriter w m) => (w -> b) -> m a -> m (a, b)
listens f m = do
(a, w) <- listen m
return (a, f w)