@@ -1,15 +1,11 @@
1{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
1{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
3{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DeriveGeneric #-}
4−{-# LANGUAGE MultiParamTypeClasses #-}
5{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
7{-# LANGUAGE UndecidableInstances #-}
6{-# LANGUAGE UndecidableInstances #-}
8−{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE DataKinds #-}
7{-# LANGUAGE DataKinds #-}
10−{-# LANGUAGE PolyKinds #-}
11{-# LANGUAGE GeneralizedNewtypeDeriving #-}
8{-# LANGUAGE GeneralizedNewtypeDeriving #-}
12−{-# LANGUAGE MagicHash #-}
@@ -63,7 +59,6 @@ import Control.Monad.Morph (MFunctor, MMonad)
63import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
59import Control.Monad.Catch (MonadThrow, MonadCatch, MonadMask)
64import GHC.Generics (Generic)
60import GHC.Generics (Generic)
65import Data.Coerce (coerce)
61import Data.Coerce (coerce)
66−import GHC.Prim (Proxy#, proxy#)
68import qualified Control.Monad.Base as MB
63import qualified Control.Monad.Base as MB
69import qualified Control.Monad.Trans.Control as MC
64import qualified Control.Monad.Trans.Control as MC
@@ -81,6 +76,11 @@ import Control.Monad.Ether.State.Class
81import Control.Monad.Ether.Except.Class
76import Control.Monad.Ether.Except.Class
82import Control.Monad.Ether.Writer.Class
77import Control.Monad.Ether.Writer.Class
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
84import qualified Control.Monad.Reader as Class
84import qualified Control.Monad.Reader as Class
85import qualified Control.Monad.State as Class
85import qualified Control.Monad.State as Class
86import qualified Control.Monad.Except as Class
86import qualified Control.Monad.Except as Class
@@ -156,47 +156,47 @@ tagReplace = coerce
157instance MonadReader tag r m
157instance MonadReader tag r m
158 => Class.MonadReader r (DispatchTagAttachT tag m) where
158 => Class.MonadReader r (DispatchTagAttachT tag m) where
159− ask = let t = proxy# :: Proxy# tag in Lift.lift (ask t)
159+ ask = Lift.lift (A.ask @tag)
160− local = let t = proxy# :: Proxy# tag in Lift.liftLocal (ask t) (local t)
160+ local = Lift.liftLocal (A.ask @tag) (A.local @tag)
162instance MonadState tag s m
162instance MonadState tag s m
163 => Class.MonadState s (DispatchTagAttachT tag m) where
163 => Class.MonadState s (DispatchTagAttachT tag m) where
164− get = let t = proxy# :: Proxy# tag in Lift.lift (get t)
164+ get = Lift.lift (A.get @tag)
165− put = let t = proxy# :: Proxy# tag in Lift.lift . put t
165+ put = Lift.lift . A.put @tag
167instance MonadExcept tag e m
167instance MonadExcept tag e m
168 => Class.MonadError e (DispatchTagAttachT tag m) where
168 => Class.MonadError e (DispatchTagAttachT tag m) where
169− throwError = let t = proxy# :: Proxy# tag in Lift.lift . throw t
169+ throwError = Lift.lift . A.throw @tag
170− catchError = let t = proxy# :: Proxy# tag in Lift.liftCatch (catch t)
170+ catchError = Lift.liftCatch (A.catch @tag)
172instance MonadWriter tag w m
172instance MonadWriter tag w m
173 => Class.MonadWriter w (DispatchTagAttachT tag m) where
173 => Class.MonadWriter w (DispatchTagAttachT tag m) where
174− writer = let t = proxy# :: Proxy# tag in Lift.lift . writer t
174+ writer = Lift.lift . A.writer @tag
175− tell = let t = proxy# :: Proxy# tag in Lift.lift . tell t
175+ tell = Lift.lift . A.tell @tag
176− listen = let t = proxy# :: Proxy# tag in Lift.liftListen (listen t)
176+ listen = Lift.liftListen (A.listen @tag)
177− pass = let t = proxy# :: Proxy# tag in Lift.liftPass (pass t)
177+ pass = Lift.liftPass (A.pass @tag)
180-- TagReplace instances
180-- TagReplace instances
182instance MonadReader tNew r m
182instance MonadReader tNew r m
183 => MonadReader tOld r (DispatchTagReplaceT tOld tNew m) where
183 => MonadReader tOld r (DispatchTagReplaceT tOld tNew m) where
184− ask _ = let t = proxy# :: Proxy# tNew in Lift.lift (ask t)
184+ ask _ = Lift.lift (A.ask @tNew)
185− local _ = let t = proxy# :: Proxy# tNew in Lift.liftLocal (ask t) (local t)
185+ local _ = Lift.liftLocal (A.ask @tNew) (A.local @tNew)
187instance MonadState tNew s m
187instance MonadState tNew s m
188 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
188 => MonadState tOld s (DispatchTagReplaceT tOld tNew m) where
189− get _ = let t = proxy# :: Proxy# tNew in Lift.lift (get t)
189+ get _ = Lift.lift (A.get @tNew)
190− put _ = let t = proxy# :: Proxy# tNew in Lift.lift . put t
190+ put _ = Lift.lift . A.put @tNew
192instance MonadExcept tNew e m
192instance MonadExcept tNew e m
193 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
193 => MonadExcept tOld e (DispatchTagReplaceT tOld tNew m) where
194− throw _ = let t = proxy# :: Proxy# tNew in Lift.lift . throw t
194+ throw _ = Lift.lift . A.throw @tNew
195− catch _ = let t = proxy# :: Proxy# tNew in Lift.liftCatch (catch t)
195+ catch _ = Lift.liftCatch (A.catch @tNew)
197instance MonadWriter tNew w m
197instance MonadWriter tNew w m
198 => MonadWriter tOld w (DispatchTagReplaceT tOld tNew m) where
198 => MonadWriter tOld w (DispatchTagReplaceT tOld tNew m) where
199− writer _ = let t = proxy# :: Proxy# tNew in Lift.lift . writer t
199+ writer _ = Lift.lift . A.writer @tNew
200− tell _ = let t = proxy# :: Proxy# tNew in Lift.lift . tell t
200+ tell _ = Lift.lift . A.tell @tNew
201− listen _ = let t = proxy# :: Proxy# tNew in Lift.liftListen (listen t)
201+ listen _ = Lift.liftListen (A.listen @tNew)
202− pass _ = let t = proxy# :: Proxy# tNew in Lift.liftPass (pass t)
202+ pass _ = Lift.liftPass (A.pass @tNew)