1+ {-# LANGUAGE CPP #-}
12{-# LANGUAGE TemplateHaskell #-}
23-- | Generate @generics-sop@ boilerplate instances using Template Haskell.
34module 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+
585596checkForGADTs :: TH. ConstructorInfo -> Q a -> Q a
586597checkForGADTs (ConstructorInfo { constructorVars = exVars
587598 , constructorContext = exCxt }) q = do
@@ -594,3 +605,6 @@ isNewtypeVariant Datatype = False
594605isNewtypeVariant DataInstance = False
595606isNewtypeVariant Newtype = True
596607isNewtypeVariant NewtypeInstance = True
608+ #if MIN_VERSION_th_abstraction(0,5,0)
609+ isNewtypeVariant TH. TypeData = False
610+ #endif
0 commit comments