@@ -13,6 +13,7 @@
1313{-# LANGUAGE DataKinds #-}
1414{-# LANGUAGE PolyKinds #-}
1515{-# LANGUAGE GeneralizedNewtypeDeriving #-}
16+{-# LANGUAGE MagicHash #-}
1617
1718{- |
1819
@@ -66,7 +67,7 @@ import Control.Monad.Morph (MFunctor, MMonad)
6667import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
6768import GHC.Generics (Generic)
6869import Data.Coerce (coerce)
69−import Data.Proxy
70+import GHC.Prim (Proxy#, proxy#)
7071
7172import qualified Control.Monad.Base as MB
7273import qualified Control.Monad.Trans.Control as MC
@@ -147,13 +148,13 @@ instance Lift.LiftCallCC (DispatchT dp) where
147148 liftCallCC' = Lift.defaultLiftCallCC' pack unpack
148149
149150-- | Attach a tag to untagged transformers.
150−tagAttach :: proxy t -> DispatchTagAttachT t m a -> m a
151+tagAttach :: Proxy# t -> DispatchTagAttachT t m a -> m a
151152tagAttach _ = coerce
152153
153154-- | Replace a tag with another tag.
154155tagReplace
155− :: proxy tOld
156− -> proxy tNew
156+ :: Proxy# tOld
157+ -> Proxy# tNew
157158 -> DispatchTagReplaceT tOld tNew m a
158159 -> m a
159160tagReplace _ _ = coerce
@@ -163,47 +164,47 @@ tagReplace _ _ = coerce
163164
164165instance MonadReader tag r m
165166 => Class.MonadReader r (DispatchTagAttachT tag m) where
166− ask = let t = Proxy :: Proxy tag in Lift.lift (ask t)
167− local = let t = Proxy :: Proxy tag in Lift.liftLocal (ask t) (local t)
167+ ask = let t = proxy# :: Proxy# tag in Lift.lift (ask t)
168+ local = let t = proxy# :: Proxy# tag in Lift.liftLocal (ask t) (local t)
168169
169170instance MonadState tag s m
170171 => Class.MonadState s (DispatchTagAttachT tag m) where
171− get = let t = Proxy :: Proxy tag in Lift.lift (get t)
172− put = let t = Proxy :: Proxy tag in Lift.lift . put t
172+ get = let t = proxy# :: Proxy# tag in Lift.lift (get t)
173+ put = let t = proxy# :: Proxy# tag in Lift.lift . put t
173174
174175instance MonadExcept tag e m
175176 => Class.MonadError e (DispatchTagAttachT tag m) where
176− throwError = let t = Proxy :: Proxy tag in Lift.lift . throw t
177− catchError = let t = Proxy :: Proxy tag in Lift.liftCatch (catch t)
177+ throwError = let t = proxy# :: Proxy# tag in Lift.lift . throw t
178+ catchError = let t = proxy# :: Proxy# tag in Lift.liftCatch (catch t)
178179
179180instance MonadWriter tag w m
180181 => Class.MonadWriter w (DispatchTagAttachT tag m) where
181− writer = let t = Proxy :: Proxy tag in Lift.lift . writer t
182− tell = let t = Proxy :: Proxy tag in Lift.lift . tell t
183− listen = let t = Proxy :: Proxy tag in Lift.liftListen (listen t)
184− pass = let t = Proxy :: Proxy tag in Lift.liftPass (pass t)
182+ writer = let t = proxy# :: Proxy# tag in Lift.lift . writer t
183+ tell = let t = proxy# :: Proxy# tag in Lift.lift . tell t
184+ listen = let t = proxy# :: Proxy# tag in Lift.liftListen (listen t)
185+ pass = let t = proxy# :: Proxy# tag in Lift.liftPass (pass t)
185186
186187
187188-- TagReplace instances
188189
189190instance MonadReader tNew r m
190191 => MonadReader tOld r (DispatchTagReplaceT tOld tNew m) where
191− ask _ = let t = Proxy :: Proxy tNew in Lift.lift (ask t)
192− local _ = let t = Proxy :: Proxy tNew in Lift.liftLocal (ask t) (local t)
192+ ask _ = let t = proxy# :: Proxy# tNew in Lift.lift (ask t)
193+ local _ = let t = proxy# :: Proxy# tNew in Lift.liftLocal (ask t) (local t)
193194
194195instance MonadState tNew s m
195196 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
196− get _ = let t = Proxy :: Proxy tNew in Lift.lift (get t)
197− put _ = let t = Proxy :: Proxy tNew in Lift.lift . put t
197+ get _ = let t = proxy# :: Proxy# tNew in Lift.lift (get t)
198+ put _ = let t = proxy# :: Proxy# tNew in Lift.lift . put t
198199
199200instance MonadExcept tNew e m
200201 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
201− throw _ = let t = Proxy :: Proxy tNew in Lift.lift . throw t
202− catch _ = let t = Proxy :: Proxy tNew in Lift.liftCatch (catch t)
202+ throw _ = let t = proxy# :: Proxy# tNew in Lift.lift . throw t
203+ catch _ = let t = proxy# :: Proxy# tNew in Lift.liftCatch (catch t)
203204
204205instance MonadWriter tNew w m
205206 => MonadWriter tOld w (DispatchTagReplaceT tOld tNew m) where
206− writer _ = let t = Proxy :: Proxy tNew in Lift.lift . writer t
207− tell _ = let t = Proxy :: Proxy tNew in Lift.lift . tell t
208− listen _ = let t = Proxy :: Proxy tNew in Lift.liftListen (listen t)
209− pass _ = let t = Proxy :: Proxy tNew in Lift.liftPass (pass t)
207+ writer _ = let t = proxy# :: Proxy# tNew in Lift.lift . writer t
208+ tell _ = let t = proxy# :: Proxy# tNew in Lift.lift . tell t
209+ listen _ = let t = proxy# :: Proxy# tNew in Lift.liftListen (listen t)
210+ pass _ = let t = proxy# :: Proxy# tNew in Lift.liftPass (pass t)