From 7f16a3fd68a22ff34d938973f4d2bc793490c3d7 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Thu, 3 Feb 2022 22:26:16 +0100 Subject: [PATCH] Fixed compilation with GHC 9.2 --- effectful-th/src/Effectful/TH.hs | 19 +++++++++++-------- effectful-th/tests/Fail.hs | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/effectful-th/src/Effectful/TH.hs b/effectful-th/src/Effectful/TH.hs index 31d29452..a5d97d60 100644 --- a/effectful-th/src/Effectful/TH.hs +++ b/effectful-th/src/Effectful/TH.hs @@ -75,7 +75,8 @@ makeSendFunctionFor tinfo cinfo = do let replaceEff = map (pure . replaceTV m effMonad) -- Create the function's type signature. - let bndrs = effectVarBndrs <> constructorVars cinfo <> [esBndr, rBndr] + let bndrs = map (mapTVFlag (const inferredSpec)) $ + effectVarBndrs <> constructorVars cinfo <> [esBndr, rBndr] let effect = appsT $ conT (datatypeName tinfo) : map varT effectVars effectConstraint = [t| $(effect) :> $(varT es) |] @@ -86,7 +87,7 @@ makeSendFunctionFor tinfo cinfo = do eff = [t| Eff $(varT es) $(varT r) |] funSig = arrowsT args eff - sig <- sigD fname $ forallT bndrs ctx funSig + sig <- withDoc $ sigD fname $ forallT bndrs ctx funSig -- Create the function's definition. ns <- let @@ -101,14 +102,16 @@ makeSendFunctionFor tinfo cinfo = do defn <- funD fname [clause pats body []] + pure [sig, defn] + where + withDoc :: Q Dec -> Q Dec #if MIN_VERSION_template_haskell(2,18,0) - let doc :: String - doc = "-- | Send the '" - <> show (constructorName cinfo) - <> "' effect to the effect handler." - pure [withDecDoc doc sig, defn] + withDoc = withDecDoc + $ "-- | Send the '" + <> show (constructorName cinfo) + <> "' effect to the effect handler." #else - pure [sig, defn] + withDoc = id #endif toFunctionName :: Name -> Name diff --git a/effectful-th/tests/Fail.hs b/effectful-th/tests/Fail.hs index 6f0b3151..e2b6b3a5 100644 --- a/effectful-th/tests/Fail.hs +++ b/effectful-th/tests/Fail.hs @@ -1,6 +1,8 @@ {-# LANGUAGE TemplateHaskell #-} module Fail where +import Prelude hiding (fail) + import Effectful.Fail (Fail) import Effectful.TH