@@ -1,4 +1,7 @@
11{-# OPTIONS_GHC -fno-warn-orphans #-}
2+{-# LANGUAGE MultiParamTypeClasses #-}
3+{-# LANGUAGE FlexibleInstances #-}
4+{-# LANGUAGE UndecidableInstances #-}
25-----------------------------------------------------------------------------
36-- |
47-- Module : Control.Monad.RWS.CPS
@@ -45,24 +48,32 @@ import Control.Monad.RWS.Class as X
4548import Control.Monad.Trans as X
4649import Data.Monoid as X
4750
51+import Control.Monad.Cont.Class
52+import Control.Monad.Error.Class
4853import Control.Monad.Trans.RWS.CPS
4954import qualified Control.Monad.Trans.RWS.CPS as CPS
5055
51−-- Orphan instance
56+-- Orphan instances
57+
5258instance (Monoid w, Monad m) => MonadWriter w (RWST r w s m) where
5359 writer = CPS.writer
5460 tell = CPS.tell
5561 listen = CPS.listen
5662 pass = CPS.pass
5763
58−-- Orphan instance
5964instance Monad m => MonadReader r (RWST r w s m) where
6065 ask = CPS.ask
6166 local = CPS.local
6267 reader = CPS.reader
6368
64−-- Orphan instance
6569instance Monad m => MonadState s (RWST r w s m) where
6670 get = CPS.get
6771 put = CPS.put
6872 state = CPS.state
73+
74+instance MonadError e m => MonadError e (RWST r w s m) where
75+ throwError = lift . throwError
76+ catchError = CPS.liftCatch catchError
77+
78+instance MonadCont m => MonadCont (RWST r w s m) where
79+ callCC = CPS.liftCallCC callCC