{-# LANGUAGE CPP #-}
module Control.Monad.Trans.MSF.Writer
( module Control.Monad.Trans.Writer.Strict
, writerS
, runWriterS
)
where
import Control.Monad.Trans.Writer.Strict hiding (liftCallCC, liftCatch, pass)
#if !MIN_VERSION_base(4,8,0)
import Data.Functor ((<$>))
import Data.Monoid (Monoid)
#endif
import Data.MonadicStreamFunction (MSF, morphGS)
writerS :: (Functor m, Monad m, Monoid w)
=> MSF m a (w, b) -> MSF (WriterT w m) a b
writerS :: forall (m :: * -> *) w a b.
(Functor m, Monad m, Monoid w) =>
MSF m a (w, b) -> MSF (WriterT w m) a b
writerS = forall (m2 :: * -> *) a1 (m1 :: * -> *) b1 a2 b2.
Monad m2 =>
(forall c. (a1 -> m1 (b1, c)) -> a2 -> m2 (b2, c))
-> MSF m1 a1 b1 -> MSF m2 a2 b2
morphGS forall a b. (a -> b) -> a -> b
$ \a -> m ((w, b), c)
f a
a -> forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
WriterT forall a b. (a -> b) -> a -> b
$ (\((w
w, b
b), c
c) -> ((b
b, c
c), w
w)) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> m ((w, b), c)
f a
a
runWriterS :: (Functor m, Monad m)
=> MSF (WriterT s m) a b -> MSF m a (s, b)
runWriterS :: forall (m :: * -> *) s a b.
(Functor m, Monad m) =>
MSF (WriterT s m) a b -> MSF m a (s, b)
runWriterS = forall (m2 :: * -> *) a1 (m1 :: * -> *) b1 a2 b2.
Monad m2 =>
(forall c. (a1 -> m1 (b1, c)) -> a2 -> m2 (b2, c))
-> MSF m1 a1 b1 -> MSF m2 a2 b2
morphGS forall a b. (a -> b) -> a -> b
$ \a -> WriterT s m (b, c)
f a
a -> (\((b
b, c
c), s
s) -> ((s
s, b
b), c
c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
runWriterT (a -> WriterT s m (b, c)
f a
a)