[project @ 2005-02-19 19:45:50 by desrt]
[ghc-hetmet.git] / ghc / compiler / types / TyCon.lhs
index 78cf5be..7fdf2e3 100644 (file)
@@ -33,7 +33,7 @@ module TyCon(
        tyConUnique,
        tyConTyVars,
        tyConArgVrcs,
-       algTcRhs, tyConDataCons, tyConDataCons_maybe, tyConFamilySize,
+       algTyConRhs, tyConDataCons, tyConDataCons_maybe, tyConFamilySize,
        tyConFields, tyConSelIds,
        tyConStupidTheta,
        tyConArity,
@@ -91,8 +91,8 @@ data TyCon
        tyConKind   :: Kind,
        tyConArity  :: Arity,
        
-       tyConTyVars :: [TyVar],         -- Scopes over (a) the [PredType] in DataTyCon
-                                       --             (b) the cached types in NewTyCon
+       tyConTyVars :: [TyVar],         -- Scopes over (a) the [PredType] in AlgTyConRhs.DataTyCon
+                                       --             (b) the cached types in AlgTyConRhs.NewTyCon
                                        --             (c) the types in algTcFields
                                        -- But not over the data constructors
        argVrcs     :: ArgVrcs,
@@ -177,6 +177,8 @@ data AlgTyConRhs
                                --      e.g. data T a where { ... }
        [DataCon]       -- The constructors; can be empty if the user declares
                        --   the type to have no constructors
+                       -- INVARIANT: Kept in order of increasing tag
+                       --            (see the tag assignment in DataCon.mkDataCon)
        Bool            -- Cached: True <=> an enumeration type
 
   | NewTyCon           -- Newtypes always have exactly one constructor
@@ -490,6 +492,11 @@ tyConFields other_tycon                      = []
 
 tyConSelIds :: TyCon -> [Id]
 tyConSelIds tc = [id | (_,_,id) <- tyConFields tc]
+
+algTyConRhs :: TyCon -> AlgTyConRhs
+algTyConRhs (AlgTyCon {algTcRhs = rhs})  = rhs
+algTyConRhs (TupleTyCon {dataCon = con}) = DataTyCon (Just []) [con] False
+algTyConRhs other = pprPanic "algTyConRhs" (ppr other)
 \end{code}
 
 \begin{code}