From 0af265fa79e770137d6a3d9e72ef66a351de683b Mon Sep 17 00:00:00 2001 From: Alexandre Esteves Date: Thu, 11 Apr 2024 00:11:53 +0100 Subject: [PATCH] Build with ghc 9.8 --- aeson-gadt-th.cabal | 8 ++++---- src/Data/Aeson/GADT/TH.hs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/aeson-gadt-th.cabal b/aeson-gadt-th.cabal index bb53d58..5bd796c 100644 --- a/aeson-gadt-th.cabal +++ b/aeson-gadt-th.cabal @@ -20,13 +20,13 @@ flag build-readme library exposed-modules: Data.Aeson.GADT.TH - build-depends: base >= 4.8 && < 4.19 + build-depends: base >= 4.8 && < 4.20 , aeson >= 1.3 && < 2.3 , containers >= 0.5 && < 0.7 , dependent-sum >= 0.4 && < 0.8 , transformers >= 0.5 && < 0.7 - , template-haskell >= 2.11.0 && < 2.21 - , th-abstraction >= 0.4 && < 0.5 + , template-haskell >= 2.11.0 && < 2.22 + , th-abstraction >= 0.4 && < 0.7 if impl(ghc < 8.2) build-depends: dependent-sum < 0.6.2.2 hs-source-dirs: src @@ -39,7 +39,7 @@ executable readme build-depends: base , aeson , dependent-sum - , dependent-sum-template >= 0.1 && < 0.2 + , dependent-sum-template >= 0.2 && < 0.3 , dependent-map >= 0.3 && < 0.5 , aeson-gadt-th default-language: Haskell2010 diff --git a/src/Data/Aeson/GADT/TH.hs b/src/Data/Aeson/GADT/TH.hs index d3529a5..6f35b4e 100644 --- a/src/Data/Aeson/GADT/TH.hs +++ b/src/Data/Aeson/GADT/TH.hs @@ -45,7 +45,15 @@ import qualified Data.Set as Set import Data.Some (Some(..)) import Language.Haskell.TH hiding (cxt) import Language.Haskell.TH.Datatype (ConstructorInfo(..), applySubstitution, datatypeCons, reifyDatatype, unifyTypes) -import Language.Haskell.TH.Datatype.TyVarBndr (TyVarBndr_, tvName) +import Language.Haskell.TH.Datatype.TyVarBndr (tvName) + +#if !MIN_VERSION_template_haskell(2,21,0) +#if MIN_VERSION_th_abstraction(0,6,0) +import Language.Haskell.TH.Datatype.TyVarBndr (TyVarBndrVis) +#elseif +type TyVarBndrVis = TyVarBndr_ BndrVis +#endif +#endif #if MIN_VERSION_dependent_sum(0,5,0) #else @@ -273,7 +281,7 @@ kindArity = \case -- its declaration, and the arity of the kind of type being defined (i.e. how many more arguments would -- need to be supplied in addition to the bound parameters in order to obtain an ordinary type of kind *). -- If the supplied 'Name' is anything other than a data or newtype, produces an error. -tyConArity' :: Name -> Q ([TyVarBndr_ ()], Int) +tyConArity' :: Name -> Q ([TyVarBndrVis], Int) tyConArity' n = reify n >>= return . \case TyConI (DataD _ _ ts mk _ _) -> (ts, maybe 0 kindArity mk) TyConI (NewtypeD _ _ ts mk _ _) -> (ts, maybe 0 kindArity mk)