{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module TysWiredIn (
mkWiredInTyConName,
mkWiredInIdName,
mkFunKind, mkForAllKind,
wiredInTyCons, isBuiltInOcc_maybe,
boolTy, boolTyCon, boolTyCon_RDR, boolTyConName,
trueDataCon, trueDataConId, true_RDR,
falseDataCon, falseDataConId, false_RDR,
promotedFalseDataCon, promotedTrueDataCon,
orderingTyCon,
ordLTDataCon, ordLTDataConId,
ordEQDataCon, ordEQDataConId,
ordGTDataCon, ordGTDataConId,
promotedLTDataCon, promotedEQDataCon, promotedGTDataCon,
boxingDataCon_maybe,
charTyCon, charDataCon, charTyCon_RDR,
charTy, stringTy, charTyConName,
doubleTyCon, doubleDataCon, doubleTy, doubleTyConName,
floatTyCon, floatDataCon, floatTy, floatTyConName,
intTyCon, intDataCon, intTyCon_RDR, intDataCon_RDR, intTyConName,
intTy,
wordTyCon, wordDataCon, wordTyConName, wordTy,
word8TyCon, word8DataCon, word8TyConName, word8Ty,
listTyCon, listTyCon_RDR, listTyConName, listTyConKey,
nilDataCon, nilDataConName, nilDataConKey,
consDataCon_RDR, consDataCon, consDataConName,
promotedNilDataCon, promotedConsDataCon,
mkListTy, mkPromotedListTy,
maybeTyCon, maybeTyConName,
nothingDataCon, nothingDataConName, promotedNothingDataCon,
justDataCon, justDataConName, promotedJustDataCon,
mkTupleTy, mkBoxedTupleTy,
tupleTyCon, tupleDataCon, tupleTyConName,
promotedTupleDataCon,
unitTyCon, unitDataCon, unitDataConId, unitTy, unitTyConKey,
pairTyCon,
unboxedUnitTyCon, unboxedUnitDataCon,
unboxedTupleKind, unboxedSumKind,
cTupleTyConName, cTupleTyConNames, isCTupleTyConName,
cTupleTyConNameArity_maybe,
cTupleDataConName, cTupleDataConNames,
anyTyCon, anyTy, anyTypeOfKind,
mkSumTy, sumTyCon, sumDataCon,
typeNatKindCon, typeNatKind, typeSymbolKindCon, typeSymbolKind,
isLiftedTypeKindTyConName, liftedTypeKind, constraintKind,
liftedTypeKindTyCon, constraintKindTyCon,
liftedTypeKindTyConName,
heqTyCon, heqTyConName, heqClass, heqDataCon,
eqTyCon, eqTyConName, eqClass, eqDataCon, eqTyCon_RDR,
coercibleTyCon, coercibleTyConName, coercibleDataCon, coercibleClass,
runtimeRepTyCon, vecCountTyCon, vecElemTyCon,
runtimeRepTy, liftedRepTy, liftedRepDataCon, liftedRepDataConTyCon,
vecRepDataConTyCon, tupleRepDataConTyCon, sumRepDataConTyCon,
liftedRepDataConTy, unliftedRepDataConTy, intRepDataConTy, int8RepDataConTy,
int16RepDataConTy, word16RepDataConTy,
wordRepDataConTy, int64RepDataConTy, word8RepDataConTy, word64RepDataConTy,
addrRepDataConTy,
floatRepDataConTy, doubleRepDataConTy,
vec2DataConTy, vec4DataConTy, vec8DataConTy, vec16DataConTy, vec32DataConTy,
vec64DataConTy,
int8ElemRepDataConTy, int16ElemRepDataConTy, int32ElemRepDataConTy,
int64ElemRepDataConTy, word8ElemRepDataConTy, word16ElemRepDataConTy,
word32ElemRepDataConTy, word64ElemRepDataConTy, floatElemRepDataConTy,
doubleElemRepDataConTy
) where
#include "HsVersions.h"
#include "MachDeps.h"
import GhcPrelude
import {-# SOURCE #-} MkId( mkDataConWorkId, mkDictSelId )
import PrelNames
import TysPrim
import {-# SOURCE #-} KnownUniques
import CoAxiom
import Id
import Constants ( mAX_TUPLE_SIZE, mAX_CTUPLE_SIZE, mAX_SUM_SIZE )
import Module ( Module )
import Type
import RepType
import DataCon
import {-# SOURCE #-} ConLike
import TyCon
import Class ( Class, mkClass )
import RdrName
import Name
import NameEnv ( NameEnv, mkNameEnv, lookupNameEnv, lookupNameEnv_NF )
import NameSet ( NameSet, mkNameSet, elemNameSet )
import BasicTypes ( Arity, Boxity(..), TupleSort(..), ConTagZ,
SourceText(..) )
import ForeignCall
import SrcLoc ( noSrcSpan )
import Unique
import Data.Array
import FastString
import Outputable
import Util
import BooleanFormula ( mkAnd )
import qualified Data.ByteString.Char8 as BS
import Data.List ( elemIndex )
alpha_tyvar :: [TyVar]
alpha_tyvar :: [TyVar]
alpha_tyvar = [TyVar
alphaTyVar]
alpha_ty :: [Type]
alpha_ty :: [Type]
alpha_ty = [Type
alphaTy]
wiredInTyCons :: [TyCon]
wiredInTyCons :: [TyCon]
wiredInTyCons = [
TyCon
unitTyCon
, TyCon
unboxedUnitTyCon
, TyCon
anyTyCon
, TyCon
boolTyCon
, TyCon
charTyCon
, TyCon
doubleTyCon
, TyCon
floatTyCon
, TyCon
intTyCon
, TyCon
wordTyCon
, TyCon
word8TyCon
, TyCon
listTyCon
, TyCon
maybeTyCon
, TyCon
heqTyCon
, TyCon
eqTyCon
, TyCon
coercibleTyCon
, TyCon
typeNatKindCon
, TyCon
typeSymbolKindCon
, TyCon
runtimeRepTyCon
, TyCon
vecCountTyCon
, TyCon
vecElemTyCon
, TyCon
constraintKindTyCon
, TyCon
liftedTypeKindTyCon
]
mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName built_in :: BuiltInSyntax
built_in modu :: Module
modu fs :: FastString
fs unique :: Unique
unique tycon :: TyCon
tycon
= Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
modu (FastString -> OccName
mkTcOccFS FastString
fs) Unique
unique
(TyCon -> TyThing
ATyCon TyCon
tycon)
BuiltInSyntax
built_in
mkWiredInDataConName :: BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName :: BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName built_in :: BuiltInSyntax
built_in modu :: Module
modu fs :: FastString
fs unique :: Unique
unique datacon :: DataCon
datacon
= Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
modu (FastString -> OccName
mkDataOccFS FastString
fs) Unique
unique
(ConLike -> TyThing
AConLike (DataCon -> ConLike
RealDataCon DataCon
datacon))
BuiltInSyntax
built_in
mkWiredInIdName :: Module -> FastString -> Unique -> Id -> Name
mkWiredInIdName :: Module -> FastString -> Unique -> TyVar -> Name
mkWiredInIdName mod :: Module
mod fs :: FastString
fs uniq :: Unique
uniq id :: TyVar
id
= Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
mod (NameSpace -> FastString -> OccName
mkOccNameFS NameSpace
Name.varName FastString
fs) Unique
uniq (TyVar -> TyThing
AnId TyVar
id) BuiltInSyntax
UserSyntax
eqTyConName, eqDataConName, eqSCSelIdName :: Name
eqTyConName :: Name
eqTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "~") Unique
eqTyConKey TyCon
eqTyCon
eqDataConName :: Name
eqDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Eq#") Unique
eqDataConKey DataCon
eqDataCon
eqSCSelIdName :: Name
eqSCSelIdName = Module -> FastString -> Unique -> TyVar -> Name
mkWiredInIdName Module
gHC_TYPES (String -> FastString
fsLit "eq_sel") Unique
eqSCSelIdKey TyVar
eqSCSelId
eqTyCon_RDR :: RdrName
eqTyCon_RDR :: RdrName
eqTyCon_RDR = Name -> RdrName
nameRdrName Name
eqTyConName
heqTyConName, heqDataConName, heqSCSelIdName :: Name
heqTyConName :: Name
heqTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "~~") Unique
heqTyConKey TyCon
heqTyCon
heqDataConName :: Name
heqDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "HEq#") Unique
heqDataConKey DataCon
heqDataCon
heqSCSelIdName :: Name
heqSCSelIdName = Module -> FastString -> Unique -> TyVar -> Name
mkWiredInIdName Module
gHC_TYPES (String -> FastString
fsLit "heq_sel") Unique
heqSCSelIdKey TyVar
heqSCSelId
coercibleTyConName, coercibleDataConName, coercibleSCSelIdName :: Name
coercibleTyConName :: Name
coercibleTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Coercible") Unique
coercibleTyConKey TyCon
coercibleTyCon
coercibleDataConName :: Name
coercibleDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "MkCoercible") Unique
coercibleDataConKey DataCon
coercibleDataCon
coercibleSCSelIdName :: Name
coercibleSCSelIdName = Module -> FastString -> Unique -> TyVar -> Name
mkWiredInIdName Module
gHC_TYPES (String -> FastString
fsLit "coercible_sel") Unique
coercibleSCSelIdKey TyVar
coercibleSCSelId
charTyConName, charDataConName, intTyConName, intDataConName :: Name
charTyConName :: Name
charTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Char") Unique
charTyConKey TyCon
charTyCon
charDataConName :: Name
charDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "C#") Unique
charDataConKey DataCon
charDataCon
intTyConName :: Name
intTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Int") Unique
intTyConKey TyCon
intTyCon
intDataConName :: Name
intDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "I#") Unique
intDataConKey DataCon
intDataCon
boolTyConName, falseDataConName, trueDataConName :: Name
boolTyConName :: Name
boolTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Bool") Unique
boolTyConKey TyCon
boolTyCon
falseDataConName :: Name
falseDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "False") Unique
falseDataConKey DataCon
falseDataCon
trueDataConName :: Name
trueDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "True") Unique
trueDataConKey DataCon
trueDataCon
listTyConName, nilDataConName, consDataConName :: Name
listTyConName :: Name
listTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
BuiltInSyntax Module
gHC_TYPES (String -> FastString
fsLit "[]") Unique
listTyConKey TyCon
listTyCon
nilDataConName :: Name
nilDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
BuiltInSyntax Module
gHC_TYPES (String -> FastString
fsLit "[]") Unique
nilDataConKey DataCon
nilDataCon
consDataConName :: Name
consDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
BuiltInSyntax Module
gHC_TYPES (String -> FastString
fsLit ":") Unique
consDataConKey DataCon
consDataCon
maybeTyConName, nothingDataConName, justDataConName :: Name
maybeTyConName :: Name
maybeTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_MAYBE (String -> FastString
fsLit "Maybe")
Unique
maybeTyConKey TyCon
maybeTyCon
nothingDataConName :: Name
nothingDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_MAYBE (String -> FastString
fsLit "Nothing")
Unique
nothingDataConKey DataCon
nothingDataCon
justDataConName :: Name
justDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_MAYBE (String -> FastString
fsLit "Just")
Unique
justDataConKey DataCon
justDataCon
wordTyConName, wordDataConName, word8TyConName, word8DataConName :: Name
wordTyConName :: Name
wordTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Word") Unique
wordTyConKey TyCon
wordTyCon
wordDataConName :: Name
wordDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "W#") Unique
wordDataConKey DataCon
wordDataCon
word8TyConName :: Name
word8TyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_WORD (String -> FastString
fsLit "Word8") Unique
word8TyConKey TyCon
word8TyCon
word8DataConName :: Name
word8DataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_WORD (String -> FastString
fsLit "W8#") Unique
word8DataConKey DataCon
word8DataCon
floatTyConName, floatDataConName, doubleTyConName, doubleDataConName :: Name
floatTyConName :: Name
floatTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Float") Unique
floatTyConKey TyCon
floatTyCon
floatDataConName :: Name
floatDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "F#") Unique
floatDataConKey DataCon
floatDataCon
doubleTyConName :: Name
doubleTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Double") Unique
doubleTyConKey TyCon
doubleTyCon
doubleDataConName :: Name
doubleDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "D#") Unique
doubleDataConKey DataCon
doubleDataCon
anyTyConName :: Name
anyTyConName :: Name
anyTyConName =
BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Any") Unique
anyTyConKey TyCon
anyTyCon
anyTyCon :: TyCon
anyTyCon :: TyCon
anyTyCon = Name
-> [TyConBinder]
-> Type
-> Maybe Name
-> FamTyConFlav
-> Maybe Class
-> Injectivity
-> TyCon
mkFamilyTyCon Name
anyTyConName [TyConBinder]
binders Type
res_kind Maybe Name
forall a. Maybe a
Nothing
(Maybe (CoAxiom Branched) -> FamTyConFlav
ClosedSynFamilyTyCon Maybe (CoAxiom Branched)
forall a. Maybe a
Nothing)
Maybe Class
forall a. Maybe a
Nothing
Injectivity
NotInjective
where
binders :: [TyConBinder]
binders@[kv :: TyConBinder
kv] = [Type] -> [TyConBinder]
mkTemplateKindTyConBinders [Type
liftedTypeKind]
res_kind :: Type
res_kind = TyVar -> Type
mkTyVarTy (TyConBinder -> TyVar
forall tv argf. VarBndr tv argf -> tv
binderVar TyConBinder
kv)
anyTy :: Type
anyTy :: Type
anyTy = TyCon -> Type
mkTyConTy TyCon
anyTyCon
anyTypeOfKind :: Kind -> Type
anyTypeOfKind :: Type -> Type
anyTypeOfKind kind :: Type
kind = TyCon -> [Type] -> Type
mkTyConApp TyCon
anyTyCon [Type
kind]
typeNatKindConName, typeSymbolKindConName :: Name
typeNatKindConName :: Name
typeNatKindConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Nat") Unique
typeNatKindConNameKey TyCon
typeNatKindCon
typeSymbolKindConName :: Name
typeSymbolKindConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Symbol") Unique
typeSymbolKindConNameKey TyCon
typeSymbolKindCon
constraintKindTyConName :: Name
constraintKindTyConName :: Name
constraintKindTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Constraint") Unique
constraintKindTyConKey TyCon
constraintKindTyCon
liftedTypeKindTyConName :: Name
liftedTypeKindTyConName :: Name
liftedTypeKindTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "Type") Unique
liftedTypeKindTyConKey TyCon
liftedTypeKindTyCon
runtimeRepTyConName, vecRepDataConName, tupleRepDataConName, sumRepDataConName :: Name
runtimeRepTyConName :: Name
runtimeRepTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "RuntimeRep") Unique
runtimeRepTyConKey TyCon
runtimeRepTyCon
vecRepDataConName :: Name
vecRepDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "VecRep") Unique
vecRepDataConKey DataCon
vecRepDataCon
tupleRepDataConName :: Name
tupleRepDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "TupleRep") Unique
tupleRepDataConKey DataCon
tupleRepDataCon
sumRepDataConName :: Name
sumRepDataConName = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "SumRep") Unique
sumRepDataConKey DataCon
sumRepDataCon
runtimeRepSimpleDataConNames :: [Name]
runtimeRepSimpleDataConNames :: [Name]
runtimeRepSimpleDataConNames
= (FastString -> Unique -> DataCon -> Name)
-> [FastString] -> [Unique] -> [DataCon] -> [Name]
forall a b c d. (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
zipWith3Lazy FastString -> Unique -> DataCon -> Name
mk_special_dc_name
[ String -> FastString
fsLit "LiftedRep"
, String -> FastString
fsLit "UnliftedRep"
, String -> FastString
fsLit "IntRep"
, String -> FastString
fsLit "WordRep"
, String -> FastString
fsLit "Int8Rep"
, String -> FastString
fsLit "Int16Rep"
, String -> FastString
fsLit "Int64Rep"
, String -> FastString
fsLit "Word8Rep"
, String -> FastString
fsLit "Word16Rep"
, String -> FastString
fsLit "Word64Rep"
, String -> FastString
fsLit "AddrRep"
, String -> FastString
fsLit "FloatRep"
, String -> FastString
fsLit "DoubleRep"
]
[Unique]
runtimeRepSimpleDataConKeys
[DataCon]
runtimeRepSimpleDataCons
vecCountTyConName :: Name
vecCountTyConName :: Name
vecCountTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "VecCount") Unique
vecCountTyConKey TyCon
vecCountTyCon
vecCountDataConNames :: [Name]
vecCountDataConNames :: [Name]
vecCountDataConNames = (FastString -> Unique -> DataCon -> Name)
-> [FastString] -> [Unique] -> [DataCon] -> [Name]
forall a b c d. (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
zipWith3Lazy FastString -> Unique -> DataCon -> Name
mk_special_dc_name
[ String -> FastString
fsLit "Vec2", String -> FastString
fsLit "Vec4", String -> FastString
fsLit "Vec8"
, String -> FastString
fsLit "Vec16", String -> FastString
fsLit "Vec32", String -> FastString
fsLit "Vec64" ]
[Unique]
vecCountDataConKeys
[DataCon]
vecCountDataCons
vecElemTyConName :: Name
vecElemTyConName :: Name
vecElemTyConName = BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInTyConName BuiltInSyntax
UserSyntax Module
gHC_TYPES (String -> FastString
fsLit "VecElem") Unique
vecElemTyConKey TyCon
vecElemTyCon
vecElemDataConNames :: [Name]
vecElemDataConNames :: [Name]
vecElemDataConNames = (FastString -> Unique -> DataCon -> Name)
-> [FastString] -> [Unique] -> [DataCon] -> [Name]
forall a b c d. (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
zipWith3Lazy FastString -> Unique -> DataCon -> Name
mk_special_dc_name
[ String -> FastString
fsLit "Int8ElemRep", String -> FastString
fsLit "Int16ElemRep", String -> FastString
fsLit "Int32ElemRep"
, String -> FastString
fsLit "Int64ElemRep", String -> FastString
fsLit "Word8ElemRep", String -> FastString
fsLit "Word16ElemRep"
, String -> FastString
fsLit "Word32ElemRep", String -> FastString
fsLit "Word64ElemRep"
, String -> FastString
fsLit "FloatElemRep", String -> FastString
fsLit "DoubleElemRep" ]
[Unique]
vecElemDataConKeys
[DataCon]
vecElemDataCons
mk_special_dc_name :: FastString -> Unique -> DataCon -> Name
mk_special_dc_name :: FastString -> Unique -> DataCon -> Name
mk_special_dc_name fs :: FastString
fs u :: Unique
u dc :: DataCon
dc = BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
mkWiredInDataConName BuiltInSyntax
UserSyntax Module
gHC_TYPES FastString
fs Unique
u DataCon
dc
boolTyCon_RDR, false_RDR, true_RDR, intTyCon_RDR, charTyCon_RDR,
intDataCon_RDR, listTyCon_RDR, consDataCon_RDR :: RdrName
boolTyCon_RDR :: RdrName
boolTyCon_RDR = Name -> RdrName
nameRdrName Name
boolTyConName
false_RDR :: RdrName
false_RDR = Name -> RdrName
nameRdrName Name
falseDataConName
true_RDR :: RdrName
true_RDR = Name -> RdrName
nameRdrName Name
trueDataConName
intTyCon_RDR :: RdrName
intTyCon_RDR = Name -> RdrName
nameRdrName Name
intTyConName
charTyCon_RDR :: RdrName
charTyCon_RDR = Name -> RdrName
nameRdrName Name
charTyConName
intDataCon_RDR :: RdrName
intDataCon_RDR = Name -> RdrName
nameRdrName Name
intDataConName
listTyCon_RDR :: RdrName
listTyCon_RDR = Name -> RdrName
nameRdrName Name
listTyConName
consDataCon_RDR :: RdrName
consDataCon_RDR = Name -> RdrName
nameRdrName Name
consDataConName
pcTyCon :: Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon :: Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon name :: Name
name cType :: Maybe CType
cType tyvars :: [TyVar]
tyvars cons :: [DataCon]
cons
= Name
-> [TyConBinder]
-> Type
-> [Role]
-> Maybe CType
-> [Type]
-> AlgTyConRhs
-> AlgTyConFlav
-> Bool
-> TyCon
mkAlgTyCon Name
name
([TyVar] -> [TyConBinder]
mkAnonTyConBinders [TyVar]
tyvars)
Type
liftedTypeKind
((TyVar -> Role) -> [TyVar] -> [Role]
forall a b. (a -> b) -> [a] -> [b]
map (Role -> TyVar -> Role
forall a b. a -> b -> a
const Role
Representational) [TyVar]
tyvars)
Maybe CType
cType
[]
([DataCon] -> AlgTyConRhs
mkDataTyConRhs [DataCon]
cons)
(Name -> AlgTyConFlav
VanillaAlgTyCon (Name -> Name
mkPrelTyConRepName Name
name))
Bool
False
pcDataCon :: Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon :: Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon n :: Name
n univs :: [TyVar]
univs = Bool
-> Name
-> [TyVar]
-> [TyVar]
-> [TyVar]
-> [Type]
-> TyCon
-> DataCon
pcDataConWithFixity Bool
False Name
n [TyVar]
univs
[]
[TyVar]
univs
pcDataConWithFixity :: Bool
-> Name
-> [TyVar]
-> [TyCoVar]
-> [TyCoVar]
-> [Type]
-> TyCon
-> DataCon
pcDataConWithFixity :: Bool
-> Name
-> [TyVar]
-> [TyVar]
-> [TyVar]
-> [Type]
-> TyCon
-> DataCon
pcDataConWithFixity infx :: Bool
infx n :: Name
n = Bool
-> Name
-> Unique
-> RuntimeRepInfo
-> [TyVar]
-> [TyVar]
-> [TyVar]
-> [Type]
-> TyCon
-> DataCon
pcDataConWithFixity' Bool
infx Name
n (Unique -> Unique
dataConWorkerUnique (Name -> Unique
nameUnique Name
n))
RuntimeRepInfo
NoRRI
pcDataConWithFixity' :: Bool -> Name -> Unique -> RuntimeRepInfo
-> [TyVar] -> [TyCoVar] -> [TyCoVar]
-> [Type] -> TyCon -> DataCon
pcDataConWithFixity' :: Bool
-> Name
-> Unique
-> RuntimeRepInfo
-> [TyVar]
-> [TyVar]
-> [TyVar]
-> [Type]
-> TyCon
-> DataCon
pcDataConWithFixity' declared_infix :: Bool
declared_infix dc_name :: Name
dc_name wrk_key :: Unique
wrk_key rri :: RuntimeRepInfo
rri
tyvars :: [TyVar]
tyvars ex_tyvars :: [TyVar]
ex_tyvars user_tyvars :: [TyVar]
user_tyvars arg_tys :: [Type]
arg_tys tycon :: TyCon
tycon
= DataCon
data_con
where
tag_map :: NameEnv ConTag
tag_map = TyCon -> NameEnv ConTag
mkTyConTagMap TyCon
tycon
data_con :: DataCon
data_con = Name
-> Bool
-> Name
-> [HsSrcBang]
-> [FieldLabel]
-> [TyVar]
-> [TyVar]
-> [TyVarBinder]
-> [EqSpec]
-> [Type]
-> [Type]
-> Type
-> RuntimeRepInfo
-> TyCon
-> ConTag
-> [Type]
-> TyVar
-> DataConRep
-> DataCon
mkDataCon Name
dc_name Bool
declared_infix Name
prom_info
((Type -> HsSrcBang) -> [Type] -> [HsSrcBang]
forall a b. (a -> b) -> [a] -> [b]
map (HsSrcBang -> Type -> HsSrcBang
forall a b. a -> b -> a
const HsSrcBang
no_bang) [Type]
arg_tys)
[]
[TyVar]
tyvars [TyVar]
ex_tyvars
(ArgFlag -> [TyVar] -> [TyVarBinder]
mkTyCoVarBinders ArgFlag
Specified [TyVar]
user_tyvars)
[]
[]
[Type]
arg_tys (TyCon -> [Type] -> Type
mkTyConApp TyCon
tycon ([TyVar] -> [Type]
mkTyVarTys [TyVar]
tyvars))
RuntimeRepInfo
rri
TyCon
tycon
(NameEnv ConTag -> Name -> ConTag
forall a. NameEnv a -> Name -> a
lookupNameEnv_NF NameEnv ConTag
tag_map Name
dc_name)
[]
(Name -> DataCon -> TyVar
mkDataConWorkId Name
wrk_name DataCon
data_con)
DataConRep
NoDataConRep
no_bang :: HsSrcBang
no_bang = SourceText -> SrcUnpackedness -> SrcStrictness -> HsSrcBang
HsSrcBang SourceText
NoSourceText SrcUnpackedness
NoSrcUnpack SrcStrictness
NoSrcStrict
wrk_name :: Name
wrk_name = DataCon -> Unique -> Name
mkDataConWorkerName DataCon
data_con Unique
wrk_key
prom_info :: Name
prom_info = Name -> Name
mkPrelTyConRepName Name
dc_name
mkDataConWorkerName :: DataCon -> Unique -> Name
mkDataConWorkerName :: DataCon -> Unique -> Name
mkDataConWorkerName data_con :: DataCon
data_con wrk_key :: Unique
wrk_key =
Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
modu OccName
wrk_occ Unique
wrk_key
(TyVar -> TyThing
AnId (DataCon -> TyVar
dataConWorkId DataCon
data_con)) BuiltInSyntax
UserSyntax
where
modu :: Module
modu = ASSERT( isExternalName dc_name )
HasDebugCallStack => Name -> Module
Name -> Module
nameModule Name
dc_name
dc_name :: Name
dc_name = DataCon -> Name
dataConName DataCon
data_con
dc_occ :: OccName
dc_occ = Name -> OccName
nameOccName Name
dc_name
wrk_occ :: OccName
wrk_occ = OccName -> OccName
mkDataConWorkerOcc OccName
dc_occ
pcSpecialDataCon :: Name -> [Type] -> TyCon -> RuntimeRepInfo -> DataCon
pcSpecialDataCon :: Name -> [Type] -> TyCon -> RuntimeRepInfo -> DataCon
pcSpecialDataCon dc_name :: Name
dc_name arg_tys :: [Type]
arg_tys tycon :: TyCon
tycon rri :: RuntimeRepInfo
rri
= Bool
-> Name
-> Unique
-> RuntimeRepInfo
-> [TyVar]
-> [TyVar]
-> [TyVar]
-> [Type]
-> TyCon
-> DataCon
pcDataConWithFixity' Bool
False Name
dc_name (Unique -> Unique
dataConWorkerUnique (Name -> Unique
nameUnique Name
dc_name)) RuntimeRepInfo
rri
[] [] [] [Type]
arg_tys TyCon
tycon
typeNatKindCon, typeSymbolKindCon :: TyCon
typeNatKindCon :: TyCon
typeNatKindCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
typeNatKindConName Maybe CType
forall a. Maybe a
Nothing [] []
typeSymbolKindCon :: TyCon
typeSymbolKindCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
typeSymbolKindConName Maybe CType
forall a. Maybe a
Nothing [] []
typeNatKind, typeSymbolKind :: Kind
typeNatKind :: Type
typeNatKind = TyCon -> Type
mkTyConTy TyCon
typeNatKindCon
typeSymbolKind :: Type
typeSymbolKind = TyCon -> Type
mkTyConTy TyCon
typeSymbolKindCon
constraintKindTyCon :: TyCon
constraintKindTyCon :: TyCon
constraintKindTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
constraintKindTyConName Maybe CType
forall a. Maybe a
Nothing [] []
liftedTypeKind, constraintKind :: Kind
liftedTypeKind :: Type
liftedTypeKind = Type -> Type
tYPE Type
liftedRepTy
constraintKind :: Type
constraintKind = TyCon -> [Type] -> Type
mkTyConApp TyCon
constraintKindTyCon []
mkFunKind :: Kind -> Kind -> Kind
mkFunKind :: Type -> Type -> Type
mkFunKind = Type -> Type -> Type
mkFunTy
mkForAllKind :: TyCoVar -> ArgFlag -> Kind -> Kind
mkForAllKind :: TyVar -> ArgFlag -> Type -> Type
mkForAllKind = TyVar -> ArgFlag -> Type -> Type
mkForAllTy
isBuiltInOcc_maybe :: OccName -> Maybe Name
isBuiltInOcc_maybe :: OccName -> Maybe Name
isBuiltInOcc_maybe occ :: OccName
occ =
case ByteString
name of
"[]" -> Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> Name -> Maybe Name
forall a b. (a -> b) -> a -> b
$ Name -> Name -> Name
choose_ns Name
listTyConName Name
nilDataConName
":" -> Name -> Maybe Name
forall a. a -> Maybe a
Just Name
consDataConName
"~" -> Name -> Maybe Name
forall a. a -> Maybe a
Just Name
eqTyConName
"->" -> Name -> Maybe Name
forall a. a -> Maybe a
Just Name
funTyConName
"()" -> Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> Name -> Maybe Name
forall a b. (a -> b) -> a -> b
$ Boxity -> ConTag -> Name
tup_name Boxity
Boxed 0
_ | Just rest :: ByteString
rest <- "(" ByteString -> ByteString -> Maybe ByteString
`BS.stripPrefix` ByteString
name
, (commas :: ByteString
commas, rest' :: ByteString
rest') <- (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==',') ByteString
rest
, ByteString
")" <- ByteString
rest'
-> Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> Name -> Maybe Name
forall a b. (a -> b) -> a -> b
$ Boxity -> ConTag -> Name
tup_name Boxity
Boxed (1ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
+ByteString -> ConTag
BS.length ByteString
commas)
"(##)" -> Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> Name -> Maybe Name
forall a b. (a -> b) -> a -> b
$ Boxity -> ConTag -> Name
tup_name Boxity
Unboxed 0
"Unit#" -> Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> Name -> Maybe Name
forall a b. (a -> b) -> a -> b
$ Boxity -> ConTag -> Name
tup_name Boxity
Unboxed 1
_ | Just rest :: ByteString
rest <- "(#" ByteString -> ByteString -> Maybe ByteString
`BS.stripPrefix` ByteString
name
, (commas :: ByteString
commas, rest' :: ByteString
rest') <- (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==',') ByteString
rest
, ByteString
"#)" <- ByteString
rest'
-> Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> Name -> Maybe Name
forall a b. (a -> b) -> a -> b
$ Boxity -> ConTag -> Name
tup_name Boxity
Unboxed (1ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
+ByteString -> ConTag
BS.length ByteString
commas)
_ | Just rest :: ByteString
rest <- "(#" ByteString -> ByteString -> Maybe ByteString
`BS.stripPrefix` ByteString
name
, (pipes :: ByteString
pipes, rest' :: ByteString
rest') <- (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
=='|') ByteString
rest
, ByteString
"#)" <- ByteString
rest'
-> Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> Name -> Maybe Name
forall a b. (a -> b) -> a -> b
$ TyCon -> Name
tyConName (TyCon -> Name) -> TyCon -> Name
forall a b. (a -> b) -> a -> b
$ ConTag -> TyCon
sumTyCon (1ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
+ByteString -> ConTag
BS.length ByteString
pipes)
_ | Just rest :: ByteString
rest <- "(#" ByteString -> ByteString -> Maybe ByteString
`BS.stripPrefix` ByteString
name
, (pipes1 :: ByteString
pipes1, rest' :: ByteString
rest') <- (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
=='|') ByteString
rest
, Just rest'' :: ByteString
rest'' <- "_" ByteString -> ByteString -> Maybe ByteString
`BS.stripPrefix` ByteString
rest'
, (pipes2 :: ByteString
pipes2, rest''' :: ByteString
rest''') <- (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.span (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
=='|') ByteString
rest''
, ByteString
"#)" <- ByteString
rest'''
-> let arity :: ConTag
arity = ByteString -> ConTag
BS.length ByteString
pipes1 ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
+ ByteString -> ConTag
BS.length ByteString
pipes2 ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
+ 1
alt :: ConTag
alt = ByteString -> ConTag
BS.length ByteString
pipes1 ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
+ 1
in Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Maybe Name) -> Name -> Maybe Name
forall a b. (a -> b) -> a -> b
$ DataCon -> Name
dataConName (DataCon -> Name) -> DataCon -> Name
forall a b. (a -> b) -> a -> b
$ ConTag -> ConTag -> DataCon
sumDataCon ConTag
alt ConTag
arity
_ -> Maybe Name
forall a. Maybe a
Nothing
where
name :: ByteString
name = FastString -> ByteString
fastStringToByteString (FastString -> ByteString) -> FastString -> ByteString
forall a b. (a -> b) -> a -> b
$ OccName -> FastString
occNameFS OccName
occ
choose_ns :: Name -> Name -> Name
choose_ns :: Name -> Name -> Name
choose_ns tc :: Name
tc dc :: Name
dc
| NameSpace -> Bool
isTcClsNameSpace NameSpace
ns = Name
tc
| NameSpace -> Bool
isDataConNameSpace NameSpace
ns = Name
dc
| Bool
otherwise = String -> SDoc -> Name
forall a. HasCallStack => String -> SDoc -> a
pprPanic "tup_name" (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
occ)
where ns :: NameSpace
ns = OccName -> NameSpace
occNameSpace OccName
occ
tup_name :: Boxity -> ConTag -> Name
tup_name boxity :: Boxity
boxity arity :: ConTag
arity
= Name -> Name -> Name
choose_ns (TyCon -> Name
forall a. NamedThing a => a -> Name
getName (Boxity -> ConTag -> TyCon
tupleTyCon Boxity
boxity ConTag
arity))
(DataCon -> Name
forall a. NamedThing a => a -> Name
getName (Boxity -> ConTag -> DataCon
tupleDataCon Boxity
boxity ConTag
arity))
mkTupleOcc :: NameSpace -> Boxity -> Arity -> OccName
mkTupleOcc :: NameSpace -> Boxity -> ConTag -> OccName
mkTupleOcc ns :: NameSpace
ns Boxed ar :: ConTag
ar = NameSpace -> String -> OccName
mkOccName NameSpace
ns (ConTag -> String
mkBoxedTupleStr ConTag
ar)
mkTupleOcc ns :: NameSpace
ns Unboxed ar :: ConTag
ar = NameSpace -> String -> OccName
mkOccName NameSpace
ns (ConTag -> String
mkUnboxedTupleStr ConTag
ar)
mkCTupleOcc :: NameSpace -> Arity -> OccName
mkCTupleOcc :: NameSpace -> ConTag -> OccName
mkCTupleOcc ns :: NameSpace
ns ar :: ConTag
ar = NameSpace -> String -> OccName
mkOccName NameSpace
ns (ConTag -> String
mkConstraintTupleStr ConTag
ar)
mkBoxedTupleStr :: Arity -> String
mkBoxedTupleStr :: ConTag -> String
mkBoxedTupleStr 0 = "()"
mkBoxedTupleStr 1 = "Unit"
mkBoxedTupleStr ar :: ConTag
ar = '(' Char -> String -> String
forall a. a -> [a] -> [a]
: ConTag -> String
commas ConTag
ar String -> String -> String
forall a. [a] -> [a] -> [a]
++ ")"
mkUnboxedTupleStr :: Arity -> String
mkUnboxedTupleStr :: ConTag -> String
mkUnboxedTupleStr 0 = "(##)"
mkUnboxedTupleStr 1 = "Unit#"
mkUnboxedTupleStr ar :: ConTag
ar = "(#" String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
commas ConTag
ar String -> String -> String
forall a. [a] -> [a] -> [a]
++ "#)"
mkConstraintTupleStr :: Arity -> String
mkConstraintTupleStr :: ConTag -> String
mkConstraintTupleStr 0 = "(%%)"
mkConstraintTupleStr 1 = "Unit%"
mkConstraintTupleStr ar :: ConTag
ar = "(%" String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
commas ConTag
ar String -> String -> String
forall a. [a] -> [a] -> [a]
++ "%)"
commas :: Arity -> String
commas :: ConTag -> String
commas ar :: ConTag
ar = ConTag -> String -> String
forall a. ConTag -> [a] -> [a]
take (ConTag
arConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
-1) (Char -> String
forall a. a -> [a]
repeat ',')
cTupleTyConName :: Arity -> Name
cTupleTyConName :: ConTag -> Name
cTupleTyConName arity :: ConTag
arity
= Unique -> Module -> OccName -> SrcSpan -> Name
mkExternalName (ConTag -> Unique
mkCTupleTyConUnique ConTag
arity) Module
gHC_CLASSES
(NameSpace -> ConTag -> OccName
mkCTupleOcc NameSpace
tcName ConTag
arity) SrcSpan
noSrcSpan
cTupleTyConNames :: [Name]
cTupleTyConNames :: [Name]
cTupleTyConNames = (ConTag -> Name) -> [ConTag] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map ConTag -> Name
cTupleTyConName (0 ConTag -> [ConTag] -> [ConTag]
forall a. a -> [a] -> [a]
: [2..ConTag
mAX_CTUPLE_SIZE])
cTupleTyConNameSet :: NameSet
cTupleTyConNameSet :: NameSet
cTupleTyConNameSet = [Name] -> NameSet
mkNameSet [Name]
cTupleTyConNames
isCTupleTyConName :: Name -> Bool
isCTupleTyConName :: Name -> Bool
isCTupleTyConName n :: Name
n
= ASSERT2( isExternalName n, ppr n )
HasDebugCallStack => Name -> Module
Name -> Module
nameModule Name
n Module -> Module -> Bool
forall a. Eq a => a -> a -> Bool
== Module
gHC_CLASSES
Bool -> Bool -> Bool
&& Name
n Name -> NameSet -> Bool
`elemNameSet` NameSet
cTupleTyConNameSet
cTupleTyConNameArity_maybe :: Name -> Maybe Arity
cTupleTyConNameArity_maybe :: Name -> Maybe ConTag
cTupleTyConNameArity_maybe n :: Name
n
| Bool -> Bool
not (Name -> Bool
isCTupleTyConName Name
n) = Maybe ConTag
forall a. Maybe a
Nothing
| Bool
otherwise = (ConTag -> ConTag) -> Maybe ConTag -> Maybe ConTag
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ConTag -> ConTag
forall p. (Ord p, Num p) => p -> p
adjustArity (Name
n Name -> [Name] -> Maybe ConTag
forall a. Eq a => a -> [a] -> Maybe ConTag
`elemIndex` [Name]
cTupleTyConNames)
where
adjustArity :: p -> p
adjustArity a :: p
a = if p
a p -> p -> Bool
forall a. Ord a => a -> a -> Bool
> 0 then p
a p -> p -> p
forall a. Num a => a -> a -> a
+ 1 else p
a
cTupleDataConName :: Arity -> Name
cTupleDataConName :: ConTag -> Name
cTupleDataConName arity :: ConTag
arity
= Unique -> Module -> OccName -> SrcSpan -> Name
mkExternalName (ConTag -> Unique
mkCTupleDataConUnique ConTag
arity) Module
gHC_CLASSES
(NameSpace -> ConTag -> OccName
mkCTupleOcc NameSpace
dataName ConTag
arity) SrcSpan
noSrcSpan
cTupleDataConNames :: [Name]
cTupleDataConNames :: [Name]
cTupleDataConNames = (ConTag -> Name) -> [ConTag] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map ConTag -> Name
cTupleDataConName (0 ConTag -> [ConTag] -> [ConTag]
forall a. a -> [a] -> [a]
: [2..ConTag
mAX_CTUPLE_SIZE])
tupleTyCon :: Boxity -> Arity -> TyCon
tupleTyCon :: Boxity -> ConTag -> TyCon
tupleTyCon sort :: Boxity
sort i :: ConTag
i | ConTag
i ConTag -> ConTag -> Bool
forall a. Ord a => a -> a -> Bool
> ConTag
mAX_TUPLE_SIZE = (TyCon, DataCon) -> TyCon
forall a b. (a, b) -> a
fst (Boxity -> ConTag -> (TyCon, DataCon)
mk_tuple Boxity
sort ConTag
i)
tupleTyCon Boxed i :: ConTag
i = (TyCon, DataCon) -> TyCon
forall a b. (a, b) -> a
fst (Array ConTag (TyCon, DataCon)
boxedTupleArr Array ConTag (TyCon, DataCon) -> ConTag -> (TyCon, DataCon)
forall i e. Ix i => Array i e -> i -> e
! ConTag
i)
tupleTyCon Unboxed i :: ConTag
i = (TyCon, DataCon) -> TyCon
forall a b. (a, b) -> a
fst (Array ConTag (TyCon, DataCon)
unboxedTupleArr Array ConTag (TyCon, DataCon) -> ConTag -> (TyCon, DataCon)
forall i e. Ix i => Array i e -> i -> e
! ConTag
i)
tupleTyConName :: TupleSort -> Arity -> Name
tupleTyConName :: TupleSort -> ConTag -> Name
tupleTyConName ConstraintTuple a :: ConTag
a = ConTag -> Name
cTupleTyConName ConTag
a
tupleTyConName BoxedTuple a :: ConTag
a = TyCon -> Name
tyConName (Boxity -> ConTag -> TyCon
tupleTyCon Boxity
Boxed ConTag
a)
tupleTyConName UnboxedTuple a :: ConTag
a = TyCon -> Name
tyConName (Boxity -> ConTag -> TyCon
tupleTyCon Boxity
Unboxed ConTag
a)
promotedTupleDataCon :: Boxity -> Arity -> TyCon
promotedTupleDataCon :: Boxity -> ConTag -> TyCon
promotedTupleDataCon boxity :: Boxity
boxity i :: ConTag
i = DataCon -> TyCon
promoteDataCon (Boxity -> ConTag -> DataCon
tupleDataCon Boxity
boxity ConTag
i)
tupleDataCon :: Boxity -> Arity -> DataCon
tupleDataCon :: Boxity -> ConTag -> DataCon
tupleDataCon sort :: Boxity
sort i :: ConTag
i | ConTag
i ConTag -> ConTag -> Bool
forall a. Ord a => a -> a -> Bool
> ConTag
mAX_TUPLE_SIZE = (TyCon, DataCon) -> DataCon
forall a b. (a, b) -> b
snd (Boxity -> ConTag -> (TyCon, DataCon)
mk_tuple Boxity
sort ConTag
i)
tupleDataCon Boxed i :: ConTag
i = (TyCon, DataCon) -> DataCon
forall a b. (a, b) -> b
snd (Array ConTag (TyCon, DataCon)
boxedTupleArr Array ConTag (TyCon, DataCon) -> ConTag -> (TyCon, DataCon)
forall i e. Ix i => Array i e -> i -> e
! ConTag
i)
tupleDataCon Unboxed i :: ConTag
i = (TyCon, DataCon) -> DataCon
forall a b. (a, b) -> b
snd (Array ConTag (TyCon, DataCon)
unboxedTupleArr Array ConTag (TyCon, DataCon) -> ConTag -> (TyCon, DataCon)
forall i e. Ix i => Array i e -> i -> e
! ConTag
i)
boxedTupleArr, unboxedTupleArr :: Array Int (TyCon,DataCon)
boxedTupleArr :: Array ConTag (TyCon, DataCon)
boxedTupleArr = (ConTag, ConTag)
-> [(TyCon, DataCon)] -> Array ConTag (TyCon, DataCon)
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (0,ConTag
mAX_TUPLE_SIZE) [Boxity -> ConTag -> (TyCon, DataCon)
mk_tuple Boxity
Boxed ConTag
i | ConTag
i <- [0..ConTag
mAX_TUPLE_SIZE]]
unboxedTupleArr :: Array ConTag (TyCon, DataCon)
unboxedTupleArr = (ConTag, ConTag)
-> [(TyCon, DataCon)] -> Array ConTag (TyCon, DataCon)
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (0,ConTag
mAX_TUPLE_SIZE) [Boxity -> ConTag -> (TyCon, DataCon)
mk_tuple Boxity
Unboxed ConTag
i | ConTag
i <- [0..ConTag
mAX_TUPLE_SIZE]]
unboxedTupleSumKind :: TyCon -> [Type] -> Kind
unboxedTupleSumKind :: TyCon -> [Type] -> Type
unboxedTupleSumKind tc :: TyCon
tc rr_tys :: [Type]
rr_tys
= Type -> Type
tYPE (TyCon -> [Type] -> Type
mkTyConApp TyCon
tc [Type -> [Type] -> Type
mkPromotedListTy Type
runtimeRepTy [Type]
rr_tys])
unboxedTupleKind :: [Type] -> Kind
unboxedTupleKind :: [Type] -> Type
unboxedTupleKind = TyCon -> [Type] -> Type
unboxedTupleSumKind TyCon
tupleRepDataConTyCon
mk_tuple :: Boxity -> Int -> (TyCon,DataCon)
mk_tuple :: Boxity -> ConTag -> (TyCon, DataCon)
mk_tuple Boxed arity :: ConTag
arity = (TyCon
tycon, DataCon
tuple_con)
where
tycon :: TyCon
tycon = Name
-> [TyConBinder]
-> Type
-> ConTag
-> DataCon
-> TupleSort
-> AlgTyConFlav
-> TyCon
mkTupleTyCon Name
tc_name [TyConBinder]
tc_binders Type
tc_res_kind ConTag
tc_arity DataCon
tuple_con
TupleSort
BoxedTuple AlgTyConFlav
flavour
tc_binders :: [TyConBinder]
tc_binders = [Type] -> [TyConBinder]
mkTemplateAnonTyConBinders (ConTag -> Type -> [Type]
forall a. ConTag -> a -> [a]
nOfThem ConTag
arity Type
liftedTypeKind)
tc_res_kind :: Type
tc_res_kind = Type
liftedTypeKind
tc_arity :: ConTag
tc_arity = ConTag
arity
flavour :: AlgTyConFlav
flavour = Name -> AlgTyConFlav
VanillaAlgTyCon (Name -> Name
mkPrelTyConRepName Name
tc_name)
dc_tvs :: [TyVar]
dc_tvs = [TyConBinder] -> [TyVar]
forall tv argf. [VarBndr tv argf] -> [tv]
binderVars [TyConBinder]
tc_binders
dc_arg_tys :: [Type]
dc_arg_tys = [TyVar] -> [Type]
mkTyVarTys [TyVar]
dc_tvs
tuple_con :: DataCon
tuple_con = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
dc_name [TyVar]
dc_tvs [Type]
dc_arg_tys TyCon
tycon
boxity :: Boxity
boxity = Boxity
Boxed
modu :: Module
modu = Module
gHC_TUPLE
tc_name :: Name
tc_name = Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
modu (NameSpace -> Boxity -> ConTag -> OccName
mkTupleOcc NameSpace
tcName Boxity
boxity ConTag
arity) Unique
tc_uniq
(TyCon -> TyThing
ATyCon TyCon
tycon) BuiltInSyntax
BuiltInSyntax
dc_name :: Name
dc_name = Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
modu (NameSpace -> Boxity -> ConTag -> OccName
mkTupleOcc NameSpace
dataName Boxity
boxity ConTag
arity) Unique
dc_uniq
(ConLike -> TyThing
AConLike (DataCon -> ConLike
RealDataCon DataCon
tuple_con)) BuiltInSyntax
BuiltInSyntax
tc_uniq :: Unique
tc_uniq = Boxity -> ConTag -> Unique
mkTupleTyConUnique Boxity
boxity ConTag
arity
dc_uniq :: Unique
dc_uniq = Boxity -> ConTag -> Unique
mkTupleDataConUnique Boxity
boxity ConTag
arity
mk_tuple Unboxed arity :: ConTag
arity = (TyCon
tycon, DataCon
tuple_con)
where
tycon :: TyCon
tycon = Name
-> [TyConBinder]
-> Type
-> ConTag
-> DataCon
-> TupleSort
-> AlgTyConFlav
-> TyCon
mkTupleTyCon Name
tc_name [TyConBinder]
tc_binders Type
tc_res_kind ConTag
tc_arity DataCon
tuple_con
TupleSort
UnboxedTuple AlgTyConFlav
flavour
tc_binders :: [TyConBinder]
tc_binders = [Type] -> ([Type] -> [Type]) -> [TyConBinder]
mkTemplateTyConBinders (ConTag -> Type -> [Type]
forall a. ConTag -> a -> [a]
nOfThem ConTag
arity Type
runtimeRepTy)
(\ks :: [Type]
ks -> (Type -> Type) -> [Type] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map Type -> Type
tYPE [Type]
ks)
tc_res_kind :: Type
tc_res_kind = [Type] -> Type
unboxedTupleKind [Type]
rr_tys
tc_arity :: ConTag
tc_arity = ConTag
arity ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
* 2
flavour :: AlgTyConFlav
flavour = Maybe Name -> AlgTyConFlav
UnboxedAlgTyCon (Maybe Name -> AlgTyConFlav) -> Maybe Name -> AlgTyConFlav
forall a b. (a -> b) -> a -> b
$ Name -> Maybe Name
forall a. a -> Maybe a
Just (Name -> Name
mkPrelTyConRepName Name
tc_name)
dc_tvs :: [TyVar]
dc_tvs = [TyConBinder] -> [TyVar]
forall tv argf. [VarBndr tv argf] -> [tv]
binderVars [TyConBinder]
tc_binders
(rr_tys :: [Type]
rr_tys, dc_arg_tys :: [Type]
dc_arg_tys) = ConTag -> [Type] -> ([Type], [Type])
forall a. ConTag -> [a] -> ([a], [a])
splitAt ConTag
arity ([TyVar] -> [Type]
mkTyVarTys [TyVar]
dc_tvs)
tuple_con :: DataCon
tuple_con = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
dc_name [TyVar]
dc_tvs [Type]
dc_arg_tys TyCon
tycon
boxity :: Boxity
boxity = Boxity
Unboxed
modu :: Module
modu = Module
gHC_PRIM
tc_name :: Name
tc_name = Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
modu (NameSpace -> Boxity -> ConTag -> OccName
mkTupleOcc NameSpace
tcName Boxity
boxity ConTag
arity) Unique
tc_uniq
(TyCon -> TyThing
ATyCon TyCon
tycon) BuiltInSyntax
BuiltInSyntax
dc_name :: Name
dc_name = Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
modu (NameSpace -> Boxity -> ConTag -> OccName
mkTupleOcc NameSpace
dataName Boxity
boxity ConTag
arity) Unique
dc_uniq
(ConLike -> TyThing
AConLike (DataCon -> ConLike
RealDataCon DataCon
tuple_con)) BuiltInSyntax
BuiltInSyntax
tc_uniq :: Unique
tc_uniq = Boxity -> ConTag -> Unique
mkTupleTyConUnique Boxity
boxity ConTag
arity
dc_uniq :: Unique
dc_uniq = Boxity -> ConTag -> Unique
mkTupleDataConUnique Boxity
boxity ConTag
arity
unitTyCon :: TyCon
unitTyCon :: TyCon
unitTyCon = Boxity -> ConTag -> TyCon
tupleTyCon Boxity
Boxed 0
unitTyConKey :: Unique
unitTyConKey :: Unique
unitTyConKey = TyCon -> Unique
forall a. Uniquable a => a -> Unique
getUnique TyCon
unitTyCon
unitDataCon :: DataCon
unitDataCon :: DataCon
unitDataCon = [DataCon] -> DataCon
forall a. [a] -> a
head (TyCon -> [DataCon]
tyConDataCons TyCon
unitTyCon)
unitDataConId :: Id
unitDataConId :: TyVar
unitDataConId = DataCon -> TyVar
dataConWorkId DataCon
unitDataCon
pairTyCon :: TyCon
pairTyCon :: TyCon
pairTyCon = Boxity -> ConTag -> TyCon
tupleTyCon Boxity
Boxed 2
unboxedUnitTyCon :: TyCon
unboxedUnitTyCon :: TyCon
unboxedUnitTyCon = Boxity -> ConTag -> TyCon
tupleTyCon Boxity
Unboxed 0
unboxedUnitDataCon :: DataCon
unboxedUnitDataCon :: DataCon
unboxedUnitDataCon = Boxity -> ConTag -> DataCon
tupleDataCon Boxity
Unboxed 0
mkSumTyConOcc :: Arity -> OccName
mkSumTyConOcc :: ConTag -> OccName
mkSumTyConOcc n :: ConTag
n = NameSpace -> String -> OccName
mkOccName NameSpace
tcName String
str
where
str :: String
str = '(' Char -> String -> String
forall a. a -> [a] -> [a]
: '#' Char -> String -> String
forall a. a -> [a] -> [a]
: String
bars String -> String -> String
forall a. [a] -> [a] -> [a]
++ "#)"
bars :: String
bars = ConTag -> Char -> String
forall a. ConTag -> a -> [a]
replicate (ConTag
nConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
-1) '|'
mkSumDataConOcc :: ConTag -> Arity -> OccName
mkSumDataConOcc :: ConTag -> ConTag -> OccName
mkSumDataConOcc alt :: ConTag
alt n :: ConTag
n = NameSpace -> String -> OccName
mkOccName NameSpace
dataName String
str
where
str :: String
str = '(' Char -> String -> String
forall a. a -> [a] -> [a]
: '#' Char -> String -> String
forall a. a -> [a] -> [a]
: ConTag -> String
bars ConTag
alt String -> String -> String
forall a. [a] -> [a] -> [a]
++ '_' Char -> String -> String
forall a. a -> [a] -> [a]
: ConTag -> String
bars (ConTag
n ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
- ConTag
alt ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
- 1) String -> String -> String
forall a. [a] -> [a] -> [a]
++ "#)"
bars :: ConTag -> String
bars i :: ConTag
i = ConTag -> Char -> String
forall a. ConTag -> a -> [a]
replicate ConTag
i '|'
sumTyCon :: Arity -> TyCon
sumTyCon :: ConTag -> TyCon
sumTyCon arity :: ConTag
arity
| ConTag
arity ConTag -> ConTag -> Bool
forall a. Ord a => a -> a -> Bool
> ConTag
mAX_SUM_SIZE
= (TyCon, Array ConTag DataCon) -> TyCon
forall a b. (a, b) -> a
fst (ConTag -> (TyCon, Array ConTag DataCon)
mk_sum ConTag
arity)
| ConTag
arity ConTag -> ConTag -> Bool
forall a. Ord a => a -> a -> Bool
< 2
= String -> TyCon
forall a. String -> a
panic ("sumTyCon: Arity starts from 2. (arity: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
forall a. Show a => a -> String
show ConTag
arity String -> String -> String
forall a. [a] -> [a] -> [a]
++ ")")
| Bool
otherwise
= (TyCon, Array ConTag DataCon) -> TyCon
forall a b. (a, b) -> a
fst (Array ConTag (TyCon, Array ConTag DataCon)
unboxedSumArr Array ConTag (TyCon, Array ConTag DataCon)
-> ConTag -> (TyCon, Array ConTag DataCon)
forall i e. Ix i => Array i e -> i -> e
! ConTag
arity)
sumDataCon :: ConTag
-> Arity
-> DataCon
sumDataCon :: ConTag -> ConTag -> DataCon
sumDataCon alt :: ConTag
alt arity :: ConTag
arity
| ConTag
alt ConTag -> ConTag -> Bool
forall a. Ord a => a -> a -> Bool
> ConTag
arity
= String -> DataCon
forall a. String -> a
panic ("sumDataCon: index out of bounds: alt: "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
forall a. Show a => a -> String
show ConTag
alt String -> String -> String
forall a. [a] -> [a] -> [a]
++ " > arity " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
forall a. Show a => a -> String
show ConTag
arity)
| ConTag
alt ConTag -> ConTag -> Bool
forall a. Ord a => a -> a -> Bool
<= 0
= String -> DataCon
forall a. String -> a
panic ("sumDataCon: Alts start from 1. (alt: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
forall a. Show a => a -> String
show ConTag
alt
String -> String -> String
forall a. [a] -> [a] -> [a]
++ ", arity: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
forall a. Show a => a -> String
show ConTag
arity String -> String -> String
forall a. [a] -> [a] -> [a]
++ ")")
| ConTag
arity ConTag -> ConTag -> Bool
forall a. Ord a => a -> a -> Bool
< 2
= String -> DataCon
forall a. String -> a
panic ("sumDataCon: Arity starts from 2. (alt: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
forall a. Show a => a -> String
show ConTag
alt
String -> String -> String
forall a. [a] -> [a] -> [a]
++ ", arity: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ConTag -> String
forall a. Show a => a -> String
show ConTag
arity String -> String -> String
forall a. [a] -> [a] -> [a]
++ ")")
| ConTag
arity ConTag -> ConTag -> Bool
forall a. Ord a => a -> a -> Bool
> ConTag
mAX_SUM_SIZE
= (TyCon, Array ConTag DataCon) -> Array ConTag DataCon
forall a b. (a, b) -> b
snd (ConTag -> (TyCon, Array ConTag DataCon)
mk_sum ConTag
arity) Array ConTag DataCon -> ConTag -> DataCon
forall i e. Ix i => Array i e -> i -> e
! (ConTag
alt ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
- 1)
| Bool
otherwise
= (TyCon, Array ConTag DataCon) -> Array ConTag DataCon
forall a b. (a, b) -> b
snd (Array ConTag (TyCon, Array ConTag DataCon)
unboxedSumArr Array ConTag (TyCon, Array ConTag DataCon)
-> ConTag -> (TyCon, Array ConTag DataCon)
forall i e. Ix i => Array i e -> i -> e
! ConTag
arity) Array ConTag DataCon -> ConTag -> DataCon
forall i e. Ix i => Array i e -> i -> e
! (ConTag
alt ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
- 1)
unboxedSumArr :: Array Int (TyCon, Array Int DataCon)
unboxedSumArr :: Array ConTag (TyCon, Array ConTag DataCon)
unboxedSumArr = (ConTag, ConTag)
-> [(TyCon, Array ConTag DataCon)]
-> Array ConTag (TyCon, Array ConTag DataCon)
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (2,ConTag
mAX_SUM_SIZE) [ConTag -> (TyCon, Array ConTag DataCon)
mk_sum ConTag
i | ConTag
i <- [2..ConTag
mAX_SUM_SIZE]]
unboxedSumKind :: [Type] -> Kind
unboxedSumKind :: [Type] -> Type
unboxedSumKind = TyCon -> [Type] -> Type
unboxedTupleSumKind TyCon
sumRepDataConTyCon
mk_sum :: Arity -> (TyCon, Array ConTagZ DataCon)
mk_sum :: ConTag -> (TyCon, Array ConTag DataCon)
mk_sum arity :: ConTag
arity = (TyCon
tycon, Array ConTag DataCon
sum_cons)
where
tycon :: TyCon
tycon = Name
-> [TyConBinder]
-> Type
-> ConTag
-> [TyVar]
-> [DataCon]
-> AlgTyConFlav
-> TyCon
mkSumTyCon Name
tc_name [TyConBinder]
tc_binders Type
tc_res_kind (ConTag
arity ConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
* 2) [TyVar]
tyvars (Array ConTag DataCon -> [DataCon]
forall i e. Array i e -> [e]
elems Array ConTag DataCon
sum_cons)
(Maybe Name -> AlgTyConFlav
UnboxedAlgTyCon Maybe Name
forall a. Maybe a
rep_name)
rep_name :: Maybe a
rep_name = Maybe a
forall a. Maybe a
Nothing
tc_binders :: [TyConBinder]
tc_binders = [Type] -> ([Type] -> [Type]) -> [TyConBinder]
mkTemplateTyConBinders (ConTag -> Type -> [Type]
forall a. ConTag -> a -> [a]
nOfThem ConTag
arity Type
runtimeRepTy)
(\ks :: [Type]
ks -> (Type -> Type) -> [Type] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map Type -> Type
tYPE [Type]
ks)
tyvars :: [TyVar]
tyvars = [TyConBinder] -> [TyVar]
forall tv argf. [VarBndr tv argf] -> [tv]
binderVars [TyConBinder]
tc_binders
tc_res_kind :: Type
tc_res_kind = [Type] -> Type
unboxedSumKind [Type]
rr_tys
(rr_tys :: [Type]
rr_tys, tyvar_tys :: [Type]
tyvar_tys) = ConTag -> [Type] -> ([Type], [Type])
forall a. ConTag -> [a] -> ([a], [a])
splitAt ConTag
arity ([TyVar] -> [Type]
mkTyVarTys [TyVar]
tyvars)
tc_name :: Name
tc_name = Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
gHC_PRIM (ConTag -> OccName
mkSumTyConOcc ConTag
arity) Unique
tc_uniq
(TyCon -> TyThing
ATyCon TyCon
tycon) BuiltInSyntax
BuiltInSyntax
sum_cons :: Array ConTag DataCon
sum_cons = (ConTag, ConTag) -> [DataCon] -> Array ConTag DataCon
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (0,ConTag
arityConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
-1) [ConTag -> DataCon
sum_con ConTag
i | ConTag
i <- [0..ConTag
arityConTag -> ConTag -> ConTag
forall a. Num a => a -> a -> a
-1]]
sum_con :: ConTag -> DataCon
sum_con i :: ConTag
i = let dc :: DataCon
dc = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
dc_name
[TyVar]
tyvars
[[Type]
tyvar_tys [Type] -> ConTag -> Type
forall a. [a] -> ConTag -> a
!! ConTag
i]
TyCon
tycon
dc_name :: Name
dc_name = Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName Module
gHC_PRIM
(ConTag -> ConTag -> OccName
mkSumDataConOcc ConTag
i ConTag
arity)
(ConTag -> Unique
dc_uniq ConTag
i)
(ConLike -> TyThing
AConLike (DataCon -> ConLike
RealDataCon DataCon
dc))
BuiltInSyntax
BuiltInSyntax
in DataCon
dc
tc_uniq :: Unique
tc_uniq = ConTag -> Unique
mkSumTyConUnique ConTag
arity
dc_uniq :: ConTag -> Unique
dc_uniq i :: ConTag
i = ConTag -> ConTag -> Unique
mkSumDataConUnique ConTag
i ConTag
arity
eqTyCon, heqTyCon, coercibleTyCon :: TyCon
eqClass, heqClass, coercibleClass :: Class
eqDataCon, heqDataCon, coercibleDataCon :: DataCon
eqSCSelId, heqSCSelId, coercibleSCSelId :: Id
(eqTyCon :: TyCon
eqTyCon, eqClass :: Class
eqClass, eqDataCon :: DataCon
eqDataCon, eqSCSelId :: TyVar
eqSCSelId)
= (TyCon
tycon, Class
klass, DataCon
datacon, TyVar
sc_sel_id)
where
tycon :: TyCon
tycon = Name
-> [TyConBinder] -> [Role] -> AlgTyConRhs -> Class -> Name -> TyCon
mkClassTyCon Name
eqTyConName [TyConBinder]
binders [Role]
roles
AlgTyConRhs
rhs Class
klass
(Name -> Name
mkPrelTyConRepName Name
eqTyConName)
klass :: Class
klass = TyCon -> Type -> TyVar -> Class
mk_class TyCon
tycon Type
sc_pred TyVar
sc_sel_id
datacon :: DataCon
datacon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
eqDataConName [TyVar]
tvs [Type
sc_pred] TyCon
tycon
binders :: [TyConBinder]
binders = [Type] -> ([Type] -> [Type]) -> [TyConBinder]
mkTemplateTyConBinders [Type
liftedTypeKind] (\[k :: Type
k] -> [Type
k,Type
k])
roles :: [Role]
roles = [Role
Nominal, Role
Nominal, Role
Nominal]
rhs :: AlgTyConRhs
rhs = [DataCon] -> AlgTyConRhs
mkDataTyConRhs [DataCon
datacon]
tvs :: [TyVar]
tvs@[k :: TyVar
k,a :: TyVar
a,b :: TyVar
b] = [TyConBinder] -> [TyVar]
forall tv argf. [VarBndr tv argf] -> [tv]
binderVars [TyConBinder]
binders
sc_pred :: Type
sc_pred = TyCon -> [Type] -> Type
mkTyConApp TyCon
eqPrimTyCon ([TyVar] -> [Type]
mkTyVarTys [TyVar
k,TyVar
k,TyVar
a,TyVar
b])
sc_sel_id :: TyVar
sc_sel_id = Name -> Class -> TyVar
mkDictSelId Name
eqSCSelIdName Class
klass
(heqTyCon :: TyCon
heqTyCon, heqClass :: Class
heqClass, heqDataCon :: DataCon
heqDataCon, heqSCSelId :: TyVar
heqSCSelId)
= (TyCon
tycon, Class
klass, DataCon
datacon, TyVar
sc_sel_id)
where
tycon :: TyCon
tycon = Name
-> [TyConBinder] -> [Role] -> AlgTyConRhs -> Class -> Name -> TyCon
mkClassTyCon Name
heqTyConName [TyConBinder]
binders [Role]
roles
AlgTyConRhs
rhs Class
klass
(Name -> Name
mkPrelTyConRepName Name
heqTyConName)
klass :: Class
klass = TyCon -> Type -> TyVar -> Class
mk_class TyCon
tycon Type
sc_pred TyVar
sc_sel_id
datacon :: DataCon
datacon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
heqDataConName [TyVar]
tvs [Type
sc_pred] TyCon
tycon
binders :: [TyConBinder]
binders = [Type] -> ([Type] -> [Type]) -> [TyConBinder]
mkTemplateTyConBinders [Type
liftedTypeKind, Type
liftedTypeKind] [Type] -> [Type]
forall a. a -> a
id
roles :: [Role]
roles = [Role
Nominal, Role
Nominal, Role
Nominal, Role
Nominal]
rhs :: AlgTyConRhs
rhs = [DataCon] -> AlgTyConRhs
mkDataTyConRhs [DataCon
datacon]
tvs :: [TyVar]
tvs = [TyConBinder] -> [TyVar]
forall tv argf. [VarBndr tv argf] -> [tv]
binderVars [TyConBinder]
binders
sc_pred :: Type
sc_pred = TyCon -> [Type] -> Type
mkTyConApp TyCon
eqPrimTyCon ([TyVar] -> [Type]
mkTyVarTys [TyVar]
tvs)
sc_sel_id :: TyVar
sc_sel_id = Name -> Class -> TyVar
mkDictSelId Name
heqSCSelIdName Class
klass
(coercibleTyCon :: TyCon
coercibleTyCon, coercibleClass :: Class
coercibleClass, coercibleDataCon :: DataCon
coercibleDataCon, coercibleSCSelId :: TyVar
coercibleSCSelId)
= (TyCon
tycon, Class
klass, DataCon
datacon, TyVar
sc_sel_id)
where
tycon :: TyCon
tycon = Name
-> [TyConBinder] -> [Role] -> AlgTyConRhs -> Class -> Name -> TyCon
mkClassTyCon Name
coercibleTyConName [TyConBinder]
binders [Role]
roles
AlgTyConRhs
rhs Class
klass
(Name -> Name
mkPrelTyConRepName Name
coercibleTyConName)
klass :: Class
klass = TyCon -> Type -> TyVar -> Class
mk_class TyCon
tycon Type
sc_pred TyVar
sc_sel_id
datacon :: DataCon
datacon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
coercibleDataConName [TyVar]
tvs [Type
sc_pred] TyCon
tycon
binders :: [TyConBinder]
binders = [Type] -> ([Type] -> [Type]) -> [TyConBinder]
mkTemplateTyConBinders [Type
liftedTypeKind] (\[k :: Type
k] -> [Type
k,Type
k])
roles :: [Role]
roles = [Role
Nominal, Role
Representational, Role
Representational]
rhs :: AlgTyConRhs
rhs = [DataCon] -> AlgTyConRhs
mkDataTyConRhs [DataCon
datacon]
tvs :: [TyVar]
tvs@[k :: TyVar
k,a :: TyVar
a,b :: TyVar
b] = [TyConBinder] -> [TyVar]
forall tv argf. [VarBndr tv argf] -> [tv]
binderVars [TyConBinder]
binders
sc_pred :: Type
sc_pred = TyCon -> [Type] -> Type
mkTyConApp TyCon
eqReprPrimTyCon ([TyVar] -> [Type]
mkTyVarTys [TyVar
k, TyVar
k, TyVar
a, TyVar
b])
sc_sel_id :: TyVar
sc_sel_id = Name -> Class -> TyVar
mkDictSelId Name
coercibleSCSelIdName Class
klass
mk_class :: TyCon -> PredType -> Id -> Class
mk_class :: TyCon -> Type -> TyVar -> Class
mk_class tycon :: TyCon
tycon sc_pred :: Type
sc_pred sc_sel_id :: TyVar
sc_sel_id
= Name
-> [TyVar]
-> [FunDep TyVar]
-> [Type]
-> [TyVar]
-> [ClassATItem]
-> [ClassOpItem]
-> ClassMinimalDef
-> TyCon
-> Class
mkClass (TyCon -> Name
tyConName TyCon
tycon) (TyCon -> [TyVar]
tyConTyVars TyCon
tycon) [] [Type
sc_pred] [TyVar
sc_sel_id]
[] [] ([LBooleanFormula Name] -> ClassMinimalDef
forall a. Eq a => [LBooleanFormula a] -> BooleanFormula a
mkAnd []) TyCon
tycon
runtimeRepTy :: Type
runtimeRepTy :: Type
runtimeRepTy = TyCon -> Type
mkTyConTy TyCon
runtimeRepTyCon
liftedTypeKindTyCon :: TyCon
liftedTypeKindTyCon :: TyCon
liftedTypeKindTyCon = Name -> [TyConBinder] -> Type -> [Role] -> Type -> TyCon
buildSynTyCon Name
liftedTypeKindTyConName
[] Type
liftedTypeKind []
(Type -> Type
tYPE Type
liftedRepTy)
runtimeRepTyCon :: TyCon
runtimeRepTyCon :: TyCon
runtimeRepTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
runtimeRepTyConName Maybe CType
forall a. Maybe a
Nothing []
(DataCon
vecRepDataCon DataCon -> [DataCon] -> [DataCon]
forall a. a -> [a] -> [a]
: DataCon
tupleRepDataCon DataCon -> [DataCon] -> [DataCon]
forall a. a -> [a] -> [a]
:
DataCon
sumRepDataCon DataCon -> [DataCon] -> [DataCon]
forall a. a -> [a] -> [a]
: [DataCon]
runtimeRepSimpleDataCons)
vecRepDataCon :: DataCon
vecRepDataCon :: DataCon
vecRepDataCon = Name -> [Type] -> TyCon -> RuntimeRepInfo -> DataCon
pcSpecialDataCon Name
vecRepDataConName [ TyCon -> Type
mkTyConTy TyCon
vecCountTyCon
, TyCon -> Type
mkTyConTy TyCon
vecElemTyCon ]
TyCon
runtimeRepTyCon
(([Type] -> [PrimRep]) -> RuntimeRepInfo
RuntimeRep [Type] -> [PrimRep]
prim_rep_fun)
where
prim_rep_fun :: [Type] -> [PrimRep]
prim_rep_fun [count :: Type
count, elem :: Type
elem]
| VecCount n :: ConTag
n <- TyCon -> RuntimeRepInfo
tyConRuntimeRepInfo (Type -> TyCon
tyConAppTyCon Type
count)
, VecElem e :: PrimElemRep
e <- TyCon -> RuntimeRepInfo
tyConRuntimeRepInfo (Type -> TyCon
tyConAppTyCon Type
elem)
= [ConTag -> PrimElemRep -> PrimRep
VecRep ConTag
n PrimElemRep
e]
prim_rep_fun args :: [Type]
args
= String -> SDoc -> [PrimRep]
forall a. HasCallStack => String -> SDoc -> a
pprPanic "vecRepDataCon" ([Type] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Type]
args)
vecRepDataConTyCon :: TyCon
vecRepDataConTyCon :: TyCon
vecRepDataConTyCon = DataCon -> TyCon
promoteDataCon DataCon
vecRepDataCon
tupleRepDataCon :: DataCon
tupleRepDataCon :: DataCon
tupleRepDataCon = Name -> [Type] -> TyCon -> RuntimeRepInfo -> DataCon
pcSpecialDataCon Name
tupleRepDataConName [ Type -> Type
mkListTy Type
runtimeRepTy ]
TyCon
runtimeRepTyCon (([Type] -> [PrimRep]) -> RuntimeRepInfo
RuntimeRep [Type] -> [PrimRep]
prim_rep_fun)
where
prim_rep_fun :: [Type] -> [PrimRep]
prim_rep_fun [rr_ty_list :: Type
rr_ty_list]
= (Type -> [PrimRep]) -> [Type] -> [PrimRep]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (HasDebugCallStack => SDoc -> Type -> [PrimRep]
SDoc -> Type -> [PrimRep]
runtimeRepPrimRep SDoc
doc) [Type]
rr_tys
where
rr_tys :: [Type]
rr_tys = Type -> [Type]
extractPromotedList Type
rr_ty_list
doc :: SDoc
doc = String -> SDoc
text "tupleRepDataCon" SDoc -> SDoc -> SDoc
<+> [Type] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Type]
rr_tys
prim_rep_fun args :: [Type]
args
= String -> SDoc -> [PrimRep]
forall a. HasCallStack => String -> SDoc -> a
pprPanic "tupleRepDataCon" ([Type] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Type]
args)
tupleRepDataConTyCon :: TyCon
tupleRepDataConTyCon :: TyCon
tupleRepDataConTyCon = DataCon -> TyCon
promoteDataCon DataCon
tupleRepDataCon
sumRepDataCon :: DataCon
sumRepDataCon :: DataCon
sumRepDataCon = Name -> [Type] -> TyCon -> RuntimeRepInfo -> DataCon
pcSpecialDataCon Name
sumRepDataConName [ Type -> Type
mkListTy Type
runtimeRepTy ]
TyCon
runtimeRepTyCon (([Type] -> [PrimRep]) -> RuntimeRepInfo
RuntimeRep [Type] -> [PrimRep]
prim_rep_fun)
where
prim_rep_fun :: [Type] -> [PrimRep]
prim_rep_fun [rr_ty_list :: Type
rr_ty_list]
= (SlotTy -> PrimRep) -> [SlotTy] -> [PrimRep]
forall a b. (a -> b) -> [a] -> [b]
map SlotTy -> PrimRep
slotPrimRep ([[PrimRep]] -> [SlotTy]
ubxSumRepType [[PrimRep]]
prim_repss)
where
rr_tys :: [Type]
rr_tys = Type -> [Type]
extractPromotedList Type
rr_ty_list
doc :: SDoc
doc = String -> SDoc
text "sumRepDataCon" SDoc -> SDoc -> SDoc
<+> [Type] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Type]
rr_tys
prim_repss :: [[PrimRep]]
prim_repss = (Type -> [PrimRep]) -> [Type] -> [[PrimRep]]
forall a b. (a -> b) -> [a] -> [b]
map (HasDebugCallStack => SDoc -> Type -> [PrimRep]
SDoc -> Type -> [PrimRep]
runtimeRepPrimRep SDoc
doc) [Type]
rr_tys
prim_rep_fun args :: [Type]
args
= String -> SDoc -> [PrimRep]
forall a. HasCallStack => String -> SDoc -> a
pprPanic "sumRepDataCon" ([Type] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Type]
args)
sumRepDataConTyCon :: TyCon
sumRepDataConTyCon :: TyCon
sumRepDataConTyCon = DataCon -> TyCon
promoteDataCon DataCon
sumRepDataCon
runtimeRepSimpleDataCons :: [DataCon]
liftedRepDataCon :: DataCon
runtimeRepSimpleDataCons :: [DataCon]
runtimeRepSimpleDataCons@(liftedRepDataCon :: DataCon
liftedRepDataCon : _)
= (PrimRep -> Name -> DataCon) -> [PrimRep] -> [Name] -> [DataCon]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWithLazy PrimRep -> Name -> DataCon
mk_runtime_rep_dc
[ PrimRep
LiftedRep, PrimRep
UnliftedRep, PrimRep
IntRep, PrimRep
WordRep, PrimRep
Int8Rep, PrimRep
Int16Rep, PrimRep
Int64Rep
, PrimRep
Word8Rep, PrimRep
Word16Rep, PrimRep
Word64Rep, PrimRep
AddrRep, PrimRep
FloatRep, PrimRep
DoubleRep ]
[Name]
runtimeRepSimpleDataConNames
where
mk_runtime_rep_dc :: PrimRep -> Name -> DataCon
mk_runtime_rep_dc primrep :: PrimRep
primrep name :: Name
name
= Name -> [Type] -> TyCon -> RuntimeRepInfo -> DataCon
pcSpecialDataCon Name
name [] TyCon
runtimeRepTyCon (([Type] -> [PrimRep]) -> RuntimeRepInfo
RuntimeRep (\_ -> [PrimRep
primrep]))
liftedRepDataConTy, unliftedRepDataConTy,
intRepDataConTy, int8RepDataConTy, int16RepDataConTy, wordRepDataConTy, int64RepDataConTy,
word8RepDataConTy, word16RepDataConTy, word64RepDataConTy, addrRepDataConTy,
floatRepDataConTy, doubleRepDataConTy :: Type
[liftedRepDataConTy :: Type
liftedRepDataConTy, unliftedRepDataConTy :: Type
unliftedRepDataConTy,
intRepDataConTy :: Type
intRepDataConTy, wordRepDataConTy :: Type
wordRepDataConTy, int8RepDataConTy :: Type
int8RepDataConTy, int16RepDataConTy :: Type
int16RepDataConTy, int64RepDataConTy :: Type
int64RepDataConTy,
word8RepDataConTy :: Type
word8RepDataConTy, word16RepDataConTy :: Type
word16RepDataConTy, word64RepDataConTy :: Type
word64RepDataConTy,
addrRepDataConTy :: Type
addrRepDataConTy, floatRepDataConTy :: Type
floatRepDataConTy, doubleRepDataConTy :: Type
doubleRepDataConTy]
= (DataCon -> Type) -> [DataCon] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map (TyCon -> Type
mkTyConTy (TyCon -> Type) -> (DataCon -> TyCon) -> DataCon -> Type
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataCon -> TyCon
promoteDataCon) [DataCon]
runtimeRepSimpleDataCons
vecCountTyCon :: TyCon
vecCountTyCon :: TyCon
vecCountTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
vecCountTyConName Maybe CType
forall a. Maybe a
Nothing [] [DataCon]
vecCountDataCons
vecCountDataCons :: [DataCon]
vecCountDataCons :: [DataCon]
vecCountDataCons = (ConTag -> Name -> DataCon) -> [ConTag] -> [Name] -> [DataCon]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWithLazy ConTag -> Name -> DataCon
mk_vec_count_dc
[ 2, 4, 8, 16, 32, 64 ]
[Name]
vecCountDataConNames
where
mk_vec_count_dc :: ConTag -> Name -> DataCon
mk_vec_count_dc n :: ConTag
n name :: Name
name
= Name -> [Type] -> TyCon -> RuntimeRepInfo -> DataCon
pcSpecialDataCon Name
name [] TyCon
vecCountTyCon (ConTag -> RuntimeRepInfo
VecCount ConTag
n)
vec2DataConTy, vec4DataConTy, vec8DataConTy, vec16DataConTy, vec32DataConTy,
vec64DataConTy :: Type
[vec2DataConTy :: Type
vec2DataConTy, vec4DataConTy :: Type
vec4DataConTy, vec8DataConTy :: Type
vec8DataConTy, vec16DataConTy :: Type
vec16DataConTy, vec32DataConTy :: Type
vec32DataConTy,
vec64DataConTy :: Type
vec64DataConTy] = (DataCon -> Type) -> [DataCon] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map (TyCon -> Type
mkTyConTy (TyCon -> Type) -> (DataCon -> TyCon) -> DataCon -> Type
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataCon -> TyCon
promoteDataCon) [DataCon]
vecCountDataCons
vecElemTyCon :: TyCon
vecElemTyCon :: TyCon
vecElemTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
vecElemTyConName Maybe CType
forall a. Maybe a
Nothing [] [DataCon]
vecElemDataCons
vecElemDataCons :: [DataCon]
vecElemDataCons :: [DataCon]
vecElemDataCons = (PrimElemRep -> Name -> DataCon)
-> [PrimElemRep] -> [Name] -> [DataCon]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWithLazy PrimElemRep -> Name -> DataCon
mk_vec_elem_dc
[ PrimElemRep
Int8ElemRep, PrimElemRep
Int16ElemRep, PrimElemRep
Int32ElemRep, PrimElemRep
Int64ElemRep
, PrimElemRep
Word8ElemRep, PrimElemRep
Word16ElemRep, PrimElemRep
Word32ElemRep, PrimElemRep
Word64ElemRep
, PrimElemRep
FloatElemRep, PrimElemRep
DoubleElemRep ]
[Name]
vecElemDataConNames
where
mk_vec_elem_dc :: PrimElemRep -> Name -> DataCon
mk_vec_elem_dc elem :: PrimElemRep
elem name :: Name
name
= Name -> [Type] -> TyCon -> RuntimeRepInfo -> DataCon
pcSpecialDataCon Name
name [] TyCon
vecElemTyCon (PrimElemRep -> RuntimeRepInfo
VecElem PrimElemRep
elem)
int8ElemRepDataConTy, int16ElemRepDataConTy, int32ElemRepDataConTy,
int64ElemRepDataConTy, word8ElemRepDataConTy, word16ElemRepDataConTy,
word32ElemRepDataConTy, word64ElemRepDataConTy, floatElemRepDataConTy,
doubleElemRepDataConTy :: Type
[int8ElemRepDataConTy :: Type
int8ElemRepDataConTy, int16ElemRepDataConTy :: Type
int16ElemRepDataConTy, int32ElemRepDataConTy :: Type
int32ElemRepDataConTy,
int64ElemRepDataConTy :: Type
int64ElemRepDataConTy, word8ElemRepDataConTy :: Type
word8ElemRepDataConTy, word16ElemRepDataConTy :: Type
word16ElemRepDataConTy,
word32ElemRepDataConTy :: Type
word32ElemRepDataConTy, word64ElemRepDataConTy :: Type
word64ElemRepDataConTy, floatElemRepDataConTy :: Type
floatElemRepDataConTy,
doubleElemRepDataConTy :: Type
doubleElemRepDataConTy] = (DataCon -> Type) -> [DataCon] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map (TyCon -> Type
mkTyConTy (TyCon -> Type) -> (DataCon -> TyCon) -> DataCon -> Type
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataCon -> TyCon
promoteDataCon)
[DataCon]
vecElemDataCons
liftedRepDataConTyCon :: TyCon
liftedRepDataConTyCon :: TyCon
liftedRepDataConTyCon = DataCon -> TyCon
promoteDataCon DataCon
liftedRepDataCon
liftedRepTy :: Type
liftedRepTy :: Type
liftedRepTy = Type
liftedRepDataConTy
boxingDataCon_maybe :: TyCon -> Maybe DataCon
boxingDataCon_maybe :: TyCon -> Maybe DataCon
boxingDataCon_maybe tc :: TyCon
tc
= NameEnv DataCon -> Name -> Maybe DataCon
forall a. NameEnv a -> Name -> Maybe a
lookupNameEnv NameEnv DataCon
boxing_constr_env (TyCon -> Name
tyConName TyCon
tc)
boxing_constr_env :: NameEnv DataCon
boxing_constr_env :: NameEnv DataCon
boxing_constr_env
= [(Name, DataCon)] -> NameEnv DataCon
forall a. [(Name, a)] -> NameEnv a
mkNameEnv [(Name
charPrimTyConName , DataCon
charDataCon )
,(Name
intPrimTyConName , DataCon
intDataCon )
,(Name
wordPrimTyConName , DataCon
wordDataCon )
,(Name
floatPrimTyConName , DataCon
floatDataCon )
,(Name
doublePrimTyConName, DataCon
doubleDataCon) ]
charTy :: Type
charTy :: Type
charTy = TyCon -> Type
mkTyConTy TyCon
charTyCon
charTyCon :: TyCon
charTyCon :: TyCon
charTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
charTyConName
(CType -> Maybe CType
forall a. a -> Maybe a
Just (SourceText -> Maybe Header -> (SourceText, FastString) -> CType
CType SourceText
NoSourceText Maybe Header
forall a. Maybe a
Nothing
(SourceText
NoSourceText,String -> FastString
fsLit "HsChar")))
[] [DataCon
charDataCon]
charDataCon :: DataCon
charDataCon :: DataCon
charDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
charDataConName [] [Type
charPrimTy] TyCon
charTyCon
stringTy :: Type
stringTy :: Type
stringTy = Type -> Type
mkListTy Type
charTy
intTy :: Type
intTy :: Type
intTy = TyCon -> Type
mkTyConTy TyCon
intTyCon
intTyCon :: TyCon
intTyCon :: TyCon
intTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
intTyConName
(CType -> Maybe CType
forall a. a -> Maybe a
Just (SourceText -> Maybe Header -> (SourceText, FastString) -> CType
CType SourceText
NoSourceText Maybe Header
forall a. Maybe a
Nothing (SourceText
NoSourceText,String -> FastString
fsLit "HsInt")))
[] [DataCon
intDataCon]
intDataCon :: DataCon
intDataCon :: DataCon
intDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
intDataConName [] [Type
intPrimTy] TyCon
intTyCon
wordTy :: Type
wordTy :: Type
wordTy = TyCon -> Type
mkTyConTy TyCon
wordTyCon
wordTyCon :: TyCon
wordTyCon :: TyCon
wordTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
wordTyConName
(CType -> Maybe CType
forall a. a -> Maybe a
Just (SourceText -> Maybe Header -> (SourceText, FastString) -> CType
CType SourceText
NoSourceText Maybe Header
forall a. Maybe a
Nothing (SourceText
NoSourceText, String -> FastString
fsLit "HsWord")))
[] [DataCon
wordDataCon]
wordDataCon :: DataCon
wordDataCon :: DataCon
wordDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
wordDataConName [] [Type
wordPrimTy] TyCon
wordTyCon
word8Ty :: Type
word8Ty :: Type
word8Ty = TyCon -> Type
mkTyConTy TyCon
word8TyCon
word8TyCon :: TyCon
word8TyCon :: TyCon
word8TyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
word8TyConName
(CType -> Maybe CType
forall a. a -> Maybe a
Just (SourceText -> Maybe Header -> (SourceText, FastString) -> CType
CType SourceText
NoSourceText Maybe Header
forall a. Maybe a
Nothing
(SourceText
NoSourceText, String -> FastString
fsLit "HsWord8"))) []
[DataCon
word8DataCon]
word8DataCon :: DataCon
word8DataCon :: DataCon
word8DataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
word8DataConName [] [Type
wordPrimTy] TyCon
word8TyCon
floatTy :: Type
floatTy :: Type
floatTy = TyCon -> Type
mkTyConTy TyCon
floatTyCon
floatTyCon :: TyCon
floatTyCon :: TyCon
floatTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
floatTyConName
(CType -> Maybe CType
forall a. a -> Maybe a
Just (SourceText -> Maybe Header -> (SourceText, FastString) -> CType
CType SourceText
NoSourceText Maybe Header
forall a. Maybe a
Nothing
(SourceText
NoSourceText, String -> FastString
fsLit "HsFloat"))) []
[DataCon
floatDataCon]
floatDataCon :: DataCon
floatDataCon :: DataCon
floatDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
floatDataConName [] [Type
floatPrimTy] TyCon
floatTyCon
doubleTy :: Type
doubleTy :: Type
doubleTy = TyCon -> Type
mkTyConTy TyCon
doubleTyCon
doubleTyCon :: TyCon
doubleTyCon :: TyCon
doubleTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
doubleTyConName
(CType -> Maybe CType
forall a. a -> Maybe a
Just (SourceText -> Maybe Header -> (SourceText, FastString) -> CType
CType SourceText
NoSourceText Maybe Header
forall a. Maybe a
Nothing
(SourceText
NoSourceText,String -> FastString
fsLit "HsDouble"))) []
[DataCon
doubleDataCon]
doubleDataCon :: DataCon
doubleDataCon :: DataCon
doubleDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
doubleDataConName [] [Type
doublePrimTy] TyCon
doubleTyCon
boolTy :: Type
boolTy :: Type
boolTy = TyCon -> Type
mkTyConTy TyCon
boolTyCon
boolTyCon :: TyCon
boolTyCon :: TyCon
boolTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
boolTyConName
(CType -> Maybe CType
forall a. a -> Maybe a
Just (SourceText -> Maybe Header -> (SourceText, FastString) -> CType
CType SourceText
NoSourceText Maybe Header
forall a. Maybe a
Nothing
(SourceText
NoSourceText, String -> FastString
fsLit "HsBool")))
[] [DataCon
falseDataCon, DataCon
trueDataCon]
falseDataCon, trueDataCon :: DataCon
falseDataCon :: DataCon
falseDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
falseDataConName [] [] TyCon
boolTyCon
trueDataCon :: DataCon
trueDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
trueDataConName [] [] TyCon
boolTyCon
falseDataConId, trueDataConId :: Id
falseDataConId :: TyVar
falseDataConId = DataCon -> TyVar
dataConWorkId DataCon
falseDataCon
trueDataConId :: TyVar
trueDataConId = DataCon -> TyVar
dataConWorkId DataCon
trueDataCon
orderingTyCon :: TyCon
orderingTyCon :: TyCon
orderingTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
orderingTyConName Maybe CType
forall a. Maybe a
Nothing
[] [DataCon
ordLTDataCon, DataCon
ordEQDataCon, DataCon
ordGTDataCon]
ordLTDataCon, ordEQDataCon, ordGTDataCon :: DataCon
ordLTDataCon :: DataCon
ordLTDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
ordLTDataConName [] [] TyCon
orderingTyCon
ordEQDataCon :: DataCon
ordEQDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
ordEQDataConName [] [] TyCon
orderingTyCon
ordGTDataCon :: DataCon
ordGTDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
ordGTDataConName [] [] TyCon
orderingTyCon
ordLTDataConId, ordEQDataConId, ordGTDataConId :: Id
ordLTDataConId :: TyVar
ordLTDataConId = DataCon -> TyVar
dataConWorkId DataCon
ordLTDataCon
ordEQDataConId :: TyVar
ordEQDataConId = DataCon -> TyVar
dataConWorkId DataCon
ordEQDataCon
ordGTDataConId :: TyVar
ordGTDataConId = DataCon -> TyVar
dataConWorkId DataCon
ordGTDataCon
mkListTy :: Type -> Type
mkListTy :: Type -> Type
mkListTy ty :: Type
ty = TyCon -> [Type] -> Type
mkTyConApp TyCon
listTyCon [Type
ty]
listTyCon :: TyCon
listTyCon :: TyCon
listTyCon =
Name
-> [TyVar]
-> [Role]
-> Maybe CType
-> [Type]
-> AlgTyConRhs
-> Bool
-> AlgTyConFlav
-> TyCon
buildAlgTyCon Name
listTyConName [TyVar]
alpha_tyvar [Role
Representational]
Maybe CType
forall a. Maybe a
Nothing []
([DataCon] -> AlgTyConRhs
mkDataTyConRhs [DataCon
nilDataCon, DataCon
consDataCon])
Bool
False
(Name -> AlgTyConFlav
VanillaAlgTyCon (Name -> AlgTyConFlav) -> Name -> AlgTyConFlav
forall a b. (a -> b) -> a -> b
$ Name -> Name
mkPrelTyConRepName Name
listTyConName)
nilDataCon :: DataCon
nilDataCon :: DataCon
nilDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
nilDataConName [TyVar]
alpha_tyvar [] TyCon
listTyCon
consDataCon :: DataCon
consDataCon :: DataCon
consDataCon = Bool
-> Name
-> [TyVar]
-> [TyVar]
-> [TyVar]
-> [Type]
-> TyCon
-> DataCon
pcDataConWithFixity Bool
True
Name
consDataConName
[TyVar]
alpha_tyvar [] [TyVar]
alpha_tyvar
[Type
alphaTy, TyCon -> [Type] -> Type
mkTyConApp TyCon
listTyCon [Type]
alpha_ty] TyCon
listTyCon
maybeTyCon :: TyCon
maybeTyCon :: TyCon
maybeTyCon = Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
pcTyCon Name
maybeTyConName Maybe CType
forall a. Maybe a
Nothing [TyVar]
alpha_tyvar
[DataCon
nothingDataCon, DataCon
justDataCon]
nothingDataCon :: DataCon
nothingDataCon :: DataCon
nothingDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
nothingDataConName [TyVar]
alpha_tyvar [] TyCon
maybeTyCon
justDataCon :: DataCon
justDataCon :: DataCon
justDataCon = Name -> [TyVar] -> [Type] -> TyCon -> DataCon
pcDataCon Name
justDataConName [TyVar]
alpha_tyvar [Type
alphaTy] TyCon
maybeTyCon
mkTupleTy :: Boxity -> [Type] -> Type
mkTupleTy :: Boxity -> [Type] -> Type
mkTupleTy Boxed [ty :: Type
ty] = Type
ty
mkTupleTy Boxed tys :: [Type]
tys = TyCon -> [Type] -> Type
mkTyConApp (Boxity -> ConTag -> TyCon
tupleTyCon Boxity
Boxed ([Type] -> ConTag
forall (t :: * -> *) a. Foldable t => t a -> ConTag
length [Type]
tys)) [Type]
tys
mkTupleTy Unboxed tys :: [Type]
tys = TyCon -> [Type] -> Type
mkTyConApp (Boxity -> ConTag -> TyCon
tupleTyCon Boxity
Unboxed ([Type] -> ConTag
forall (t :: * -> *) a. Foldable t => t a -> ConTag
length [Type]
tys))
((Type -> Type) -> [Type] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map HasDebugCallStack => Type -> Type
Type -> Type
getRuntimeRep [Type]
tys [Type] -> [Type] -> [Type]
forall a. [a] -> [a] -> [a]
++ [Type]
tys)
mkBoxedTupleTy :: [Type] -> Type
mkBoxedTupleTy :: [Type] -> Type
mkBoxedTupleTy tys :: [Type]
tys = Boxity -> [Type] -> Type
mkTupleTy Boxity
Boxed [Type]
tys
unitTy :: Type
unitTy :: Type
unitTy = Boxity -> [Type] -> Type
mkTupleTy Boxity
Boxed []
mkSumTy :: [Type] -> Type
mkSumTy :: [Type] -> Type
mkSumTy tys :: [Type]
tys = TyCon -> [Type] -> Type
mkTyConApp (ConTag -> TyCon
sumTyCon ([Type] -> ConTag
forall (t :: * -> *) a. Foldable t => t a -> ConTag
length [Type]
tys))
((Type -> Type) -> [Type] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map HasDebugCallStack => Type -> Type
Type -> Type
getRuntimeRep [Type]
tys [Type] -> [Type] -> [Type]
forall a. [a] -> [a] -> [a]
++ [Type]
tys)
promotedFalseDataCon, promotedTrueDataCon :: TyCon
promotedTrueDataCon :: TyCon
promotedTrueDataCon = DataCon -> TyCon
promoteDataCon DataCon
trueDataCon
promotedFalseDataCon :: TyCon
promotedFalseDataCon = DataCon -> TyCon
promoteDataCon DataCon
falseDataCon
promotedNothingDataCon, promotedJustDataCon :: TyCon
promotedNothingDataCon :: TyCon
promotedNothingDataCon = DataCon -> TyCon
promoteDataCon DataCon
nothingDataCon
promotedJustDataCon :: TyCon
promotedJustDataCon = DataCon -> TyCon
promoteDataCon DataCon
justDataCon
promotedLTDataCon
, promotedEQDataCon
, promotedGTDataCon
:: TyCon
promotedLTDataCon :: TyCon
promotedLTDataCon = DataCon -> TyCon
promoteDataCon DataCon
ordLTDataCon
promotedEQDataCon :: TyCon
promotedEQDataCon = DataCon -> TyCon
promoteDataCon DataCon
ordEQDataCon
promotedGTDataCon :: TyCon
promotedGTDataCon = DataCon -> TyCon
promoteDataCon DataCon
ordGTDataCon
promotedConsDataCon, promotedNilDataCon :: TyCon
promotedConsDataCon :: TyCon
promotedConsDataCon = DataCon -> TyCon
promoteDataCon DataCon
consDataCon
promotedNilDataCon :: TyCon
promotedNilDataCon = DataCon -> TyCon
promoteDataCon DataCon
nilDataCon
mkPromotedListTy :: Kind
-> [Type]
-> Type
mkPromotedListTy :: Type -> [Type] -> Type
mkPromotedListTy k :: Type
k tys :: [Type]
tys
= (Type -> Type -> Type) -> Type -> [Type] -> Type
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Type -> Type -> Type
cons Type
nil [Type]
tys
where
cons :: Type
-> Type
-> Type
cons :: Type -> Type -> Type
cons elt :: Type
elt list :: Type
list = TyCon -> [Type] -> Type
mkTyConApp TyCon
promotedConsDataCon [Type
k, Type
elt, Type
list]
nil :: Type
nil :: Type
nil = TyCon -> [Type] -> Type
mkTyConApp TyCon
promotedNilDataCon [Type
k]
extractPromotedList :: Type
-> [Type]
tys :: Type
tys = Type -> [Type]
go Type
tys
where
go :: Type -> [Type]
go list_ty :: Type
list_ty
| Just (tc :: TyCon
tc, [_k :: Type
_k, t :: Type
t, ts :: Type
ts]) <- HasDebugCallStack => Type -> Maybe (TyCon, [Type])
Type -> Maybe (TyCon, [Type])
splitTyConApp_maybe Type
list_ty
= ASSERT( tc `hasKey` consDataConKey )
Type
t Type -> [Type] -> [Type]
forall a. a -> [a] -> [a]
: Type -> [Type]
go Type
ts
| Just (tc :: TyCon
tc, [_k :: Type
_k]) <- HasDebugCallStack => Type -> Maybe (TyCon, [Type])
Type -> Maybe (TyCon, [Type])
splitTyConApp_maybe Type
list_ty
= ASSERT( tc `hasKey` nilDataConKey )
[]
| Bool
otherwise
= String -> SDoc -> [Type]
forall a. HasCallStack => String -> SDoc -> a
pprPanic "extractPromotedList" (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
tys)