on master help sign in
Add: default MTL instances for DispatchT
30f7946Vladislav Zavialov
CHANGELOG.md+5
@@ -1,3 +1,8 @@
1+0.4.2.0
2+-------
3+
4+* Add default MTL instances for DispatchT.
5+
10.4.1.0
60.4.1.0
2-------
7-------
3
8
ether.cabal+1−1
@@ -1,5 +1,5 @@
1name: ether
1name: ether
2−version: 0.4.1.0
2+version: 0.4.2.0
3synopsis: Monad transformers and classes
3synopsis: Monad transformers and classes
4description:
4description:
5 Ether is a Haskell library that extends @mtl@ and @transformers@ with
5 Ether is a Haskell library that extends @mtl@ and @transformers@ with
src/Control/Monad/Trans/Ether/Dispatch.hs+42
@@ -84,6 +84,7 @@ import Control.Monad.Ether.State.Class
84import Control.Monad.Ether.Except.Class
84import Control.Monad.Ether.Except.Class
85import Control.Monad.Ether.Writer.Class
85import Control.Monad.Ether.Writer.Class
86
86
87+import qualified Control.Monad.Cont as Class
87import qualified Control.Monad.Reader as Class
88import qualified Control.Monad.Reader as Class
88import qualified Control.Monad.State as Class
89import qualified Control.Monad.State as Class
89import qualified Control.Monad.Except as Class
90import qualified Control.Monad.Except as Class
@@ -207,3 +208,44 @@ instance MonadWriter tNew w m
207 tell _ = let t = Proxy :: Proxy tNew in Lift.lift . tell t
208 tell _ = let t = Proxy :: Proxy tNew in Lift.lift . tell t
208 listen _ = let t = Proxy :: Proxy tNew in Lift.liftListen (listen t)
209 listen _ = let t = Proxy :: Proxy tNew in Lift.liftListen (listen t)
209 pass _ = let t = Proxy :: Proxy tNew in Lift.liftPass (pass t)
210 pass _ = let t = Proxy :: Proxy tNew in Lift.liftPass (pass t)
211+
212+
213+-- Instances for mtl classes
214+
215+instance {-# OVERLAPPABLE #-}
216+ ( Class.MonadCont m
217+ ) => Class.MonadCont (DispatchT dp m)
218+ where
219+ callCC = Lift.liftCallCC' Class.callCC
220+
221+instance {-# OVERLAPPABLE #-}
222+ ( Class.MonadReader r m
223+ ) => Class.MonadReader r (DispatchT dp m)
224+ where
225+ ask = Class.lift Class.ask
226+ local = Lift.liftLocal Class.ask Class.local
227+ reader = Class.lift . Class.reader
228+
229+instance {-# OVERLAPPABLE #-}
230+ ( Class.MonadState s m
231+ ) => Class.MonadState s (DispatchT dp m)
232+ where
233+ get = Class.lift Class.get
234+ put = Class.lift . Class.put
235+ state = Class.lift . Class.state
236+
237+instance {-# OVERLAPPABLE #-}
238+ ( Class.MonadWriter w m
239+ ) => Class.MonadWriter w (DispatchT dp m)
240+ where
241+ writer = Class.lift . Class.writer
242+ tell = Class.lift . Class.tell
243+ listen = Lift.liftListen Class.listen
244+ pass = Lift.liftPass Class.pass
245+
246+instance {-# OVERLAPPABLE #-}
247+ ( Class.MonadError e m
248+ ) => Class.MonadError e (DispatchT dp m)
249+ where
250+ throwError = Class.lift . Class.throwError
251+ catchError = Lift.liftCatch Class.catchError