{-# LANGUAGE CPP #-}
module TemplateHaskell.Compat.V0208 where

import TemplateHaskell.Compat.V0208.Prelude
import Language.Haskell.TH


classP :: Name -> [Type] -> Pred
#if MIN_VERSION_template_haskell(2,10,0)
classP :: Name -> [Type] -> Type
classP Name
n [Type]
tl =
  (Type -> Type -> Type) -> Type -> [Type] -> Type
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl Type -> Type -> Type
AppT (Name -> Type
ConT Name
n) [Type]
tl
#else
classP =
  ClassP
#endif

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

dataD :: Cxt -> Name -> [UnitTyVarBndr] -> [Con] -> [Name] -> Dec
dataD :: [Type] -> Name -> [UnitTyVarBndr] -> [Con] -> [Name] -> Dec
dataD [Type]
cxt Name
name [UnitTyVarBndr]
varBndrs [Con]
cons [Name]
derivingNames =
#if MIN_VERSION_template_haskell(2,12,0)
  [Type]
-> Name
-> [UnitTyVarBndr]
-> Maybe Type
-> [Con]
-> [DerivClause]
-> Dec
DataD [Type]
cxt Name
name [UnitTyVarBndr]
varBndrs Maybe Type
forall a. Maybe a
Nothing [Con]
cons (DerivClause -> [DerivClause]
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe DerivStrategy -> [Type] -> DerivClause
DerivClause Maybe DerivStrategy
forall a. Maybe a
Nothing ((Name -> Type) -> [Name] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map Name -> Type
ConT [Name]
derivingNames)))
#elif MIN_VERSION_template_haskell(2,11,0)
  DataD cxt name varBndrs Nothing cons (map ConT derivingNames)
#else
  DataD cxt name varBndrs cons derivingNames
#endif

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

tupE :: [Exp] -> Exp
#if MIN_VERSION_template_haskell(2,16,0)
tupE :: [Exp] -> Exp
tupE = \ case
  [Exp
a] -> Exp
a
  [Exp]
a -> [Maybe Exp] -> Exp
TupE ((Exp -> Maybe Exp) -> [Exp] -> [Maybe Exp]
forall a b. (a -> b) -> [a] -> [b]
map Exp -> Maybe Exp
forall a. a -> Maybe a
Just [Exp]
a)
#else
tupE = TupE
#endif

specifiedPlainTV :: Name -> SpecificityTyVarBndr
#if MIN_VERSION_template_haskell(2,17,0)
specifiedPlainTV = flip PlainTV SpecifiedSpec
#else
specifiedPlainTV :: Name -> UnitTyVarBndr
specifiedPlainTV = Name -> UnitTyVarBndr
PlainTV
#endif

#if MIN_VERSION_template_haskell(2,17,0)
type SpecificityTyVarBndr = TyVarBndr Specificity
#else
type SpecificityTyVarBndr = TyVarBndr
#endif

#if MIN_VERSION_template_haskell(2,17,0)
type UnitTyVarBndr = TyVarBndr ()
#else
type UnitTyVarBndr = TyVarBndr
#endif

doE :: [Stmt] -> Exp
#if MIN_VERSION_template_haskell(2,17,0)
doE = DoE Nothing
#else
doE :: [Stmt] -> Exp
doE = [Stmt] -> Exp
DoE
#endif

#if MIN_VERSION_template_haskell(2,17,0)
tyVarBndrKind :: TyVarBndr flag -> Maybe Kind
tyVarBndrKind = \ case
  KindedTV _ _ a -> Just a
  _ -> Nothing
#else
tyVarBndrKind :: TyVarBndr -> Maybe Kind
tyVarBndrKind :: UnitTyVarBndr -> Maybe Type
tyVarBndrKind = \ case
  KindedTV Name
_ Type
a -> Type -> Maybe Type
forall a. a -> Maybe a
Just Type
a
  UnitTyVarBndr
_ -> Maybe Type
forall a. Maybe a
Nothing
#endif