on master help sign in
Guard compatibility hack behind CPP
commite7ad6e0d369fe611e5754b241f8e7d2d9eeaa8ca authorRyan Scott <ryan.gl.scott@gmail.com> dateSun 21 May 2017, 20:52 (9 years ago) parent5151fe0
1 file changed+12−4
src/Ether/TaggedTrans.hs+12−4
src/Ether/TaggedTrans.hs+12−4
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12module Ether.TaggedTrans
23 ( TaggedTrans(..)
34 ) where
@@ -29,11 +30,17 @@ import qualified Control.Monad.Error.Class as Mtl
2930import GHC.Generics (Generic)
3031import Data.Coerce (coerce)
3132
33+#define TRAC_11837_PRESENT \
34+ __GLASGOW_HASKELL__ == 800 && __GLASGOW_HASKELL_PATCHLEVEL1__ == 1
35+
3236newtype TaggedTrans tag trans m a = TaggedTrans (trans m a)
3337 deriving
3438 ( Generic
3539 , Functor, Applicative, Alternative, Monad, MonadPlus
3640 , MonadFix, MonadTrans, MonadIO
41+#if !(TRAC_11837_PRESENT)
42+ , MFunctor, MMonad
43+#endif
3744 , MonadThrow, MonadCatch, MonadMask )
3845
3946type Pack tag trans m a = trans m a -> TaggedTrans tag trans m a
@@ -175,14 +182,15 @@ instance
175182 throwError = lift . Mtl.throwError
176183 catchError = Lift.liftCatch Mtl.catchError
177184
178−-- NB: Don't use GeneralizedNewtypeDeriving to create this instance, as it will
179−-- trigger GHC Trac #11837 on GHC 8.0.1 and older.
185+#if TRAC_11837_PRESENT
186+-- NB: Don't use GeneralizedNewtypeDeriving to create these instances on
187+-- GHC 8.0.1, as they will trigger GHC Trac #11837
188+
180189instance MFunctor trans => MFunctor (TaggedTrans tag trans) where
181190 hoist f (TaggedTrans t) = TaggedTrans (hoist f t)
182191
183−-- NB: Don't use GeneralizedNewtypeDeriving to create this instance, as it will
184−-- trigger GHC Trac #11837 on GHC 8.0.1 and older.
185192instance MMonad trans => MMonad (TaggedTrans tag trans) where
186193 embed f (TaggedTrans t) = TaggedTrans (embed (runTaggedTrans . f) t)
187194 where
188195 runTaggedTrans (TaggedTrans x) = x
196+#endif