[project @ 2003-07-09 11:08:03 by simonpj]
[ghc-hetmet.git] / ghc / compiler / basicTypes / Name.lhs
index a8117fb..acf518f 100644 (file)
@@ -17,7 +17,7 @@ module Name (
 
        nameUnique, setNameUnique,
        nameOccName, nameModule, nameModule_maybe,
-       setNameOcc, setNameModuleAndLoc, 
+       setNameOcc, setNameSrcLoc, 
        hashName, externaliseName, localiseName,
 
        nameSrcLoc, eqNameByOcc,
@@ -34,7 +34,7 @@ module Name (
 #include "HsVersions.h"
 
 import OccName         -- All of it
-import Module          ( Module, ModuleName, moduleName, mkVanillaModule, isHomeModule )
+import Module          ( Module, moduleName, isHomeModule )
 import CmdLineOpts     ( opt_Static )
 import SrcLoc          ( noSrcLoc, isWiredInLoc, wiredInSrcLoc, SrcLoc )
 import Unique          ( Unique, Uniquable(..), getKey, pprUnique )
@@ -177,11 +177,11 @@ mkInternalName uniq occ loc = Name { n_uniq = uniq, n_sort = Internal, n_occ = o
 
 mkExternalName :: Unique -> Module -> OccName -> SrcLoc -> Name
 mkExternalName uniq mod occ loc = Name { n_uniq = uniq, n_sort = External mod,
-                                      n_occ = occ, n_loc = loc }
+                                        n_occ = occ, n_loc = loc }
 
-mkKnownKeyExternalName :: ModuleName -> OccName -> Unique -> Name
+mkKnownKeyExternalName :: Module -> OccName -> Unique -> Name
 mkKnownKeyExternalName mod occ uniq
-  = mkExternalName uniq (mkVanillaModule mod) occ noSrcLoc
+  = mkExternalName uniq mod occ noSrcLoc
 
 mkWiredInName :: Module -> OccName -> Unique -> Name
 mkWiredInName mod occ uniq = mkExternalName uniq mod occ wiredInSrcLoc
@@ -230,10 +230,8 @@ externaliseName n mod = n { n_sort = External mod }
 localiseName :: Name -> Name
 localiseName n = n { n_sort = Internal }
                                
-setNameModuleAndLoc :: Name -> Module -> SrcLoc -> Name
-setNameModuleAndLoc name mod loc = name {n_sort = set (n_sort name), n_loc = loc}
-                      where
-                        set (External _) = External mod
+setNameSrcLoc :: Name -> SrcLoc -> Name
+setNameSrcLoc name loc = name {n_loc = loc}
 \end{code}
 
 
@@ -302,17 +300,13 @@ pprName name@(Name {n_sort = sort, n_uniq = uniq, n_occ = occ})
 
 pprExternal sty name uniq mod occ
   | codeStyle sty        = ppr (moduleName mod) <> char '_' <> pprOccName occ
-
-  | debugStyle sty       = ppr (moduleName mod) <> dot <> pprOccName occ <> 
-                           text "{-" <> pprUnique uniq <> text "-}"
-
+  | debugStyle sty       = ppr (moduleName mod) <> dot <> ppr_debug_occ uniq occ
   | unqualStyle sty name = pprOccName occ
   | otherwise           = ppr (moduleName mod) <> dot <> pprOccName occ
 
 pprInternal sty uniq occ
   | codeStyle sty  = pprUnique uniq
-  | debugStyle sty = pprOccName occ <> 
-                    text "{-" <> pprUnique uniq <> text "-}"
+  | debugStyle sty = ppr_debug_occ uniq occ
   | otherwise      = pprOccName occ    -- User style
 
 -- Like Internal, except that we only omit the unique in Iface style
@@ -322,6 +316,10 @@ pprSystem sty uniq occ
                                -- If the tidy phase hasn't run, the OccName
                                -- is unlikely to be informative (like 's'),
                                -- so print the unique
+
+ppr_debug_occ uniq occ = hsep [pprOccName occ, text "{-", 
+                              text (briefOccNameFlavour occ), 
+                              pprUnique uniq, text "-}"]
 \end{code}
 
 %************************************************************************