{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
module Generics.Deriving.TH.Internal where
import Control.Monad (unless)
import Data.Char (isAlphaNum, ord)
import Data.Foldable (foldr')
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map as Map (Map)
import Data.Maybe (mapMaybe)
import qualified Data.Set as Set
import Data.Set (Set)
import Language.Haskell.TH.Datatype
import Language.Haskell.TH.Datatype.TyVarBndr
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Ppr (pprint)
import Language.Haskell.TH.Syntax
#ifndef CURRENT_PACKAGE_KEY
import Data.Version (showVersion)
import Paths_generic_deriving (version)
#endif
type TypeSubst = Map Name Type
applySubstitutionKind :: Map Name Kind -> Type -> Type
#if MIN_VERSION_template_haskell(2,8,0)
applySubstitutionKind :: Map Name Kind -> Kind -> Kind
applySubstitutionKind = Map Name Kind -> Kind -> Kind
forall a. TypeSubstitution a => Map Name Kind -> a -> a
applySubstitution
#else
applySubstitutionKind _ t = t
#endif
substNameWithKind :: Name -> Kind -> Type -> Type
substNameWithKind :: Name -> Kind -> Kind -> Kind
substNameWithKind Name
n Kind
k = Map Name Kind -> Kind -> Kind
applySubstitutionKind (Name -> Kind -> Map Name Kind
forall k a. k -> a -> Map k a
Map.singleton Name
n Kind
k)
substNamesWithKindStar :: [Name] -> Type -> Type
substNamesWithKindStar :: [Name] -> Kind -> Kind
substNamesWithKindStar [Name]
ns Kind
t = (Name -> Kind -> Kind) -> Kind -> [Name] -> Kind
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr' ((Name -> Kind -> Kind -> Kind) -> Kind -> Name -> Kind -> Kind
forall a b c. (a -> b -> c) -> b -> a -> c
flip Name -> Kind -> Kind -> Kind
substNameWithKind Kind
starK) Kind
t [Name]
ns
data StarKindStatus = NotKindStar
| KindStar
| IsKindVar Name
deriving StarKindStatus -> StarKindStatus -> Bool
(StarKindStatus -> StarKindStatus -> Bool)
-> (StarKindStatus -> StarKindStatus -> Bool) -> Eq StarKindStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StarKindStatus -> StarKindStatus -> Bool
$c/= :: StarKindStatus -> StarKindStatus -> Bool
== :: StarKindStatus -> StarKindStatus -> Bool
$c== :: StarKindStatus -> StarKindStatus -> Bool
Eq
canRealizeKindStar :: Type -> StarKindStatus
canRealizeKindStar :: Kind -> StarKindStatus
canRealizeKindStar Kind
t
| Kind -> Bool
hasKindStar Kind
t = StarKindStatus
KindStar
| Bool
otherwise = case Kind
t of
#if MIN_VERSION_template_haskell(2,8,0)
SigT Kind
_ (VarT Name
k) -> Name -> StarKindStatus
IsKindVar Name
k
#endif
Kind
_ -> StarKindStatus
NotKindStar
starKindStatusToName :: StarKindStatus -> Maybe Name
starKindStatusToName :: StarKindStatus -> Maybe Name
starKindStatusToName (IsKindVar Name
n) = Name -> Maybe Name
forall a. a -> Maybe a
Just Name
n
starKindStatusToName StarKindStatus
_ = Maybe Name
forall a. Maybe a
Nothing
catKindVarNames :: [StarKindStatus] -> [Name]
catKindVarNames :: [StarKindStatus] -> [Name]
catKindVarNames = (StarKindStatus -> Maybe Name) -> [StarKindStatus] -> [Name]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe StarKindStatus -> Maybe Name
starKindStatusToName
hasKindStar :: Type -> Bool
hasKindStar :: Kind -> Bool
hasKindStar VarT{} = Bool
True
#if MIN_VERSION_template_haskell(2,8,0)
hasKindStar (SigT Kind
_ Kind
StarT) = Bool
True
#else
hasKindStar (SigT _ StarK) = True
#endif
hasKindStar Kind
_ = Bool
False
typeToTyVarBndr :: Type -> Maybe TyVarBndrUnit
typeToTyVarBndr :: Kind -> Maybe TyVarBndrUnit
typeToTyVarBndr (VarT Name
n) = TyVarBndrUnit -> Maybe TyVarBndrUnit
forall a. a -> Maybe a
Just (Name -> TyVarBndrUnit
plainTV Name
n)
typeToTyVarBndr (SigT (VarT Name
n) Kind
k) = TyVarBndrUnit -> Maybe TyVarBndrUnit
forall a. a -> Maybe a
Just (Name -> Kind -> TyVarBndrUnit
kindedTV Name
n Kind
k)
typeToTyVarBndr Kind
_ = Maybe TyVarBndrUnit
forall a. Maybe a
Nothing
typeKind :: Type -> Kind
typeKind :: Kind -> Kind
typeKind (SigT Kind
_ Kind
k) = Kind
k
typeKind Kind
_ = Kind
starK
makeFunType :: [Type] -> Type -> Type
makeFunType :: [Kind] -> Kind -> Kind
makeFunType [Kind]
argTys Kind
resTy = (Kind -> Kind -> Kind) -> Kind -> [Kind] -> Kind
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr' (Kind -> Kind -> Kind
AppT (Kind -> Kind -> Kind) -> (Kind -> Kind) -> Kind -> Kind -> Kind
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Kind -> Kind -> Kind
AppT Kind
ArrowT) Kind
resTy [Kind]
argTys
makeFunKind :: [Kind] -> Kind -> Kind
#if MIN_VERSION_template_haskell(2,8,0)
makeFunKind :: [Kind] -> Kind -> Kind
makeFunKind = [Kind] -> Kind -> Kind
makeFunType
#else
makeFunKind argKinds resKind = foldr' ArrowK resKind argKinds
#endif
isInTypeFamilyApp :: Name -> Type -> [Type] -> Q Bool
isInTypeFamilyApp :: Name -> Kind -> [Kind] -> Q Bool
isInTypeFamilyApp Name
name Kind
tyFun [Kind]
tyArgs =
case Kind
tyFun of
ConT Name
tcName -> Name -> Q Bool
go Name
tcName
Kind
_ -> Bool -> Q Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
where
go :: Name -> Q Bool
go :: Name -> Q Bool
go Name
tcName = do
Info
info <- Name -> Q Info
reify Name
tcName
case Info
info of
#if MIN_VERSION_template_haskell(2,11,0)
FamilyI (OpenTypeFamilyD (TypeFamilyHead Name
_ [TyVarBndrUnit]
bndrs FamilyResultSig
_ Maybe InjectivityAnn
_)) [Dec]
_
-> [TyVarBndrUnit] -> Q Bool
forall a. [a] -> Q Bool
withinFirstArgs [TyVarBndrUnit]
bndrs
#elif MIN_VERSION_template_haskell(2,7,0)
FamilyI (FamilyD TypeFam _ bndrs _) _
-> withinFirstArgs bndrs
#else
TyConI (FamilyD TypeFam _ bndrs _)
-> withinFirstArgs bndrs
#endif
#if MIN_VERSION_template_haskell(2,11,0)
FamilyI (ClosedTypeFamilyD (TypeFamilyHead Name
_ [TyVarBndrUnit]
bndrs FamilyResultSig
_ Maybe InjectivityAnn
_) [TySynEqn]
_) [Dec]
_
-> [TyVarBndrUnit] -> Q Bool
forall a. [a] -> Q Bool
withinFirstArgs [TyVarBndrUnit]
bndrs
#elif MIN_VERSION_template_haskell(2,9,0)
FamilyI (ClosedTypeFamilyD _ bndrs _ _) _
-> withinFirstArgs bndrs
#endif
Info
_ -> Bool -> Q Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
where
withinFirstArgs :: [a] -> Q Bool
withinFirstArgs :: [a] -> Q Bool
withinFirstArgs [a]
bndrs =
let firstArgs :: [Kind]
firstArgs = Int -> [Kind] -> [Kind]
forall a. Int -> [a] -> [a]
take ([a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
bndrs) [Kind]
tyArgs
argFVs :: [Name]
argFVs = [Kind] -> [Name]
forall a. TypeSubstitution a => a -> [Name]
freeVariables [Kind]
firstArgs
in Bool -> Q Bool
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> Q Bool) -> Bool -> Q Bool
forall a b. (a -> b) -> a -> b
$ Name
name Name -> [Name] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Name]
argFVs
ground :: Type -> Name -> Bool
ground :: Kind -> Name -> Bool
ground Kind
ty Name
name = Name
name Name -> [Name] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` Kind -> [Name]
forall a. TypeSubstitution a => a -> [Name]
freeVariables Kind
ty
applyTyToTys :: Type -> [Type] -> Type
applyTyToTys :: Kind -> [Kind] -> Kind
applyTyToTys = (Kind -> Kind -> Kind) -> Kind -> [Kind] -> Kind
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
List.foldl' Kind -> Kind -> Kind
AppT
applyTyToTvbs :: Name -> [TyVarBndr_ flag] -> Type
applyTyToTvbs :: Name -> [TyVarBndrUnit] -> Kind
applyTyToTvbs = (Kind -> TyVarBndrUnit -> Kind) -> Kind -> [TyVarBndrUnit] -> Kind
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
List.foldl' (\Kind
a -> Kind -> Kind -> Kind
AppT Kind
a (Kind -> Kind) -> (TyVarBndrUnit -> Kind) -> TyVarBndrUnit -> Kind
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TyVarBndrUnit -> Kind
forall flag. TyVarBndrUnit -> Kind
tyVarBndrToType) (Kind -> [TyVarBndrUnit] -> Kind)
-> (Name -> Kind) -> Name -> [TyVarBndrUnit] -> Kind
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Kind
ConT
unapplyTy :: Type -> (Type, [Type])
unapplyTy :: Kind -> (Kind, [Kind])
unapplyTy Kind
ty = Kind -> Kind -> [Kind] -> (Kind, [Kind])
go Kind
ty Kind
ty []
where
go :: Type -> Type -> [Type] -> (Type, [Type])
go :: Kind -> Kind -> [Kind] -> (Kind, [Kind])
go Kind
_ (AppT Kind
ty1 Kind
ty2) [Kind]
args = Kind -> Kind -> [Kind] -> (Kind, [Kind])
go Kind
ty1 Kind
ty1 (Kind
ty2Kind -> [Kind] -> [Kind]
forall a. a -> [a] -> [a]
:[Kind]
args)
go Kind
origTy (SigT Kind
ty' Kind
_) [Kind]
args = Kind -> Kind -> [Kind] -> (Kind, [Kind])
go Kind
origTy Kind
ty' [Kind]
args
#if MIN_VERSION_template_haskell(2,11,0)
go Kind
origTy (InfixT Kind
ty1 Name
n Kind
ty2) [Kind]
args = Kind -> Kind -> [Kind] -> (Kind, [Kind])
go Kind
origTy (Name -> Kind
ConT Name
n Kind -> Kind -> Kind
`AppT` Kind
ty1 Kind -> Kind -> Kind
`AppT` Kind
ty2) [Kind]
args
go Kind
origTy (ParensT Kind
ty') [Kind]
args = Kind -> Kind -> [Kind] -> (Kind, [Kind])
go Kind
origTy Kind
ty' [Kind]
args
#endif
go Kind
origTy Kind
_ [Kind]
args = (Kind
origTy, [Kind]
args)
uncurryTy :: Type -> ([TyVarBndrSpec], [Type])
uncurryTy :: Kind -> ([TyVarBndrUnit], [Kind])
uncurryTy (AppT (AppT Kind
ArrowT Kind
t1) Kind
t2) =
let ([TyVarBndrUnit]
tvbs, [Kind]
tys) = Kind -> ([TyVarBndrUnit], [Kind])
uncurryTy Kind
t2
in ([TyVarBndrUnit]
tvbs, Kind
t1Kind -> [Kind] -> [Kind]
forall a. a -> [a] -> [a]
:[Kind]
tys)
uncurryTy (SigT Kind
t Kind
_) = Kind -> ([TyVarBndrUnit], [Kind])
uncurryTy Kind
t
uncurryTy (ForallT [TyVarBndrUnit]
tvbs [Kind]
_ Kind
t) =
let ([TyVarBndrUnit]
tvbs', [Kind]
tys) = Kind -> ([TyVarBndrUnit], [Kind])
uncurryTy Kind
t
in ([TyVarBndrUnit]
tvbs [TyVarBndrUnit] -> [TyVarBndrUnit] -> [TyVarBndrUnit]
forall a. [a] -> [a] -> [a]
++ [TyVarBndrUnit]
tvbs', [Kind]
tys)
uncurryTy Kind
t = ([], [Kind
t])
uncurryKind :: Kind -> ([TyVarBndrSpec], [Kind])
#if MIN_VERSION_template_haskell(2,8,0)
uncurryKind :: Kind -> ([TyVarBndrUnit], [Kind])
uncurryKind = Kind -> ([TyVarBndrUnit], [Kind])
uncurryTy
#else
uncurryKind (ArrowK k1 k2) =
let (kvbs, ks) = uncurryKind k2
in (kvbs, k1:ks)
uncurryKind k = ([], [k])
#endif
tyVarBndrToType :: TyVarBndr_ flag -> Type
tyVarBndrToType :: TyVarBndrUnit -> Kind
tyVarBndrToType = (Name -> Kind) -> (Name -> Kind -> Kind) -> TyVarBndrUnit -> Kind
forall r flag.
(Name -> r) -> (Name -> Kind -> r) -> TyVarBndrUnit -> r
elimTV Name -> Kind
VarT (\Name
n Kind
k -> Kind -> Kind -> Kind
SigT (Name -> Kind
VarT Name
n) Kind
k)
newNameList :: String -> Int -> Q [Name]
newNameList :: String -> Int -> Q [Name]
newNameList String
prefix Int
n = (Int -> Q Name) -> [Int] -> Q [Name]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (String -> Q Name
newName (String -> Q Name) -> (Int -> String) -> Int -> Q Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
prefix String -> String -> String
forall a. [a] -> [a] -> [a]
++) (String -> String) -> (Int -> String) -> Int -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String
forall a. Show a => a -> String
show) [Int
1..Int
n]
canEtaReduce :: [Type] -> [Type] -> Bool
canEtaReduce :: [Kind] -> [Kind] -> Bool
canEtaReduce [Kind]
remaining [Kind]
dropped =
(Kind -> Bool) -> [Kind] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Kind -> Bool
isTyVar [Kind]
dropped
Bool -> Bool -> Bool
&& [Name] -> Bool
forall a. Ord a => [a] -> Bool
allDistinct [Name]
droppedNames
Bool -> Bool -> Bool
&& Bool -> Bool
not ((Kind -> Bool) -> [Kind] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Kind -> [Name] -> Bool
`mentionsName` [Name]
droppedNames) [Kind]
remaining)
where
droppedNames :: [Name]
droppedNames :: [Name]
droppedNames = (Kind -> Name) -> [Kind] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map Kind -> Name
varTToName [Kind]
dropped
varTToName :: Type -> Name
varTToName :: Kind -> Name
varTToName (VarT Name
n) = Name
n
varTToName (SigT Kind
t Kind
_) = Kind -> Name
varTToName Kind
t
varTToName Kind
_ = String -> Name
forall a. HasCallStack => String -> a
error String
"Not a type variable!"
isTyVar :: Type -> Bool
isTyVar :: Kind -> Bool
isTyVar VarT{} = Bool
True
isTyVar (SigT Kind
t Kind
_) = Kind -> Bool
isTyVar Kind
t
isTyVar Kind
_ = Bool
False
isKindVar :: Kind -> Bool
#if MIN_VERSION_template_haskell(2,8,0)
isKindVar :: Kind -> Bool
isKindVar = Kind -> Bool
isTyVar
#else
isKindVar _ = False
#endif
isTypeMonomorphic :: Type -> Bool
isTypeMonomorphic :: Kind -> Bool
isTypeMonomorphic = Kind -> Bool
go
where
go :: Type -> Bool
go :: Kind -> Bool
go (AppT Kind
t1 Kind
t2) = Kind -> Bool
go Kind
t1 Bool -> Bool -> Bool
&& Kind -> Bool
go Kind
t2
go (SigT Kind
t Kind
_k) = Kind -> Bool
go Kind
t
#if MIN_VERSION_template_haskell(2,8,0)
Bool -> Bool -> Bool
&& Kind -> Bool
go Kind
_k
#endif
go VarT{} = Bool
False
go Kind
_ = Bool
True
unSigT :: Type -> Type
unSigT :: Kind -> Kind
unSigT (SigT Kind
t Kind
_) = Kind
t
unSigT Kind
t = Kind
t
unKindedTV :: TyVarBndrUnit -> TyVarBndrUnit
unKindedTV :: TyVarBndrUnit -> TyVarBndrUnit
unKindedTV TyVarBndrUnit
tvb = (Name -> TyVarBndrUnit)
-> (Name -> Kind -> TyVarBndrUnit)
-> TyVarBndrUnit
-> TyVarBndrUnit
forall r flag.
(Name -> r) -> (Name -> Kind -> r) -> TyVarBndrUnit -> r
elimTV (\Name
_ -> TyVarBndrUnit
tvb) (\Name
n Kind
_ -> Name -> TyVarBndrUnit
plainTV Name
n) TyVarBndrUnit
tvb
mentionsName :: Type -> [Name] -> Bool
mentionsName :: Kind -> [Name] -> Bool
mentionsName = Kind -> [Name] -> Bool
go
where
go :: Type -> [Name] -> Bool
go :: Kind -> [Name] -> Bool
go (AppT Kind
t1 Kind
t2) [Name]
names = Kind -> [Name] -> Bool
go Kind
t1 [Name]
names Bool -> Bool -> Bool
|| Kind -> [Name] -> Bool
go Kind
t2 [Name]
names
go (SigT Kind
t Kind
_k) [Name]
names = Kind -> [Name] -> Bool
go Kind
t [Name]
names
#if MIN_VERSION_template_haskell(2,8,0)
Bool -> Bool -> Bool
|| Kind -> [Name] -> Bool
go Kind
_k [Name]
names
#endif
go (VarT Name
n) [Name]
names = Name
n Name -> [Name] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Name]
names
go Kind
_ [Name]
_ = Bool
False
allDistinct :: Ord a => [a] -> Bool
allDistinct :: [a] -> Bool
allDistinct = Set a -> [a] -> Bool
forall a. Ord a => Set a -> [a] -> Bool
allDistinct' Set a
forall a. Set a
Set.empty
where
allDistinct' :: Ord a => Set a -> [a] -> Bool
allDistinct' :: Set a -> [a] -> Bool
allDistinct' Set a
uniqs (a
x:[a]
xs)
| a
x a -> Set a -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set a
uniqs = Bool
False
| Bool
otherwise = Set a -> [a] -> Bool
forall a. Ord a => Set a -> [a] -> Bool
allDistinct' (a -> Set a -> Set a
forall a. Ord a => a -> Set a -> Set a
Set.insert a
x Set a
uniqs) [a]
xs
allDistinct' Set a
_ [a]
_ = Bool
True
fst3 :: (a, b, c) -> a
fst3 :: (a, b, c) -> a
fst3 (a
a, b
_, c
_) = a
a
snd3 :: (a, b, c) -> b
snd3 :: (a, b, c) -> b
snd3 (a
_, b
b, c
_) = b
b
trd3 :: (a, b, c) -> c
trd3 :: (a, b, c) -> c
trd3 (a
_, b
_, c
c) = c
c
shrink :: (a, b, c) -> (b, c)
shrink :: (a, b, c) -> (b, c)
shrink (a
_, b
b, c
c) = (b
b, c
c)
foldBal :: (a -> a -> a) -> a -> [a] -> a
{-# INLINE foldBal #-}
foldBal :: (a -> a -> a) -> a -> [a] -> a
foldBal a -> a -> a
op0 a
x0 [a]
xs0 = (a -> a -> a) -> a -> Int -> [a] -> a
forall t. (t -> t -> t) -> t -> Int -> [t] -> t
fold_bal a -> a -> a
op0 a
x0 ([a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
xs0) [a]
xs0
where
fold_bal :: (t -> t -> t) -> t -> Int -> [t] -> t
fold_bal t -> t -> t
op t
x !Int
n [t]
xs = case [t]
xs of
[] -> t
x
[t
a] -> t
a
[t]
_ -> let !nl :: Int
nl = Int
n Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
2
!nr :: Int
nr = Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
nl
([t]
l,[t]
r) = Int -> [t] -> ([t], [t])
forall a. Int -> [a] -> ([a], [a])
splitAt Int
nl [t]
xs
in (t -> t -> t) -> t -> Int -> [t] -> t
fold_bal t -> t -> t
op t
x Int
nl [t]
l
t -> t -> t
`op` (t -> t -> t) -> t -> Int -> [t] -> t
fold_bal t -> t -> t
op t
x Int
nr [t]
r
isNewtypeVariant :: DatatypeVariant_ -> Bool
isNewtypeVariant :: DatatypeVariant_ -> Bool
isNewtypeVariant DatatypeVariant_
Datatype_ = Bool
False
isNewtypeVariant DatatypeVariant_
Newtype_ = Bool
True
isNewtypeVariant (DataInstance_ {}) = Bool
False
isNewtypeVariant (NewtypeInstance_ {}) = Bool
True
data GenericClass = Generic | Generic1 deriving Int -> GenericClass
GenericClass -> Int
GenericClass -> [GenericClass]
GenericClass -> GenericClass
GenericClass -> GenericClass -> [GenericClass]
GenericClass -> GenericClass -> GenericClass -> [GenericClass]
(GenericClass -> GenericClass)
-> (GenericClass -> GenericClass)
-> (Int -> GenericClass)
-> (GenericClass -> Int)
-> (GenericClass -> [GenericClass])
-> (GenericClass -> GenericClass -> [GenericClass])
-> (GenericClass -> GenericClass -> [GenericClass])
-> (GenericClass -> GenericClass -> GenericClass -> [GenericClass])
-> Enum GenericClass
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: GenericClass -> GenericClass -> GenericClass -> [GenericClass]
$cenumFromThenTo :: GenericClass -> GenericClass -> GenericClass -> [GenericClass]
enumFromTo :: GenericClass -> GenericClass -> [GenericClass]
$cenumFromTo :: GenericClass -> GenericClass -> [GenericClass]
enumFromThen :: GenericClass -> GenericClass -> [GenericClass]
$cenumFromThen :: GenericClass -> GenericClass -> [GenericClass]
enumFrom :: GenericClass -> [GenericClass]
$cenumFrom :: GenericClass -> [GenericClass]
fromEnum :: GenericClass -> Int
$cfromEnum :: GenericClass -> Int
toEnum :: Int -> GenericClass
$ctoEnum :: Int -> GenericClass
pred :: GenericClass -> GenericClass
$cpred :: GenericClass -> GenericClass
succ :: GenericClass -> GenericClass
$csucc :: GenericClass -> GenericClass
Enum
data GenericKind = Gen0
| Gen1 Name (Maybe Name)
genericKind :: GenericClass -> [Type] -> ([TyVarBndrUnit], GenericKind)
genericKind :: GenericClass -> [Kind] -> ([TyVarBndrUnit], GenericKind)
genericKind GenericClass
gClass [Kind]
tySynVars =
case GenericClass
gClass of
GenericClass
Generic -> ([Kind] -> [TyVarBndrUnit]
freeVariablesWellScoped [Kind]
tySynVars, GenericKind
Gen0)
GenericClass
Generic1 -> ([Kind] -> [TyVarBndrUnit]
freeVariablesWellScoped [Kind]
initArgs, Name -> Maybe Name -> GenericKind
Gen1 (Kind -> Name
varTToName Kind
lastArg) Maybe Name
mbLastArgKindName)
where
initArgs :: [Type]
initArgs :: [Kind]
initArgs = [Kind] -> [Kind]
forall a. [a] -> [a]
init [Kind]
tySynVars
lastArg :: Type
lastArg :: Kind
lastArg = [Kind] -> Kind
forall a. [a] -> a
last [Kind]
tySynVars
mbLastArgKindName :: Maybe Name
mbLastArgKindName :: Maybe Name
mbLastArgKindName = StarKindStatus -> Maybe Name
starKindStatusToName
(StarKindStatus -> Maybe Name) -> StarKindStatus -> Maybe Name
forall a b. (a -> b) -> a -> b
$ Kind -> StarKindStatus
canRealizeKindStar Kind
lastArg
data DatatypeVariant_
= Datatype_
| Newtype_
| DataInstance_ ConstructorInfo
| NewtypeInstance_ ConstructorInfo
showsDatatypeVariant :: DatatypeVariant_ -> ShowS
showsDatatypeVariant :: DatatypeVariant_ -> String -> String
showsDatatypeVariant DatatypeVariant_
variant = (String -> String -> String
forall a. [a] -> [a] -> [a]
++ Char
'_'Char -> String -> String
forall a. a -> [a] -> [a]
:String
label)
where
dataPlain :: String
dataPlain :: String
dataPlain = String
"Plain"
dataFamily :: ConstructorInfo -> String
dataFamily :: ConstructorInfo -> String
dataFamily ConstructorInfo
con = String
"Family_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
sanitizeName (Name -> String
nameBase (Name -> String) -> Name -> String
forall a b. (a -> b) -> a -> b
$ ConstructorInfo -> Name
constructorName ConstructorInfo
con)
label :: String
label :: String
label = case DatatypeVariant_
variant of
DatatypeVariant_
Datatype_ -> String
dataPlain
DatatypeVariant_
Newtype_ -> String
dataPlain
DataInstance_ ConstructorInfo
con -> ConstructorInfo -> String
dataFamily ConstructorInfo
con
NewtypeInstance_ ConstructorInfo
con -> ConstructorInfo -> String
dataFamily ConstructorInfo
con
showNameQual :: Name -> String
showNameQual :: Name -> String
showNameQual = String -> String
sanitizeName (String -> String) -> (Name -> String) -> Name -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> String
showQual
where
showQual :: Name -> String
showQual (Name OccName
_ (NameQ ModName
m)) = ModName -> String
modString ModName
m
showQual (Name OccName
_ (NameG NameSpace
_ PkgName
pkg ModName
m)) = PkgName -> String
pkgString PkgName
pkg String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
":" String -> String -> String
forall a. [a] -> [a] -> [a]
++ ModName -> String
modString ModName
m
showQual Name
_ = String
""
sanitizeName :: String -> String
sanitizeName :: String -> String
sanitizeName String
nb = Char
'N'Char -> String -> String
forall a. a -> [a] -> [a]
:(
String
nb String -> (Char -> String) -> String
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Char
x -> case Char
x of
Char
c | Char -> Bool
isAlphaNum Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\''-> [Char
c]
Char
'_' -> String
"__"
Char
c -> String
"_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (Char -> Int
ord Char
c))
etaReductionError :: Type -> Q a
etaReductionError :: Kind -> Q a
etaReductionError Kind
instanceType = String -> Q a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q a) -> String -> Q a
forall a b. (a -> b) -> a -> b
$
String
"Cannot eta-reduce to an instance of form \n\tinstance (...) => "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Kind -> String
forall a. Ppr a => a -> String
pprint Kind
instanceType
derivingKindError :: Name -> Q a
derivingKindError :: Name -> Q a
derivingKindError Name
tyConName = String -> Q a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
(String -> Q a) -> (String -> String) -> String -> Q a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
showString String
"Cannot derive well-kinded instance of form ‘Generic1 "
(String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> (String -> String) -> String -> String
showParen Bool
True
( String -> String -> String
showString (Name -> String
nameBase Name
tyConName)
(String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
showString String
" ..."
)
(String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
showString String
"‘\n\tClass Generic1 expects an argument of kind * -> *"
(String -> Q a) -> String -> Q a
forall a b. (a -> b) -> a -> b
$ String
""
outOfPlaceTyVarError :: Q a
outOfPlaceTyVarError :: Q a
outOfPlaceTyVarError = String -> Q a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
(String -> Q a) -> (String -> String) -> String -> Q a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
showString String
"Constructor must only use its last type variable as"
(String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
showString String
" the last argument of a data type"
(String -> Q a) -> String -> Q a
forall a b. (a -> b) -> a -> b
$ String
""
rankNError :: a
rankNError :: a
rankNError = String -> a
forall a. HasCallStack => String -> a
error String
"Cannot have polymorphic arguments"
reifyDataInfo :: Name
-> Q (Either String (Name, [Type], [ConstructorInfo], DatatypeVariant_))
reifyDataInfo :: Name
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
reifyDataInfo Name
name = do
Either String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
forall (m :: * -> *) a. Monad m => a -> m a
return (Either String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)))
-> Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
forall a b. (a -> b) -> a -> b
$ String
-> Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
forall a b. a -> Either a b
Left (String
-> Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
-> String
-> Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
forall a b. (a -> b) -> a -> b
$ String
ns String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" Could not reify " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Name -> String
nameBase Name
name
Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
forall a. Q a -> Q a -> Q a
`recover`
do DatatypeInfo { datatypeContext :: DatatypeInfo -> [Kind]
datatypeContext = [Kind]
ctxt
, datatypeName :: DatatypeInfo -> Name
datatypeName = Name
parentName
, datatypeInstTypes :: DatatypeInfo -> [Kind]
datatypeInstTypes = [Kind]
tys
, datatypeVariant :: DatatypeInfo -> DatatypeVariant
datatypeVariant = DatatypeVariant
variant
, datatypeCons :: DatatypeInfo -> [ConstructorInfo]
datatypeCons = [ConstructorInfo]
cons
} <- Name -> Q DatatypeInfo
reifyDatatype Name
name
let variant_ :: DatatypeVariant_
variant_ = case DatatypeVariant
variant of
DatatypeVariant
Datatype -> DatatypeVariant_
Datatype_
DatatypeVariant
Newtype -> DatatypeVariant_
Newtype_
DatatypeVariant
DataInstance -> ConstructorInfo -> DatatypeVariant_
DataInstance_ (ConstructorInfo -> DatatypeVariant_)
-> ConstructorInfo -> DatatypeVariant_
forall a b. (a -> b) -> a -> b
$ [ConstructorInfo] -> ConstructorInfo
forall a. [a] -> a
head [ConstructorInfo]
cons
DatatypeVariant
NewtypeInstance -> ConstructorInfo -> DatatypeVariant_
NewtypeInstance_ (ConstructorInfo -> DatatypeVariant_)
-> ConstructorInfo -> DatatypeVariant_
forall a b. (a -> b) -> a -> b
$ [ConstructorInfo] -> ConstructorInfo
forall a. [a] -> a
head [ConstructorInfo]
cons
Name
-> [Kind]
-> Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
forall a. Name -> [Kind] -> a -> Q a
checkDataContext Name
parentName [Kind]
ctxt (Either String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)))
-> Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
-> Q (Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_))
forall a b. (a -> b) -> a -> b
$ (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
-> Either
String (Name, [Kind], [ConstructorInfo], DatatypeVariant_)
forall a b. b -> Either a b
Right (Name
parentName, [Kind]
tys, [ConstructorInfo]
cons, DatatypeVariant_
variant_)
where
ns :: String
ns :: String
ns = String
"Generics.Deriving.TH.reifyDataInfo: "
checkDataContext :: Name -> Cxt -> a -> Q a
checkDataContext :: Name -> [Kind] -> a -> Q a
checkDataContext Name
_ [] a
x = a -> Q a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
checkDataContext Name
dataName [Kind]
_ a
_ = String -> Q a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q a) -> String -> Q a
forall a b. (a -> b) -> a -> b
$
Name -> String
nameBase Name
dataName String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" must not have a datatype context"
checkExistentialContext :: Name -> [TyVarBndrUnit] -> Cxt -> Q ()
checkExistentialContext :: Name -> [TyVarBndrUnit] -> [Kind] -> Q ()
checkExistentialContext Name
conName [TyVarBndrUnit]
vars [Kind]
ctxt =
Bool -> Q () -> Q ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([TyVarBndrUnit] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [TyVarBndrUnit]
vars Bool -> Bool -> Bool
&& [Kind] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Kind]
ctxt) (Q () -> Q ()) -> Q () -> Q ()
forall a b. (a -> b) -> a -> b
$ String -> Q ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q ()) -> String -> Q ()
forall a b. (a -> b) -> a -> b
$
Name -> String
nameBase Name
conName String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" must be a vanilla data constructor"
gdPackageKey :: String
#ifdef CURRENT_PACKAGE_KEY
gdPackageKey :: String
gdPackageKey = CURRENT_PACKAGE_KEY
#else
gdPackageKey = "generic-deriving-" ++ showVersion version
#endif
mkGD4'4_d :: String -> Name
#if MIN_VERSION_base(4,6,0)
mkGD4'4_d :: String -> Name
mkGD4'4_d = String -> String -> String -> Name
mkNameG_d String
"base" String
"GHC.Generics"
#elif MIN_VERSION_base(4,4,0)
mkGD4'4_d = mkNameG_d "ghc-prim" "GHC.Generics"
#else
mkGD4'4_d = mkNameG_d gdPackageKey "Generics.Deriving.Base.Internal"
#endif
mkGD4'9_d :: String -> Name
#if MIN_VERSION_base(4,9,0)
mkGD4'9_d :: String -> Name
mkGD4'9_d = String -> String -> String -> Name
mkNameG_d String
"base" String
"GHC.Generics"
#else
mkGD4'9_d = mkNameG_d gdPackageKey "Generics.Deriving.Base.Internal"
#endif
mkGD4'4_tc :: String -> Name
#if MIN_VERSION_base(4,6,0)
mkGD4'4_tc :: String -> Name
mkGD4'4_tc = String -> String -> String -> Name
mkNameG_tc String
"base" String
"GHC.Generics"
#elif MIN_VERSION_base(4,4,0)
mkGD4'4_tc = mkNameG_tc "ghc-prim" "GHC.Generics"
#else
mkGD4'4_tc = mkNameG_tc gdPackageKey "Generics.Deriving.Base.Internal"
#endif
mkGD4'9_tc :: String -> Name
#if MIN_VERSION_base(4,9,0)
mkGD4'9_tc :: String -> Name
mkGD4'9_tc = String -> String -> String -> Name
mkNameG_tc String
"base" String
"GHC.Generics"
#else
mkGD4'9_tc = mkNameG_tc gdPackageKey "Generics.Deriving.Base.Internal"
#endif
mkGD4'4_v :: String -> Name
#if MIN_VERSION_base(4,6,0)
mkGD4'4_v :: String -> Name
mkGD4'4_v = String -> String -> String -> Name
mkNameG_v String
"base" String
"GHC.Generics"
#elif MIN_VERSION_base(4,4,0)
mkGD4'4_v = mkNameG_v "ghc-prim" "GHC.Generics"
#else
mkGD4'4_v = mkNameG_v gdPackageKey "Generics.Deriving.Base.Internal"
#endif
mkGD4'9_v :: String -> Name
#if MIN_VERSION_base(4,9,0)
mkGD4'9_v :: String -> Name
mkGD4'9_v = String -> String -> String -> Name
mkNameG_v String
"base" String
"GHC.Generics"
#else
mkGD4'9_v = mkNameG_v gdPackageKey "Generics.Deriving.Base.Internal"
#endif
mkBaseName_d :: String -> String -> Name
mkBaseName_d :: String -> String -> Name
mkBaseName_d = String -> String -> String -> Name
mkNameG_d String
"base"
mkGHCPrimName_d :: String -> String -> Name
mkGHCPrimName_d :: String -> String -> Name
mkGHCPrimName_d = String -> String -> String -> Name
mkNameG_d String
"ghc-prim"
mkGHCPrimName_tc :: String -> String -> Name
mkGHCPrimName_tc :: String -> String -> Name
mkGHCPrimName_tc = String -> String -> String -> Name
mkNameG_tc String
"ghc-prim"
mkGHCPrimName_v :: String -> String -> Name
mkGHCPrimName_v :: String -> String -> Name
mkGHCPrimName_v = String -> String -> String -> Name
mkNameG_v String
"ghc-prim"
comp1DataName :: Name
comp1DataName :: Name
comp1DataName = String -> Name
mkGD4'4_d String
"Comp1"
infixDataName :: Name
infixDataName :: Name
infixDataName = String -> Name
mkGD4'4_d String
"Infix"
k1DataName :: Name
k1DataName :: Name
k1DataName = String -> Name
mkGD4'4_d String
"K1"
l1DataName :: Name
l1DataName :: Name
l1DataName = String -> Name
mkGD4'4_d String
"L1"
leftAssociativeDataName :: Name
leftAssociativeDataName :: Name
leftAssociativeDataName = String -> Name
mkGD4'4_d String
"LeftAssociative"
m1DataName :: Name
m1DataName :: Name
m1DataName = String -> Name
mkGD4'4_d String
"M1"
notAssociativeDataName :: Name
notAssociativeDataName :: Name
notAssociativeDataName = String -> Name
mkGD4'4_d String
"NotAssociative"
par1DataName :: Name
par1DataName :: Name
par1DataName = String -> Name
mkGD4'4_d String
"Par1"
prefixDataName :: Name
prefixDataName :: Name
prefixDataName = String -> Name
mkGD4'4_d String
"Prefix"
productDataName :: Name
productDataName :: Name
productDataName = String -> Name
mkGD4'4_d String
":*:"
r1DataName :: Name
r1DataName :: Name
r1DataName = String -> Name
mkGD4'4_d String
"R1"
rec1DataName :: Name
rec1DataName :: Name
rec1DataName = String -> Name
mkGD4'4_d String
"Rec1"
rightAssociativeDataName :: Name
rightAssociativeDataName :: Name
rightAssociativeDataName = String -> Name
mkGD4'4_d String
"RightAssociative"
u1DataName :: Name
u1DataName :: Name
u1DataName = String -> Name
mkGD4'4_d String
"U1"
uAddrDataName :: Name
uAddrDataName :: Name
uAddrDataName = String -> Name
mkGD4'9_d String
"UAddr"
uCharDataName :: Name
uCharDataName :: Name
uCharDataName = String -> Name
mkGD4'9_d String
"UChar"
uDoubleDataName :: Name
uDoubleDataName :: Name
uDoubleDataName = String -> Name
mkGD4'9_d String
"UDouble"
uFloatDataName :: Name
uFloatDataName :: Name
uFloatDataName = String -> Name
mkGD4'9_d String
"UFloat"
uIntDataName :: Name
uIntDataName :: Name
uIntDataName = String -> Name
mkGD4'9_d String
"UInt"
uWordDataName :: Name
uWordDataName :: Name
uWordDataName = String -> Name
mkGD4'9_d String
"UWord"
c1TypeName :: Name
c1TypeName :: Name
c1TypeName = String -> Name
mkGD4'4_tc String
"C1"
composeTypeName :: Name
composeTypeName :: Name
composeTypeName = String -> Name
mkGD4'4_tc String
":.:"
constructorTypeName :: Name
constructorTypeName :: Name
constructorTypeName = String -> Name
mkGD4'4_tc String
"Constructor"
d1TypeName :: Name
d1TypeName :: Name
d1TypeName = String -> Name
mkGD4'4_tc String
"D1"
genericTypeName :: Name
genericTypeName :: Name
genericTypeName = String -> Name
mkGD4'4_tc String
"Generic"
generic1TypeName :: Name
generic1TypeName :: Name
generic1TypeName = String -> Name
mkGD4'4_tc String
"Generic1"
datatypeTypeName :: Name
datatypeTypeName :: Name
datatypeTypeName = String -> Name
mkGD4'4_tc String
"Datatype"
noSelectorTypeName :: Name
noSelectorTypeName :: Name
noSelectorTypeName = String -> Name
mkGD4'4_tc String
"NoSelector"
par1TypeName :: Name
par1TypeName :: Name
par1TypeName = String -> Name
mkGD4'4_tc String
"Par1"
productTypeName :: Name
productTypeName :: Name
productTypeName = String -> Name
mkGD4'4_tc String
":*:"
rec0TypeName :: Name
rec0TypeName :: Name
rec0TypeName = String -> Name
mkGD4'4_tc String
"Rec0"
rec1TypeName :: Name
rec1TypeName :: Name
rec1TypeName = String -> Name
mkGD4'4_tc String
"Rec1"
repTypeName :: Name
repTypeName :: Name
repTypeName = String -> Name
mkGD4'4_tc String
"Rep"
rep1TypeName :: Name
rep1TypeName :: Name
rep1TypeName = String -> Name
mkGD4'4_tc String
"Rep1"
s1TypeName :: Name
s1TypeName :: Name
s1TypeName = String -> Name
mkGD4'4_tc String
"S1"
selectorTypeName :: Name
selectorTypeName :: Name
selectorTypeName = String -> Name
mkGD4'4_tc String
"Selector"
sumTypeName :: Name
sumTypeName :: Name
sumTypeName = String -> Name
mkGD4'4_tc String
":+:"
u1TypeName :: Name
u1TypeName :: Name
u1TypeName = String -> Name
mkGD4'4_tc String
"U1"
uAddrTypeName :: Name
uAddrTypeName :: Name
uAddrTypeName = String -> Name
mkGD4'9_tc String
"UAddr"
uCharTypeName :: Name
uCharTypeName :: Name
uCharTypeName = String -> Name
mkGD4'9_tc String
"UChar"
uDoubleTypeName :: Name
uDoubleTypeName :: Name
uDoubleTypeName = String -> Name
mkGD4'9_tc String
"UDouble"
uFloatTypeName :: Name
uFloatTypeName :: Name
uFloatTypeName = String -> Name
mkGD4'9_tc String
"UFloat"
uIntTypeName :: Name
uIntTypeName :: Name
uIntTypeName = String -> Name
mkGD4'9_tc String
"UInt"
uWordTypeName :: Name
uWordTypeName :: Name
uWordTypeName = String -> Name
mkGD4'9_tc String
"UWord"
v1TypeName :: Name
v1TypeName :: Name
v1TypeName = String -> Name
mkGD4'4_tc String
"V1"
conFixityValName :: Name
conFixityValName :: Name
conFixityValName = String -> Name
mkGD4'4_v String
"conFixity"
conIsRecordValName :: Name
conIsRecordValName :: Name
conIsRecordValName = String -> Name
mkGD4'4_v String
"conIsRecord"
conNameValName :: Name
conNameValName :: Name
conNameValName = String -> Name
mkGD4'4_v String
"conName"
datatypeNameValName :: Name
datatypeNameValName :: Name
datatypeNameValName = String -> Name
mkGD4'4_v String
"datatypeName"
isNewtypeValName :: Name
isNewtypeValName :: Name
isNewtypeValName = String -> Name
mkGD4'4_v String
"isNewtype"
fromValName :: Name
fromValName :: Name
fromValName = String -> Name
mkGD4'4_v String
"from"
from1ValName :: Name
from1ValName :: Name
from1ValName = String -> Name
mkGD4'4_v String
"from1"
moduleNameValName :: Name
moduleNameValName :: Name
moduleNameValName = String -> Name
mkGD4'4_v String
"moduleName"
selNameValName :: Name
selNameValName :: Name
selNameValName = String -> Name
mkGD4'4_v String
"selName"
seqValName :: Name
seqValName :: Name
seqValName = String -> String -> Name
mkGHCPrimName_v String
"GHC.Prim" String
"seq"
toValName :: Name
toValName :: Name
toValName = String -> Name
mkGD4'4_v String
"to"
to1ValName :: Name
to1ValName :: Name
to1ValName = String -> Name
mkGD4'4_v String
"to1"
uAddrHashValName :: Name
uAddrHashValName :: Name
uAddrHashValName = String -> Name
mkGD4'9_v String
"uAddr#"
uCharHashValName :: Name
uCharHashValName :: Name
uCharHashValName = String -> Name
mkGD4'9_v String
"uChar#"
uDoubleHashValName :: Name
uDoubleHashValName :: Name
uDoubleHashValName = String -> Name
mkGD4'9_v String
"uDouble#"
uFloatHashValName :: Name
uFloatHashValName :: Name
uFloatHashValName = String -> Name
mkGD4'9_v String
"uFloat#"
uIntHashValName :: Name
uIntHashValName :: Name
uIntHashValName = String -> Name
mkGD4'9_v String
"uInt#"
uWordHashValName :: Name
uWordHashValName :: Name
uWordHashValName = String -> Name
mkGD4'9_v String
"uWord#"
unComp1ValName :: Name
unComp1ValName :: Name
unComp1ValName = String -> Name
mkGD4'4_v String
"unComp1"
unK1ValName :: Name
unK1ValName :: Name
unK1ValName = String -> Name
mkGD4'4_v String
"unK1"
unPar1ValName :: Name
unPar1ValName :: Name
unPar1ValName = String -> Name
mkGD4'4_v String
"unPar1"
unRec1ValName :: Name
unRec1ValName :: Name
unRec1ValName = String -> Name
mkGD4'4_v String
"unRec1"
trueDataName, falseDataName :: Name
#if MIN_VERSION_base(4,4,0)
trueDataName :: Name
trueDataName = String -> String -> Name
mkGHCPrimName_d String
"GHC.Types" String
"True"
falseDataName :: Name
falseDataName = String -> String -> Name
mkGHCPrimName_d String
"GHC.Types" String
"False"
#else
trueDataName = mkGHCPrimName_d "GHC.Bool" "True"
falseDataName = mkGHCPrimName_d "GHC.Bool" "False"
#endif
nothingDataName, justDataName :: Name
#if MIN_VERSION_base(4,12,0)
nothingDataName :: Name
nothingDataName = String -> String -> Name
mkBaseName_d String
"GHC.Maybe" String
"Nothing"
justDataName :: Name
justDataName = String -> String -> Name
mkBaseName_d String
"GHC.Maybe" String
"Just"
#elif MIN_VERSION_base(4,8,0)
nothingDataName = mkBaseName_d "GHC.Base" "Nothing"
justDataName = mkBaseName_d "GHC.Base" "Just"
#else
nothingDataName = mkBaseName_d "Data.Maybe" "Nothing"
justDataName = mkBaseName_d "Data.Maybe" "Just"
#endif
mkGHCPrim_tc :: String -> Name
mkGHCPrim_tc :: String -> Name
mkGHCPrim_tc = String -> String -> String -> Name
mkNameG_tc String
"ghc-prim" String
"GHC.Prim"
addrHashTypeName :: Name
addrHashTypeName :: Name
addrHashTypeName = String -> Name
mkGHCPrim_tc String
"Addr#"
charHashTypeName :: Name
charHashTypeName :: Name
charHashTypeName = String -> Name
mkGHCPrim_tc String
"Char#"
doubleHashTypeName :: Name
doubleHashTypeName :: Name
doubleHashTypeName = String -> Name
mkGHCPrim_tc String
"Double#"
floatHashTypeName :: Name
floatHashTypeName :: Name
floatHashTypeName = String -> Name
mkGHCPrim_tc String
"Float#"
intHashTypeName :: Name
intHashTypeName :: Name
intHashTypeName = String -> Name
mkGHCPrim_tc String
"Int#"
wordHashTypeName :: Name
wordHashTypeName :: Name
wordHashTypeName = String -> Name
mkGHCPrim_tc String
"Word#"
composeValName :: Name
composeValName :: Name
composeValName = String -> String -> String -> Name
mkNameG_v String
"base" String
"GHC.Base" String
"."
errorValName :: Name
errorValName :: Name
errorValName = String -> String -> String -> Name
mkNameG_v String
"base" String
"GHC.Err" String
"error"
fmapValName :: Name
fmapValName :: Name
fmapValName = String -> String -> String -> Name
mkNameG_v String
"base" String
"GHC.Base" String
"fmap"
undefinedValName :: Name
undefinedValName :: Name
undefinedValName = String -> String -> String -> Name
mkNameG_v String
"base" String
"GHC.Err" String
"undefined"
decidedLazyDataName :: Name
decidedLazyDataName :: Name
decidedLazyDataName = String -> Name
mkGD4'9_d String
"DecidedLazy"
decidedStrictDataName :: Name
decidedStrictDataName :: Name
decidedStrictDataName = String -> Name
mkGD4'9_d String
"DecidedStrict"
decidedUnpackDataName :: Name
decidedUnpackDataName :: Name
decidedUnpackDataName = String -> Name
mkGD4'9_d String
"DecidedUnpack"
infixIDataName :: Name
infixIDataName :: Name
infixIDataName = String -> Name
mkGD4'9_d String
"InfixI"
metaConsDataName :: Name
metaConsDataName :: Name
metaConsDataName = String -> Name
mkGD4'9_d String
"MetaCons"
metaDataDataName :: Name
metaDataDataName :: Name
metaDataDataName = String -> Name
mkGD4'9_d String
"MetaData"
metaNoSelDataName :: Name
metaNoSelDataName :: Name
metaNoSelDataName = String -> Name
mkGD4'9_d String
"MetaNoSel"
metaSelDataName :: Name
metaSelDataName :: Name
metaSelDataName = String -> Name
mkGD4'9_d String
"MetaSel"
noSourceStrictnessDataName :: Name
noSourceStrictnessDataName :: Name
noSourceStrictnessDataName = String -> Name
mkGD4'9_d String
"NoSourceStrictness"
noSourceUnpackednessDataName :: Name
noSourceUnpackednessDataName :: Name
noSourceUnpackednessDataName = String -> Name
mkGD4'9_d String
"NoSourceUnpackedness"
prefixIDataName :: Name
prefixIDataName :: Name
prefixIDataName = String -> Name
mkGD4'9_d String
"PrefixI"
sourceLazyDataName :: Name
sourceLazyDataName :: Name
sourceLazyDataName = String -> Name
mkGD4'9_d String
"SourceLazy"
sourceNoUnpackDataName :: Name
sourceNoUnpackDataName :: Name
sourceNoUnpackDataName = String -> Name
mkGD4'9_d String
"SourceNoUnpack"
sourceStrictDataName :: Name
sourceStrictDataName :: Name
sourceStrictDataName = String -> Name
mkGD4'9_d String
"SourceStrict"
sourceUnpackDataName :: Name
sourceUnpackDataName :: Name
sourceUnpackDataName = String -> Name
mkGD4'9_d String
"SourceUnpack"
packageNameValName :: Name
packageNameValName :: Name
packageNameValName = String -> Name
mkGD4'4_v String
"packageName"