X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=sidebyside;f=RWST.icl;h=2f02d6dce1dbd86d5e32d9a1ded2a46a137044bf;hb=f081c2c5e248331eb6e2f090f4afe818fd8259eb;hp=712f71e62db2689d3824e473b2705f3540ac566c;hpb=392b823861ae02cc42454abce8c97e606931c3d6;p=cc1516.git diff --git a/RWST.icl b/RWST.icl index 712f71e..2f02d6d 100644 --- a/RWST.icl +++ b/RWST.icl @@ -8,6 +8,7 @@ import Data.Functor.Identity import Data.Functor import Data.Monoid import Control.Monad +import Control.Monad.Trans import Control.Applicative // The RWS monad @@ -46,6 +47,9 @@ instance Monad (RWST r w s m) | Monad m & Monoid w where >>= \(a, s`, w)->runRWST (k a) r s` >>= \(b, s``,w`)->pure (b, s``, mappend w w`) +instance MonadTrans (RWST r w s) | Monoid w where + liftT m = RWST \_ s->m >>= \a->pure (a, s, mempty) + runRWST :: (RWST r w s m a) r s -> m (a, s, w) runRWST (RWST f) r s = f r s