@@ -6,7 +6,6 @@
66{-# LANGUAGE UndecidableInstances #-}
77{-# LANGUAGE DataKinds #-}
88{-# LANGUAGE GeneralizedNewtypeDeriving #-}
9−{-# LANGUAGE MagicHash #-}
109
1110{- |
1211
@@ -60,7 +59,6 @@ import Control.Monad.Morph (MFunctor, MMonad)
6059import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
6160import GHC.Generics (Generic)
6261import Data.Coerce (coerce)
63−import GHC.Prim (Proxy#, proxy#)
6462
6563import qualified Control.Monad.Base as MB
6664import qualified Control.Monad.Trans.Control as MC
@@ -78,6 +76,11 @@ import Control.Monad.Ether.State.Class
7876import Control.Monad.Ether.Except.Class
7977import Control.Monad.Ether.Writer.Class
8078
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+
8184import qualified Control.Monad.Reader as Class
8285import qualified Control.Monad.State as Class
8386import qualified Control.Monad.Except as Class
@@ -153,47 +156,47 @@ tagReplace = coerce
153156
154157instance MonadReader tag r m
155158 => Class.MonadReader r (DispatchTagAttachT tag m) where
156− ask = let t = proxy# :: Proxy# tag in Lift.lift (ask t)
157− local = let t = proxy# :: Proxy# tag in Lift.liftLocal (ask t) (local t)
159+ ask = Lift.lift (A.ask @tag)
160+ local = Lift.liftLocal (A.ask @tag) (A.local @tag)
158161
159162instance MonadState tag s m
160163 => Class.MonadState s (DispatchTagAttachT tag m) where
161− get = let t = proxy# :: Proxy# tag in Lift.lift (get t)
162− put = let t = proxy# :: Proxy# tag in Lift.lift . put t
164+ get = Lift.lift (A.get @tag)
165+ put = Lift.lift . A.put @tag
163166
164167instance MonadExcept tag e m
165168 => Class.MonadError e (DispatchTagAttachT tag m) where
166− throwError = let t = proxy# :: Proxy# tag in Lift.lift . throw t
167− catchError = let t = proxy# :: Proxy# tag in Lift.liftCatch (catch t)
169+ throwError = Lift.lift . A.throw @tag
170+ catchError = Lift.liftCatch (A.catch @tag)
168171
169172instance MonadWriter tag w m
170173 => Class.MonadWriter w (DispatchTagAttachT tag m) where
171− writer = let t = proxy# :: Proxy# tag in Lift.lift . writer t
172− tell = let t = proxy# :: Proxy# tag in Lift.lift . tell t
173− listen = let t = proxy# :: Proxy# tag in Lift.liftListen (listen t)
174− pass = let t = proxy# :: Proxy# tag in Lift.liftPass (pass t)
174+ writer = Lift.lift . A.writer @tag
175+ tell = Lift.lift . A.tell @tag
176+ listen = Lift.liftListen (A.listen @tag)
177+ pass = Lift.liftPass (A.pass @tag)
175178
176179
177180-- TagReplace instances
178181
179182instance MonadReader tNew r m
180183 => MonadReader tOld r (DispatchTagReplaceT tOld tNew m) where
181− ask _ = let t = proxy# :: Proxy# tNew in Lift.lift (ask t)
182− local _ = let t = proxy# :: Proxy# tNew in Lift.liftLocal (ask t) (local t)
184+ ask _ = Lift.lift (A.ask @tNew)
185+ local _ = Lift.liftLocal (A.ask @tNew) (A.local @tNew)
183186
184187instance MonadState tNew s m
185188 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
186− get _ = let t = proxy# :: Proxy# tNew in Lift.lift (get t)
187− put _ = let t = proxy# :: Proxy# tNew in Lift.lift . put t
189+ get _ = Lift.lift (A.get @tNew)
190+ put _ = Lift.lift . A.put @tNew
188191
189192instance MonadExcept tNew e m
190193 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
191− throw _ = let t = proxy# :: Proxy# tNew in Lift.lift . throw t
192− catch _ = let t = proxy# :: Proxy# tNew in Lift.liftCatch (catch t)
194+ throw _ = Lift.lift . A.throw @tNew
195+ catch _ = Lift.liftCatch (A.catch @tNew)
193196
194197instance MonadWriter tNew w m
195198 => MonadWriter tOld w (DispatchTagReplaceT tOld tNew m) where
196− writer _ = let t = proxy# :: Proxy# tNew in Lift.lift . writer t
197− tell _ = let t = proxy# :: Proxy# tNew in Lift.lift . tell t
198− listen _ = let t = proxy# :: Proxy# tNew in Lift.liftListen (listen t)
199− pass _ = let t = proxy# :: Proxy# tNew in Lift.liftPass (pass t)
199+ writer _ = Lift.lift . A.writer @tNew
200+ tell _ = Lift.lift . A.tell @tNew
201+ listen _ = Lift.liftListen (A.listen @tNew)
202+ pass _ = Lift.liftPass (A.pass @tNew)