Slightly improve -ddump-hi-diffs output
[ghc-hetmet.git] / compiler / iface / MkIface.lhs
index f7cb28a..0d4d163 100644 (file)
@@ -188,7 +188,6 @@ import TyCon
 import DataCon
 import Type
 import TcType
-import TysPrim
 import InstEnv
 import FamInstEnv
 import TcRnMonad
@@ -258,11 +257,13 @@ mkIface hsc_env maybe_old_iface
        ; let   { entities = typeEnvElts type_env ;
                   decls  = [ tyThingToIfaceDecl entity
                           | entity <- entities,
-                             not (isImplicitTyThing entity
-                                  || isWiredInName (getName entity)) ]
-                        -- Don't put implicit Ids and class tycons in
-                        -- the interface file, Nor wired-in things; the
-                        -- compiler knows about them anyhow
+                            let name = getName entity,
+                             not (isImplicitTyThing entity),
+                               -- No implicit Ids and class tycons in the interface file
+                            not (isWiredInName name),
+                               -- Nor wired-in things; the compiler knows about them anyhow
+                            nameIsLocalOrFrom this_mod name  ]
+                               -- Sigh: see Note [Root-main Id] in TcRnDriver
 
                ; fixities    = [(occ,fix) | FixItem occ fix _ <- nameEnvElts fix_env]
                ; deprecs     = mkIfaceDeprec src_deprecs
@@ -276,9 +277,13 @@ mkIface hsc_env maybe_old_iface
                        mi_deps     = deps,
                        mi_usages   = usages,
                        mi_exports  = mkIfaceExports exports,
+       
+                       -- Sort these lexicographically, so that
+                       -- the result is stable across compilations
                        mi_insts    = sortLe le_inst iface_insts,
                        mi_fam_insts= sortLe le_fam_inst iface_fam_insts,
                        mi_rules    = sortLe le_rule iface_rules,
+
                        mi_fixities = fixities,
                        mi_deprecs  = deprecs,
                        mi_globals  = Just rdr_env,
@@ -314,15 +319,19 @@ mkIface hsc_env maybe_old_iface
 
        ; return (new_iface, no_change_at_all) }
   where
-     r1 `le_rule`     r2      = ifRuleName        r1 <= ifRuleName        r2
-     i1 `le_inst`     i2      = ifDFun            i1 <= ifDFun            i2
-     i1 `le_fam_inst` i2      = ifFamInstTyConOcc i1 <= ifFamInstTyConOcc i2
+     r1 `le_rule`     r2 = ifRuleName      r1    <=    ifRuleName      r2
+     i1 `le_inst`     i2 = ifDFun          i1 `le_occ` ifDFun          i2  
+     i1 `le_fam_inst` i2 = ifFamInstTcName i1 `le_occ` ifFamInstTcName i2
+
+     le_occ :: Name -> Name -> Bool
+       -- Compare lexicographically by OccName, *not* by unique, because 
+       -- the latter is not stable across compilations
+     le_occ n1 n2 = nameOccName n1 <= nameOccName n2
 
      dflags = hsc_dflags hsc_env
      deliberatelyOmitted x = panic ("Deliberately omitted: " ++ x)
-     ifFamInstTyConOcc = nameOccName . ifaceTyConName . ifFamInstTyCon
+     ifFamInstTcName = ifaceTyConName . ifFamInstTyCon
 
-                                             
 -----------------------------
 writeIfaceFile :: DynFlags -> ModLocation -> ModIface -> IO ()
 writeIfaceFile dflags location new_iface
@@ -529,7 +538,7 @@ addVersionInfo ver_fn (Just old_iface@(ModIface {
        where
          occ = ifName new_decl
          why = case lookupOccEnv eq_env occ of
-                   Just (EqBut names) -> sep [ppr occ <> colon, ptext SLIT("Free vars (only) changed:"),
+                   Just (EqBut names) -> sep [ppr occ <> colon, ptext SLIT("Free vars (only) changed:") <> ppr names,
                                              nest 2 (braces (fsep (map ppr (occSetElts 
                                                (occs `intersectOccSet` changed_occs)))))]
                            where occs = mkOccSet (map nameOccName (nameSetToList names))
@@ -1240,9 +1249,6 @@ toIfaceExpr (Note n e)    = IfaceNote (toIfaceNote n) (toIfaceExpr e)
 toIfaceNote (SCC cc)      = IfaceSCC cc
 toIfaceNote InlineMe      = IfaceInlineMe
 toIfaceNote (CoreNote s)  = IfaceCoreNote s
-toIfaceNote (TickBox m n) = IfaceTickBox m n
-toIfaceNote (BinaryTickBox m t e)
-                          = IfaceBinaryTickBox m t e
 
 ---------------------
 toIfaceBind (NonRec b r) = IfaceNonRec (toIfaceIdBndr b) (toIfaceExpr r)