@@ -2,6 +2,7 @@ module Control.Monad.Writer
22
33import Builtins
44import Control.Monad.Identity
5+import Control.Monad.Trans
56
67%access public
78
@@ -44,6 +45,10 @@ instance (Monoid w, Monad m) => MonadWriter w (WriterT w m) where
4445 pass (WR m) = WR $ do ((a, f), w) <- m
4546 return (a, f w)
4647
48+instance Monoid w => MonadTrans (WriterT w) where
49+ lift x = WR $ do r <- x
50+ return (r, neutral)
51+
4752||| Run an action in the Writer monad and transform the written output
4853listens : MonadWriter w m => (w -> b) -> m a -> m (a, b)
4954listens f m = listens' f (listen m) where