Constructor names in info tables
[ghc-hetmet.git] / compiler / basicTypes / DataCon.lhs
index 8829128..c75f1b4 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}
@@ -9,7 +10,7 @@ module DataCon (
        ConTag, fIRST_TAG,
        mkDataCon,
        dataConRepType, dataConSig, dataConFullSig,
-       dataConName, dataConTag, dataConTyCon, dataConUserType,
+       dataConName, dataConIdentity, dataConTag, dataConTyCon, dataConUserType,
        dataConUnivTyVars, dataConExTyVars, dataConAllTyVars, dataConResTys,
        dataConEqSpec, eqSpecPreds, dataConTheta, dataConStupidTheta, 
        dataConInstArgTys, dataConOrigArgTys, 
@@ -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}
 
@@ -316,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
@@ -356,7 +350,7 @@ data DataConIds
        -- The 'Nothing' case of DCIds is important
        -- Not only is this efficient,
        -- but it also ensures that the wrapper is replaced
-       -- by the worker (becuase it *is* the wroker)
+       -- by the worker (becuase it *is* the worker)
        -- even when there are no args. E.g. in
        --              f (:) x
        -- the (:) *is* the worker.
@@ -507,6 +501,19 @@ mk_dict_strict_mark pred | isStrictPred pred = MarkedStrict
 dataConName :: DataCon -> Name
 dataConName = dcName
 
+-- generate a name in the format: package:Module.OccName
+-- and the unique identity of the name
+dataConIdentity :: DataCon -> String
+dataConIdentity dataCon
+   = prettyName
+   where
+   prettyName = pretty packageModule ++ "." ++ pretty occ
+   nm = getName dataCon
+   packageModule = nameModule nm
+   occ = getOccName dataCon
+   pretty :: Outputable a => a -> String 
+   pretty = showSDoc . ppr
+
 dataConTag :: DataCon -> ConTag
 dataConTag  = dcTag
 
@@ -625,7 +632,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