@@ -20,27 +20,9 @@ module Control.Monad.Ether.Except.Class
2020import Data.Monoid
2121#endif
2222
23−import Data.Proxy (Proxy(Proxy))
24−import Control.Monad.Trans (lift)
25−
2623import Control.Monad.Trans.Ether.Except hiding (throw, catch)
2724import qualified Control.Monad.Trans.Ether.Except as E
28−import qualified Control.Monad.Trans.Ether.Reader as R
29−import qualified Control.Monad.Trans.Ether.Writer as W
30−import qualified Control.Monad.Trans.Ether.State.Lazy as S.L
31−import qualified Control.Monad.Trans.Ether.State.Strict as S.S
32−import qualified Control.Ether.Util as Util
33−
34−-- for mtl instances
35−import qualified Control.Monad.Trans.Except as Trans.E
36−import qualified Control.Monad.Trans.Identity as Trans.I
37−import qualified Control.Monad.Trans.List as Trans.L
38−import qualified Control.Monad.Trans.Maybe as Trans.M
39−import qualified Control.Monad.Trans.Reader as Trans.R
40−import qualified Control.Monad.Trans.State.Lazy as Trans.S.Lazy
41−import qualified Control.Monad.Trans.State.Strict as Trans.S.Strict
42−import qualified Control.Monad.Trans.Writer.Lazy as Trans.W.Lazy
43−import qualified Control.Monad.Trans.Writer.Strict as Trans.W.Strict
25+import qualified Control.Monad.Trans.Lift.Catch as Lift
4426
4527
4628-- | See 'Control.Monad.Except.MonadError'.
@@ -57,63 +39,9 @@ instance {-# OVERLAPPING #-} Monad m => MonadExcept tag e (ExceptT tag e m) wher
5739 throw = E.throw
5840 catch = E.catch
5941
60−instance MonadExcept tag e m => MonadExcept tag e (ExceptT tag' e' m) where
61− throw t = lift . throw t
62− catch t = liftCatch Proxy (catch t)
63−
64−-- Instances for other tagged transformers
65−
66−instance MonadExcept tag e m => MonadExcept tag e (R.ReaderT tag' r m) where
67− throw t = lift . throw t
68− catch t = R.liftCatch Proxy (catch t)
69−
70−instance (Monoid w, MonadExcept tag e m) => MonadExcept tag e (W.WriterT tag' w m) where
71− throw t = lift . throw t
72− catch t = W.liftCatch Proxy (catch t)
73−
74−instance MonadExcept tag e m => MonadExcept tag e (S.L.StateT tag' s m) where
75− throw t = lift . throw t
76− catch t = S.L.liftCatch Proxy (catch t)
77−
78−instance MonadExcept tag e m => MonadExcept tag e (S.S.StateT tag' s m) where
79− throw t = lift . throw t
80− catch t = S.S.liftCatch Proxy (catch t)
81−
82−
83−-- Instances for mtl transformers
84−
85−instance MonadExcept tag e m => MonadExcept tag e (Trans.E.ExceptT e' m) where
86− throw t = lift . throw t
87− catch t = Util.liftCatch_ExceptT (catch t)
88−
89−instance MonadExcept tag e m => MonadExcept tag e (Trans.I.IdentityT m) where
90− throw t = lift . throw t
91− catch t = Trans.I.liftCatch (catch t)
92−
93−instance MonadExcept tag e m => MonadExcept tag e (Trans.L.ListT m) where
94− throw t = lift . throw t
95− catch t = Trans.L.liftCatch (catch t)
96−
97−instance MonadExcept tag e m => MonadExcept tag e (Trans.M.MaybeT m) where
98− throw t = lift . throw t
99− catch t = Trans.M.liftCatch (catch t)
100−
101−instance MonadExcept tag e m => MonadExcept tag e (Trans.R.ReaderT r m) where
102− throw t = lift . throw t
103− catch t = Trans.R.liftCatch (catch t)
104−
105−instance MonadExcept tag e m => MonadExcept tag e (Trans.S.Lazy.StateT s m) where
106− throw t = lift . throw t
107− catch t = Trans.S.Lazy.liftCatch (catch t)
108−
109−instance MonadExcept tag e m => MonadExcept tag e (Trans.S.Strict.StateT s m) where
110− throw t = lift . throw t
111− catch t = Trans.S.Strict.liftCatch (catch t)
112−
113−instance (Monoid w, MonadExcept tag e m) => MonadExcept tag e (Trans.W.Lazy.WriterT w m) where
114− throw t = lift . throw t
115− catch t = Trans.W.Lazy.liftCatch (catch t)
116−
117−instance (Monoid w, MonadExcept tag e m) => MonadExcept tag e (Trans.W.Strict.WriterT w m) where
118− throw t = lift . throw t
119− catch t = Trans.W.Strict.liftCatch (catch t)
42+instance ( Lift.LiftCatch t
43+ , Monad (t m)
44+ , MonadExcept tag e m
45+ ) => MonadExcept tag e (t m) where
46+ throw t = Lift.lift . throw t
47+ catch t = Lift.liftCatch (catch t)