@@ -1,4 +1,7 @@
1+-- The use of ImpredicativeTypes here is safe, see discussion under GitHub issue
2+-- #35. It's only needed to allow the visible type application of a polytype.
1−{-# LANGUAGE CPP #-}
3+{-# LANGUAGE ImpredicativeTypes #-}
2module Ether.TaggedTrans
5module Ether.TaggedTrans
3 ( TaggedTrans(..)
6 ( TaggedTrans(..)
@@ -30,17 +33,11 @@ import qualified Control.Monad.Error.Class as Mtl
30import GHC.Generics (Generic)
33import GHC.Generics (Generic)
31import Data.Coerce (coerce)
34import Data.Coerce (coerce)
33−#define TRAC_11837_PRESENT \
34− __GLASGOW_HASKELL__ == 800 && __GLASGOW_HASKELL_PATCHLEVEL1__ == 1
36newtype TaggedTrans tag trans m a = TaggedTrans (trans m a)
36newtype TaggedTrans tag trans m a = TaggedTrans (trans m a)
39 , Functor, Applicative, Alternative, Monad, MonadPlus
39 , Functor, Applicative, Alternative, Monad, MonadPlus
40 , MonadFix, MonadTrans, MonadIO
40 , MonadFix, MonadTrans, MonadIO
41−#if !(TRAC_11837_PRESENT)
44 , MonadThrow, MonadCatch, MonadMask )
41 , MonadThrow, MonadCatch, MonadMask )
46type Pack tag trans m a = trans m a -> TaggedTrans tag trans m a
43type Pack tag trans m a = trans m a -> TaggedTrans tag trans m a
@@ -182,15 +179,28 @@ instance
182 throwError = lift . Mtl.throwError
179 throwError = lift . Mtl.throwError
183 catchError = Lift.liftCatch Mtl.catchError
180 catchError = Lift.liftCatch Mtl.catchError
185−#if TRAC_11837_PRESENT
182+type Hoist trans =
186−-- NB: Don't use GeneralizedNewtypeDeriving to create these instances on
183+ forall m n b . Monad m =>
187−-- GHC 8.0.1, as they will trigger GHC Trac #11837
184+ (forall a . m a -> n a) -> trans m b -> trans n b
186+-- NB: Don't use GeneralizedNewtypeDeriving to create this instance, as it will
187+-- trigger GHC Trac #11837 on GHC 8.0.1 and older.
189instance MFunctor trans => MFunctor (TaggedTrans tag trans) where
188instance MFunctor trans => MFunctor (TaggedTrans tag trans) where
190− hoist f (TaggedTrans t) = TaggedTrans (hoist f t)
189+ hoist =
192+ @(Hoist (TaggedTrans tag trans))
196+ forall n m b . Monad n =>
197+ (forall a . m a -> trans n a) -> trans m b -> trans n b
199+-- NB: Don't use GeneralizedNewtypeDeriving to create this instance, as it will
200+-- trigger GHC Trac #11837 on GHC 8.0.1 and older.
192instance MMonad trans => MMonad (TaggedTrans tag trans) where
201instance MMonad trans => MMonad (TaggedTrans tag trans) where
193− embed f (TaggedTrans t) = TaggedTrans (embed (runTaggedTrans . f) t)
202+ embed =
195− runTaggedTrans (TaggedTrans x) = x
204+ @(Embed trans)
196−#endif
205+ @(Embed (TaggedTrans tag trans))