on master help sign in
Type applications in Dispatch
3521eacIndex Int
src/Control/Monad/Trans/Ether/Dispatch.hs+25−22
@@ -6,7 +6,6 @@
6{-# LANGUAGE UndecidableInstances #-}
6{-# LANGUAGE UndecidableInstances #-}
7{-# LANGUAGE DataKinds #-}
7{-# LANGUAGE DataKinds #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
9−{-# LANGUAGE MagicHash #-}
10
9
11{- |
10{- |
12
11
@@ -60,7 +59,6 @@ import Control.Monad.Morph (MFunctor, MMonad)
60import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
59import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
61import GHC.Generics (Generic)
60import GHC.Generics (Generic)
62import Data.Coerce (coerce)
61import Data.Coerce (coerce)
63−import GHC.Prim (Proxy#, proxy#)
64
62
65import qualified Control.Monad.Base as MB
63import qualified Control.Monad.Base as MB
66import qualified Control.Monad.Trans.Control as MC
64import qualified Control.Monad.Trans.Control as MC
@@ -78,6 +76,11 @@ import Control.Monad.Ether.State.Class
78import Control.Monad.Ether.Except.Class
76import Control.Monad.Ether.Except.Class
79import Control.Monad.Ether.Writer.Class
77import Control.Monad.Ether.Writer.Class
80
78
79+import Control.Monad.Ether.Reader as A
80+import Control.Monad.Ether.State.Common as A
81+import Control.Monad.Ether.Except as A
82+import Control.Monad.Ether.Writer as A
83+
81import qualified Control.Monad.Reader as Class
84import qualified Control.Monad.Reader as Class
82import qualified Control.Monad.State as Class
85import qualified Control.Monad.State as Class
83import qualified Control.Monad.Except as Class
86import qualified Control.Monad.Except as Class
@@ -153,47 +156,47 @@ tagReplace = coerce
153
156
154instance MonadReader tag r m
157instance MonadReader tag r m
155 => Class.MonadReader r (DispatchTagAttachT tag m) where
158 => Class.MonadReader r (DispatchTagAttachT tag m) where
156− ask = let t = proxy# :: Proxy# tag in Lift.lift (ask t)
159+ ask = Lift.lift (A.ask @tag)
157− local = let t = proxy# :: Proxy# tag in Lift.liftLocal (ask t) (local t)
160+ local = Lift.liftLocal (A.ask @tag) (A.local @tag)
158
161
159instance MonadState tag s m
162instance MonadState tag s m
160 => Class.MonadState s (DispatchTagAttachT tag m) where
163 => Class.MonadState s (DispatchTagAttachT tag m) where
161− get = let t = proxy# :: Proxy# tag in Lift.lift (get t)
164+ get = Lift.lift (A.get @tag)
162− put = let t = proxy# :: Proxy# tag in Lift.lift . put t
165+ put = Lift.lift . A.put @tag
163
166
164instance MonadExcept tag e m
167instance MonadExcept tag e m
165 => Class.MonadError e (DispatchTagAttachT tag m) where
168 => Class.MonadError e (DispatchTagAttachT tag m) where
166− throwError = let t = proxy# :: Proxy# tag in Lift.lift . throw t
169+ throwError = Lift.lift . A.throw @tag
167− catchError = let t = proxy# :: Proxy# tag in Lift.liftCatch (catch t)
170+ catchError = Lift.liftCatch (A.catch @tag)
168
171
169instance MonadWriter tag w m
172instance MonadWriter tag w m
170 => Class.MonadWriter w (DispatchTagAttachT tag m) where
173 => Class.MonadWriter w (DispatchTagAttachT tag m) where
171− writer = let t = proxy# :: Proxy# tag in Lift.lift . writer t
174+ writer = Lift.lift . A.writer @tag
172− tell = let t = proxy# :: Proxy# tag in Lift.lift . tell t
175+ tell = Lift.lift . A.tell @tag
173− listen = let t = proxy# :: Proxy# tag in Lift.liftListen (listen t)
176+ listen = Lift.liftListen (A.listen @tag)
174− pass = let t = proxy# :: Proxy# tag in Lift.liftPass (pass t)
177+ pass = Lift.liftPass (A.pass @tag)
175
178
176
179
177-- TagReplace instances
180-- TagReplace instances
178
181
179instance MonadReader tNew r m
182instance MonadReader tNew r m
180 => MonadReader tOld r (DispatchTagReplaceT tOld tNew m) where
183 => MonadReader tOld r (DispatchTagReplaceT tOld tNew m) where
181− ask _ = let t = proxy# :: Proxy# tNew in Lift.lift (ask t)
184+ ask _ = Lift.lift (A.ask @tNew)
182− local _ = let t = proxy# :: Proxy# tNew in Lift.liftLocal (ask t) (local t)
185+ local _ = Lift.liftLocal (A.ask @tNew) (A.local @tNew)
183
186
184instance MonadState tNew s m
187instance MonadState tNew s m
185 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
188 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
186− get _ = let t = proxy# :: Proxy# tNew in Lift.lift (get t)
189+ get _ = Lift.lift (A.get @tNew)
187− put _ = let t = proxy# :: Proxy# tNew in Lift.lift . put t
190+ put _ = Lift.lift . A.put @tNew
188
191
189instance MonadExcept tNew e m
192instance MonadExcept tNew e m
190 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
193 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
191− throw _ = let t = proxy# :: Proxy# tNew in Lift.lift . throw t
194+ throw _ = Lift.lift . A.throw @tNew
192− catch _ = let t = proxy# :: Proxy# tNew in Lift.liftCatch (catch t)
195+ catch _ = Lift.liftCatch (A.catch @tNew)
193
196
194instance MonadWriter tNew w m
197instance MonadWriter tNew w m
195 => MonadWriter tOld w (DispatchTagReplaceT tOld tNew m) where
198 => MonadWriter tOld w (DispatchTagReplaceT tOld tNew m) where
196− writer _ = let t = proxy# :: Proxy# tNew in Lift.lift . writer t
199+ writer _ = Lift.lift . A.writer @tNew
197− tell _ = let t = proxy# :: Proxy# tNew in Lift.lift . tell t
200+ tell _ = Lift.lift . A.tell @tNew
198− listen _ = let t = proxy# :: Proxy# tNew in Lift.liftListen (listen t)
201+ listen _ = Lift.liftListen (A.listen @tNew)
199− pass _ = let t = proxy# :: Proxy# tNew in Lift.liftPass (pass t)
202+ pass _ = Lift.liftPass (A.pass @tNew)