@@ -14,7 +14,7 @@ interface (Monoid w, MonadReader r m, MonadWriter w m, MonadState s m) => MonadR
14record RWST (r : Type) (w : Type) (s : Type) (m : Type -> Type) (a : Type) where
14record RWST (r : Type) (w : Type) (s : Type) (m : Type -> Type) (a : Type) where
15 constructor MkRWST
15 constructor MkRWST
16 runRWST : r -> s -> m (a, s, w)
16 runRWST : r -> s -> m (a, s, w)
18implementation Monad m => Functor (RWST r w s m) where
18implementation Monad m => Functor (RWST r w s m) where
19 map f (MkRWST m) = MkRWST $ \r,s => do (a, s', w) <- m r s
19 map f (MkRWST m) = MkRWST $ \r,s => do (a, s', w) <- m r s
20 pure (f a, s', w)
20 pure (f a, s', w)
@@ -48,6 +48,12 @@ implementation (Monoid w, Monad m) => MonadState s (RWST r w s m) where
49implementation (Monoid w, Monad m) => MonadRWS r w s (RWST r w s m) where {}
49implementation (Monoid w, Monad m) => MonadRWS r w s (RWST r w s m) where {}
51+||| Adapted from https://hackage.haskell.org/package/transformers-0.5.4.0/docs/src/Control-Monad-Trans-RWS-Lazy.html
52+implementation Monoid w => MonadTrans (RWST r w s) where
53+ lift x = MkRWST $ \ _, s => do
51||| The RWS monad. See the MonadRWS interface
57||| The RWS monad. See the MonadRWS interface
52RWS : Type -> Type -> Type -> Type -> Type
58RWS : Type -> Type -> Type -> Type -> Type
53RWS r w s a = RWST r w s Identity a
59RWS r w s a = RWST r w s Identity a