{-# LANGUAGE CPP #-}
module Data.API.TH.Compat where

import Language.Haskell.TH

mkDataD :: Cxt -> Name -> [TyVarBndr] -> [Con] -> [Name] -> Dec
mkDataD :: Cxt -> Name -> [TyVarBndr] -> [Con] -> [Name] -> Dec
mkDataD Cxt
cxt1 Name
name [TyVarBndr]
tyVarBndrs [Con]
cons [Name]
drvs =
#if MIN_VERSION_template_haskell(2,12,0)
  Cxt
-> Name
-> [TyVarBndr]
-> Maybe Kind
-> [Con]
-> [DerivClause]
-> Dec
DataD Cxt
cxt1 Name
name [TyVarBndr]
tyVarBndrs Maybe Kind
forall a. Maybe a
Nothing [Con]
cons [Maybe DerivStrategy -> Cxt -> DerivClause
DerivClause Maybe DerivStrategy
forall a. Maybe a
Nothing ((Name -> Kind) -> [Name] -> Cxt
forall a b. (a -> b) -> [a] -> [b]
map Name -> Kind
ConT [Name]
drvs)]
#elif MIN_VERSION_template_haskell(2,11,0)
  DataD cxt1 name tyVarBndrs Nothing cons (map ConT drvs)
#else
  DataD cxt1 name tyVarBndrs cons drvs
#endif

mkInstanceD :: Cxt -> Type -> [Dec] -> Dec
mkInstanceD :: Cxt -> Kind -> [Dec] -> Dec
mkInstanceD =
#if MIN_VERSION_template_haskell(2,11,0)
  Maybe Overlap -> Cxt -> Kind -> [Dec] -> Dec
InstanceD Maybe Overlap
forall a. Maybe a
Nothing
#else
  InstanceD
#endif

mkNewtypeD :: Cxt -> Name -> [TyVarBndr] -> Con -> [Name] -> Dec
mkNewtypeD :: Cxt -> Name -> [TyVarBndr] -> Con -> [Name] -> Dec
mkNewtypeD Cxt
cxt1 Name
name [TyVarBndr]
tyVarBndrs Con
cons [Name]
drvs =
#if MIN_VERSION_template_haskell(2,12,0)
  Cxt
-> Name -> [TyVarBndr] -> Maybe Kind -> Con -> [DerivClause] -> Dec
NewtypeD Cxt
cxt1 Name
name [TyVarBndr]
tyVarBndrs Maybe Kind
forall a. Maybe a
Nothing Con
cons [Maybe DerivStrategy -> Cxt -> DerivClause
DerivClause Maybe DerivStrategy
forall a. Maybe a
Nothing ((Name -> Kind) -> [Name] -> Cxt
forall a b. (a -> b) -> [a] -> [b]
map Name -> Kind
ConT [Name]
drvs)]
#elif MIN_VERSION_template_haskell(2,11,0)
  NewtypeD cxt1 name tyVarBndrs Nothing cons (map ConT drvs)
#else
  NewtypeD cxt1 name tyVarBndrs cons drvs
#endif

----------------------------------------

type Strictness =
#if MIN_VERSION_template_haskell(2,11,0)
  Bang
#else
  Strict
#endif

annIsStrict :: Strictness
annIsStrict :: Strictness
annIsStrict =
#if MIN_VERSION_template_haskell(2,11,0)
  SourceUnpackedness -> SourceStrictness -> Strictness
Bang SourceUnpackedness
NoSourceUnpackedness SourceStrictness
SourceStrict
#else
  IsStrict
#endif

annNotStrict :: Strictness
annNotStrict :: Strictness
annNotStrict =
#if MIN_VERSION_template_haskell(2,11,0)
  SourceUnpackedness -> SourceStrictness -> Strictness
Bang SourceUnpackedness
NoSourceUnpackedness SourceStrictness
NoSourceStrictness
#else
  NotStrict
#endif