@@ -1,15 +1,11 @@
11{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
22
33{-# LANGUAGE DeriveGeneric #-}
4−{-# LANGUAGE MultiParamTypeClasses #-}
54{-# LANGUAGE TypeFamilies #-}
65{-# LANGUAGE FlexibleInstances #-}
76{-# LANGUAGE UndecidableInstances #-}
8−{-# LANGUAGE ScopedTypeVariables #-}
97{-# LANGUAGE DataKinds #-}
10−{-# LANGUAGE PolyKinds #-}
118{-# LANGUAGE GeneralizedNewtypeDeriving #-}
12−{-# LANGUAGE MagicHash #-}
139
1410{- |
1511
@@ -63,7 +59,6 @@ import Control.Monad.Morph (MFunctor, MMonad)
6359import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
6460import GHC.Generics (Generic)
6561import Data.Coerce (coerce)
66−import GHC.Prim (Proxy#, proxy#)
6762
6863import qualified Control.Monad.Base as MB
6964import qualified Control.Monad.Trans.Control as MC
@@ -81,6 +76,11 @@ import Control.Monad.Ether.State.Class
8176import Control.Monad.Ether.Except.Class
8277import Control.Monad.Ether.Writer.Class
8378
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+
8484import qualified Control.Monad.Reader as Class
8585import qualified Control.Monad.State as Class
8686import qualified Control.Monad.Except as Class
@@ -156,47 +156,47 @@ tagReplace = coerce
156156
157157instance MonadReader tag r m
158158 => Class.MonadReader r (DispatchTagAttachT tag m) where
159− ask = let t = proxy# :: Proxy# tag in Lift.lift (ask t)
160− 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)
161161
162162instance MonadState tag s m
163163 => Class.MonadState s (DispatchTagAttachT tag m) where
164− get = let t = proxy# :: Proxy# tag in Lift.lift (get t)
165− 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
166166
167167instance MonadExcept tag e m
168168 => Class.MonadError e (DispatchTagAttachT tag m) where
169− throwError = let t = proxy# :: Proxy# tag in Lift.lift . throw t
170− 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)
171171
172172instance MonadWriter tag w m
173173 => Class.MonadWriter w (DispatchTagAttachT tag m) where
174− writer = let t = proxy# :: Proxy# tag in Lift.lift . writer t
175− tell = let t = proxy# :: Proxy# tag in Lift.lift . tell t
176− listen = let t = proxy# :: Proxy# tag in Lift.liftListen (listen t)
177− 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)
178178
179179
180180-- TagReplace instances
181181
182182instance MonadReader tNew r m
183183 => MonadReader tOld r (DispatchTagReplaceT tOld tNew m) where
184− ask _ = let t = proxy# :: Proxy# tNew in Lift.lift (ask t)
185− 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)
186186
187187instance MonadState tNew s m
188188 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
189− get _ = let t = proxy# :: Proxy# tNew in Lift.lift (get t)
190− 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
191191
192192instance MonadExcept tNew e m
193193 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
194− throw _ = let t = proxy# :: Proxy# tNew in Lift.lift . throw t
195− 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)
196196
197197instance MonadWriter tNew w m
198198 => MonadWriter tOld w (DispatchTagReplaceT tOld tNew m) where
199− writer _ = let t = proxy# :: Proxy# tNew in Lift.lift . writer t
200− tell _ = let t = proxy# :: Proxy# tNew in Lift.lift . tell t
201− listen _ = let t = proxy# :: Proxy# tNew in Lift.liftListen (listen t)
202− 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)