[project @ 1999-03-02 14:22:43 by sof]
[ghc-hetmet.git] / ghc / compiler / basicTypes / Name.lhs
index 20b38e9..c895f18 100644 (file)
@@ -43,6 +43,7 @@ import {-# SOURCE #-} Var   ( Id, setIdName )
 import {-# SOURCE #-} TyCon ( TyCon, setTyConName )
 
 import OccName         -- All of it
+import Module
 import RdrName         ( RdrName, mkRdrQual, mkRdrUnqual )
 import CmdLineOpts     ( opt_PprStyle_NoPrags, opt_OmitInterfacePragmas, opt_EnsureSplittableC )
 
@@ -130,26 +131,6 @@ mkWiredInTyConName uniq mod fs tycon
   = Name { n_uniq = uniq, n_sort = WiredInTyCon mod tycon,
           n_occ = mkSrcOccFS tcName fs, n_prov = SystemProv }
 
-fixupSystemName :: Name -> Module -> Provenance -> Name
-       -- Give the SystemProv name an appropriate provenance, and
-       -- perhaps change the Moulde too (so that its HiFlag is right)
-       -- There is a painful hack in that we want to push this
-       -- better name into an WiredInId/TyCon so that it prints
-       -- nicely in error messages
-fixupSystemName name@(Name {n_sort = Global _}) mod' prov'
-  = name {n_sort = Global mod', n_prov = prov'}
-
-fixupSystemName name@(Name {n_sort = WiredInId _ id}) mod' prov'
-  = name'
-  where
-    name' = name {n_sort = WiredInId mod' id', n_prov = prov'}
-    id'   = setIdName id name'
-
-fixupSystemName name@(Name {n_sort = WiredInTyCon _ tc}) mod' prov'
-  = name'
-  where
-    name' = name {n_sort = WiredInTyCon mod' tc', n_prov = prov'}
-    tc'   = setTyConName tc name'
 
 ---------------------------------------------------------------------
 mkDerivedName :: (OccName -> OccName)
@@ -384,7 +365,10 @@ isExternallyVisibleName :: Name -> Bool
 nameUnique name = n_uniq name
 nameOccName name = n_occ name
 
-nameModule name = nameSortModule (n_sort name)
+nameModule name =
+  case n_sort name of
+    Local -> pprPanic "nameModule" (ppr name)
+    x     -> nameSortModule x
 
 nameSortModule (Global       mod)   = mod
 nameSortModule (WiredInId    mod _) = mod
@@ -513,9 +497,10 @@ pprName (Name {n_sort = sort, n_uniq = uniq, n_occ = occ, n_prov = prov})
 
     pp_mod_dot sty
       = case prov of
-          SystemProv                                -> pp_qual mod  dot    user_sty
-               -- Hack alert!  Omit the qualifier on SystemProv things, which I claim
-               -- will also be WiredIn things. We can't get the omit flag right
+          SystemProv                                -> pp_qual mod  pp_sep    user_sty
+               -- Hack alert!  Omit the qualifier on SystemProv things in user style
+                -- I claim such SystemProv things will also be WiredIn things.
+               -- We can't get the omit flag right
                -- on wired in tycons etc (sigh) so we just leave it out in user style, 
                -- and hope that leaving it out isn't too consfusing.
                -- (e.g. if the programmer hides Bool and  redefines it.  If so, use -dppr-debug.)