+data TyCon
+ = FunTyCon {
+ tyConUnique :: Unique,
+ tyConName :: Name,
+ tyConKind :: Kind,
+ tyConArity :: Arity
+ }
+
+
+ | AlgTyCon { -- Tuples, data type, and newtype decls.
+ -- All lifted, all boxed
+ tyConUnique :: Unique,
+ tyConName :: Name,
+ tyConKind :: Kind,
+ tyConArity :: Arity,
+
+ tyConTyVars :: [TyVar],
+ tyConArgVrcs :: ArgVrcs,
+ algTyConTheta :: [PredType],
+
+ dataCons :: DataConDetails DataCon,
+
+ selIds :: [Id], -- Its record selectors (if any)
+
+ algTyConFlavour :: AlgTyConFlavour,
+ algTyConRec :: RecFlag, -- Tells whether the data type is part of
+ -- a mutually-recursive group or not
+
+ genInfo :: Maybe (EP Id), -- Convert T <-> Tring
+ -- Some TyCons don't have it;
+ -- e.g. the TyCon for a Class dictionary,
+ -- and TyCons with unboxed arguments
+
+ algTyConClass :: Maybe Class
+ -- Just cl if this tycon came from a class declaration
+ }
+
+ | PrimTyCon { -- Primitive types; cannot be defined in Haskell
+ -- Now includes foreign-imported types
+ tyConUnique :: Unique,
+ tyConName :: Name,
+ tyConKind :: Kind,
+ tyConArity :: Arity,
+ tyConArgVrcs :: ArgVrcs,
+ primTyConRep :: PrimRep, -- Many primitive tycons are unboxed, but some are
+ -- boxed (represented by pointers). The PrimRep tells.
+
+ isUnLifted :: Bool, -- Most primitive tycons are unlifted,
+ -- but foreign-imported ones may not be
+ tyConExtName :: Maybe FastString
+ }
+
+ | TupleTyCon {
+
+ tyConUnique :: Unique,
+ tyConName :: Name,
+ tyConKind :: Kind,
+ tyConArity :: Arity,
+ tyConBoxed :: Boxity,
+ tyConTyVars :: [TyVar],
+ dataCon :: DataCon,
+ genInfo :: Maybe (EP Id) -- Generic type and conv funs
+ }
+
+ | SynTyCon {
+ tyConUnique :: Unique,
+ tyConName :: Name,
+ tyConKind :: Kind,
+ tyConArity :: Arity,
+
+ tyConTyVars :: [TyVar], -- Bound tyvars
+ synTyConDefn :: Type, -- Right-hand side, mentioning these type vars.
+ -- Acts as a template for the expansion when
+ -- the tycon is applied to some types.
+ tyConArgVrcs :: ArgVrcs
+ }
+
+ | KindCon { -- Type constructor at the kind level
+ tyConUnique :: Unique,
+ tyConName :: Name,
+ tyConKind :: SuperKind,
+ tyConArity :: Arity
+ }
+
+ | SuperKindCon { -- The type of kind variables or boxity variables,
+ tyConUnique :: Unique,
+ tyConName :: Name
+ }
+
+type ArgVrcs = [(Bool,Bool)] -- Tyvar variance info: [(occPos,occNeg)]
+
+data AlgTyConFlavour
+ = DataTyCon -- Data type
+
+ | EnumTyCon -- Special sort of enumeration type
+
+ | NewTyCon Type -- Newtype, with its *ultimate* representation type
+ -- By 'ultimate' I mean that the rep type is not itself
+ -- a newtype or type synonym.
+ -- The rep type isn't entirely simple:
+ -- for a recursive newtype we pick () as the rep type
+ -- newtype T = MkT T
+ --
+ -- The rep type has free type variables the tyConTyVars
+ -- Thus:
+ -- newtype T a = MkT [(a,Int)]
+ -- The rep type is [(a,Int)]
+ -- NB: the rep type isn't necessarily the original RHS of the
+ -- newtype decl, because the rep type looks through other
+ -- newtypes. If you want hte original RHS, look at the
+ -- argument type of the data constructor.
+
+data DataConDetails datacon
+ = DataCons [datacon] -- Its data constructors, with fully polymorphic types
+ -- A type can have zero constructors
+
+ | Unknown -- We're importing this data type from an hi-boot file
+ -- and we don't know what its constructors are
+
+ | HasCons Int -- In a quest for compilation speed we have imported
+ -- only the number of constructors (to get return
+ -- conventions right) but not the constructors themselves
+
+visibleDataCons (DataCons cs) = cs
+visibleDataCons other = []
+\end{code}