Skip to content

Commit

Permalink
Support building with template-haskell-2.21.*, th-abstraction-0.6.*
Browse files Browse the repository at this point in the history
Fixes #93.
  • Loading branch information
RyanGlScott committed Aug 1, 2023
1 parent 6270495 commit 0618145
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# next [????.??.??]
* Support building with `template-haskell-2.21.*` (GHC 9.8).
* The Template Haskell machinery now uses `TemplateHaskellQuotes` when
building with GHC 8.0+ instead of manually constructing each Template Haskell
`Name`. A consequence of this is that `generic-deriving` will now build with
Expand Down
9 changes: 6 additions & 3 deletions generic-deriving.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ library

build-depends: containers >= 0.1 && < 0.7
, ghc-prim < 1
, template-haskell >= 2.4 && < 2.21
, th-abstraction >= 0.4 && < 0.6
, template-haskell >= 2.4 && < 2.22
-- TODO: Eventually, we should bump the lower version
-- bounds to >=0.6 so that we can remove some CPP in
-- Generics.Deriving.TH.Internal.
, th-abstraction >= 0.4 && < 0.7

default-language: Haskell2010
ghc-options: -Wall
Expand All @@ -150,7 +153,7 @@ test-suite spec
build-depends: base >= 4.3 && < 5
, generic-deriving
, hspec >= 2 && < 3
, template-haskell >= 2.4 && < 2.21
, template-haskell >= 2.4 && < 2.22
build-tool-depends: hspec-discover:hspec-discover
hs-source-dirs: tests
default-language: Haskell2010
Expand Down
3 changes: 2 additions & 1 deletion src/Generics/Deriving/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ import Generics.Deriving.TH.Pre4_9
#endif

import Language.Haskell.TH.Datatype
import Language.Haskell.TH.Datatype.TyVarBndr
import Language.Haskell.TH.Lib
import Language.Haskell.TH

Expand Down Expand Up @@ -314,7 +315,7 @@ deriveRepCommon gClass useKindSigs n = do
then tySynVars
else map unKindedTV tySynVars
fmap (:[]) $ tySynD (genRepName gClass dv name)
tySynVars'
(changeTVFlags bndrReq tySynVars')
(repType gt dv name Map.empty cons)

deriveInst :: GenericClass -> Options -> Name -> Q [Dec]
Expand Down
9 changes: 8 additions & 1 deletion src/Generics/Deriving/TH/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ isUnsaturatedType = go 0 . dustOff

-- | Given a name, check if that name is a type family. If
-- so, return a list of its binders.
getTypeFamilyBinders :: Name -> Q (Maybe [TyVarBndr_ ()])
getTypeFamilyBinders :: Name -> Q (Maybe [TyVarBndrVis])
getTypeFamilyBinders tcName = do
info <- reify tcName
return $ case info of
Expand Down Expand Up @@ -587,6 +587,13 @@ checkExistentialContext constrName vars ctxt =
unless (null vars && null ctxt) $ fail $
nameBase constrName ++ " must be a vanilla data constructor"

#if !(MIN_VERSION_template_haskell(2,21,0)) && !(MIN_VERSION_th_abstraction(0,6,0))
type TyVarBndrVis = TyVarBndrUnit

bndrReq :: ()
bndrReq = ()
#endif

-------------------------------------------------------------------------------
-- Quoted names
-------------------------------------------------------------------------------
Expand Down

0 comments on commit 0618145

Please sign in to comment.