Big tidy-up of deriving code
[ghc-hetmet.git] / compiler / basicTypes / DataCon.lhs
index 3450602..0fb7fae 100644 (file)
@@ -1,4 +1,5 @@
 %
+% (c) The University of Glasgow 2006
 % (c) The GRASP/AQUA Project, Glasgow University, 1998
 %
 \section[DataCon]{@DataCon@: Data Constructors}
@@ -29,26 +30,18 @@ module DataCon (
 
 #include "HsVersions.h"
 
-import Type            ( Type, ThetaType, 
-                         substTyWith, substTyVar, mkTopTvSubst, 
-                         mkForAllTys, mkFunTys, mkTyConApp, mkTyVarTy, mkTyVarTys, 
-                         splitTyConApp_maybe, newTyConInstRhs, 
-                         mkPredTys, isStrictPred, pprType
-                       )
-import Coercion                ( isEqPred, mkEqPred )
-import TyCon           ( TyCon, FieldLabel, tyConDataCons, 
-                         isProductTyCon, isTupleTyCon, isUnboxedTupleTyCon,
-                          isNewTyCon, isClosedNewTyCon, isRecursiveTyCon,
-                          tyConFamInst_maybe )
-import Class           ( Class, classTyCon )
-import Name            ( Name, NamedThing(..), nameUnique )
-import Var             ( TyVar, Id )
-import BasicTypes      ( Arity, StrictnessMark(..) )
+import Type
+import Coercion
+import TyCon
+import Class
+import Name
+import Var
+import BasicTypes
 import Outputable
-import Unique          ( Unique, Uniquable(..) )
-import ListSetOps      ( assoc, minusList )
-import Util            ( zipEqual, zipWithEqual )
-import Maybes           ( expectJust )
+import Unique
+import ListSetOps
+import Util
+import Maybes
 import FastString
 \end{code}
 
@@ -260,6 +253,9 @@ data DataCon
                -- [This is a change (Oct05): previously, vanilla datacons guaranteed to
                --  have the same type variables as their parent TyCon, but that seems ugly.]
 
+       -- INVARIANT: the UnivTyVars and ExTyVars all have distinct OccNames
+       -- Reason: less confusing, and easier to generate IfaceSyn
+
        dcEqSpec :: [(TyVar,Type)],     -- Equalities derived from the result type, 
                                        -- *as written by the programmer*
                -- This field allows us to move conveniently between the two ways
@@ -313,6 +309,7 @@ data DataCon
                                        -- and *including* existential dictionaries
 
        dcRepStrictness :: [StrictnessMark],    -- One for each *representation* argument       
+               -- See also Note [Data-con worker strictness] in MkId.lhs
 
        dcRepType   :: Type,    -- Type of the constructor
                                --      forall a x y. (a:=:(x,y), Ord x) => x -> y -> MkT a
@@ -622,7 +619,7 @@ dataConUserType  (MkData { dcUnivTyVars = univ_tvs,
     mkFunTys (mkPredTys theta) $
     mkFunTys arg_tys $
     case tyConFamInst_maybe tycon of
-      Nothing             -> mkTyConApp tycon (map (substTyVar subst) univ_tvs)
+      Nothing             -> mkTyConApp tycon (substTyVars subst univ_tvs)
       Just (ftc, insttys) -> mkTyConApp ftc insttys        -- data instance
   where
     subst = mkTopTvSubst eq_spec