Allow template-haskell 2.17, 2.18 (#34)

With a bit of CPP for backwards compatibility.

Ref https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.0#template-haskell-217
This commit is contained in:
Richard Marko 2022-01-07 20:13:38 +01:00 committed by GitHub
parent e5ef0fec4a
commit 87403cc229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -57,7 +57,7 @@ library:
dependencies:
- natural-transformation >= 0.2
- transformers-base
- template-haskell >= 2.11 && < 2.17
- template-haskell >= 2.11 && < 2.19
executables:
freer-examples:

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
@ -121,7 +122,11 @@ genType (GadtC _ tArgs' (AppT eff tRet)) = do
resultType = ConT ''Eff `AppT` VarT effs `AppT` tRet
return
#if MIN_VERSION_template_haskell(2,17,0)
. ForallT [PlainTV effs SpecifiedSpec] [memberConstraint]
#else
. ForallT [PlainTV effs] [memberConstraint]
#endif
. foldArrows
$ tArgs
++ [resultType]
@ -141,8 +146,13 @@ simplifyBndrs t = t
-- | Turn TvVarBndrs of the form (KindedTV tv StarT) into (PlainTV tv)
-- This can prevent the need for KindSignatures
#if MIN_VERSION_template_haskell(2,17,0)
simplifyBndr :: TyVarBndrSpec -> TyVarBndrSpec
simplifyBndr (KindedTV tv f StarT) = PlainTV tv f
#else
simplifyBndr :: TyVarBndr -> TyVarBndr
simplifyBndr (KindedTV tv StarT) = PlainTV tv
#endif
simplifyBndr bndr = bndr
-- | Generates a type signature of the form