isTupleTyCon, isUnboxedTupleTyCon, isBoxedTupleTyCon, tupleTyConBoxity,
isRecursiveTyCon, newTyConRep,
- mkAlgTyConRep, --mkAlgTyCon,
+ mkAlgTyCon, --mkAlgTyCon,
mkClassTyCon,
mkFunTyCon,
mkPrimTyCon,
tyConUnique,
tyConTyVars,
tyConArgVrcs_maybe,
- tyConDataCons, tyConDataConsIfAvailable,
- tyConFamilySize,
+ tyConDataCons, tyConDataConsIfAvailable, tyConFamilySize,
+ tyConSelIds,
tyConTheta,
tyConPrimRep,
tyConArity,
-- (b) in a quest for fast compilation we don't import
-- the constructors
+ selIds :: [Id], -- Its record selectors (if any)
+
noOfDataCons :: Int, -- Number of data constructors
-- Usually this is the same as the length of the
-- dataCons field, but the latter may be empty if
}
type ArgVrcs = [(Bool,Bool)] -- Tyvar variance info: [(occPos,occNeg)]
- -- *NB*: this is tyvar variance info, *not*
- -- termvar usage info.
data AlgTyConFlavour
= DataTyCon -- Data type
-- This is the making of a TyCon. Just the same as the old mkAlgTyCon,
-- but now you also have to pass in the generic information about the type
-- constructor - you can get hold of it easily (see Generics module)
-mkAlgTyConRep name kind tyvars theta argvrcs cons ncons flavour rec
+mkAlgTyCon name kind tyvars theta argvrcs cons ncons sels flavour rec
gen_info
= AlgTyCon {
tyConName = name,
tyConArgVrcs = argvrcs,
algTyConTheta = theta,
dataCons = cons,
+ selIds = sels,
noOfDataCons = ncons,
algTyConClass = False,
algTyConFlavour = flavour,
tyConArgVrcs = argvrcs,
algTyConTheta = [],
dataCons = [con],
+ selIds = [],
noOfDataCons = 1,
algTyConClass = True,
algTyConFlavour = flavour,
\begin{code}
tyConDataCons :: TyCon -> [DataCon]
-tyConDataCons tycon = ASSERT2( not (null cons), ppr tycon ) cons
+tyConDataCons tycon = ASSERT2( not (null cons), ppr tycon )
+ ASSERT2( length cons == tyConFamilySize tycon, ppr tycon )
+ cons
where
cons = tyConDataConsIfAvailable tycon
tyConFamilySize other = pprPanic "tyConFamilySize:" (ppr other)
#endif
+tyConSelIds :: TyCon -> [Id]
+tyConSelIds (AlgTyCon {selIds = sels}) = sels
+tyConSelIds other_tycon = []
+\end{code}
+
+\begin{code}
tyConPrimRep :: TyCon -> PrimRep
tyConPrimRep (PrimTyCon {primTyConRep = rep}) = rep
tyConPrimRep _ = PtrRep