Skip to content

Commit f97eaf7

Browse files
authored
Merge pull request #160 from RyanGlScott/th-abstraction-0.5
Support building with `th-abstraction-0.5.*`
2 parents 28008e5 + 262804b commit f97eaf7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

generics-sop/generics-sop.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ library
6868
build-depends: base >= 4.9 && < 4.19,
6969
sop-core == 0.5.0.*,
7070
template-haskell >= 2.8 && < 2.21,
71-
th-abstraction >= 0.4 && < 0.5,
71+
th-abstraction >= 0.4 && < 0.6,
7272
ghc-prim >= 0.3 && < 0.11
7373
hs-source-dirs: src
7474
default-language: Haskell2010

generics-sop/src/Generics/SOP/TH.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE TemplateHaskell #-}
23
-- | Generate @generics-sop@ boilerplate instances using Template Haskell.
34
module Generics.SOP.TH
@@ -580,8 +581,18 @@ withDataDec (TH.DatatypeInfo { datatypeContext = ctxt
580581
, datatypeInstTypes = instTypes
581582
, datatypeVariant = variant
582583
, datatypeCons = cons }) f =
584+
checkForTypeData variant $
583585
f variant ctxt name bndrs instTypes cons
584586

587+
checkForTypeData :: DatatypeVariant -> Q a -> Q a
588+
checkForTypeData variant q = do
589+
case variant of
590+
#if MIN_VERSION_th_abstraction(0,5,0)
591+
TH.TypeData -> fail $ "`type data` declarations not supported"
592+
#endif
593+
_ -> return ()
594+
q
595+
585596
checkForGADTs :: TH.ConstructorInfo -> Q a -> Q a
586597
checkForGADTs (ConstructorInfo { constructorVars = exVars
587598
, constructorContext = exCxt }) q = do
@@ -594,3 +605,6 @@ isNewtypeVariant Datatype = False
594605
isNewtypeVariant DataInstance = False
595606
isNewtypeVariant Newtype = True
596607
isNewtypeVariant NewtypeInstance = True
608+
#if MIN_VERSION_th_abstraction(0,5,0)
609+
isNewtypeVariant TH.TypeData = False
610+
#endif

0 commit comments

Comments
 (0)