@@ -13,9 +13,11 @@ import Control.Monad.Fix (MonadFix)
1313import Control.Monad.IO.Class (MonadIO)
1414import Control.Monad.Ether.Reader
1515import Control.Monad.Ether.State
16+import Control.Monad.Ether.Except
1617
1718import qualified Control.Monad.Reader as Class
1819import qualified Control.Monad.State as Class
20+import qualified Control.Monad.Except as Class
1921
2022newtype WrappedEther tag m a = WrapEther { unwrapEther :: m a }
2123 deriving ( Functor, Applicative, Alternative, Monad, MonadPlus
@@ -29,5 +31,9 @@ instance MonadState tag s m => Class.MonadState s (WrappedEther tag m) where
2931 get = WrapEther $ get (Proxy :: Proxy tag)
3032 put = WrapEther . put (Proxy :: Proxy tag)
3133
34+instance MonadExcept tag e m => Class.MonadError e (WrappedEther tag m) where
35+ throwError = WrapEther . throw (Proxy :: Proxy tag)
36+ catchError m h = WrapEther $ catch (Proxy :: Proxy tag) (unwrapEther m) (unwrapEther . h)
37+
3238ethered :: proxy tag -> WrappedEther tag m a -> m a
3339ethered _proxy = unwrapEther