[project @ 2004-08-16 09:53:47 by simonpj]
[ghc-hetmet.git] / ghc / compiler / basicTypes / Name.lhs
index b98a491..29b2b3e 100644 (file)
@@ -11,8 +11,8 @@ module Name (
        -- The Name type
        Name,                                   -- Abstract
        mkInternalName, mkSystemName, 
-       mkSystemNameEncoded, mkSystemTvNameEncoded, mkFCallName,
-       mkIPName,
+       mkSystemNameEncoded, mkSysTvName, 
+       mkFCallName, mkIPName,
        mkExternalName, mkWiredInName,
 
        nameUnique, setNameUnique,
@@ -212,10 +212,10 @@ mkSystemNameEncoded uniq fs = Name { n_uniq = uniq, n_sort = System,
                                     n_occ = mkSysOccFS varName fs, 
                                     n_loc = noSrcLoc }
 
-mkSystemTvNameEncoded :: Unique -> EncodedFS -> Name
-mkSystemTvNameEncoded uniq fs = Name { n_uniq = uniq, n_sort = System, 
-                                      n_occ = mkSysOccFS tvName fs, 
-                                      n_loc = noSrcLoc }
+mkSysTvName :: Unique -> EncodedFS -> Name
+mkSysTvName uniq fs = Name { n_uniq = uniq, n_sort = System, 
+                            n_occ = mkSysOccFS tvName fs, 
+                            n_loc = noSrcLoc }
 
 mkFCallName :: Unique -> EncodedString -> Name
        -- The encoded string completely describes the ccall
@@ -300,17 +300,17 @@ instance Outputable Name where
 instance OutputableBndr Name where
     pprBndr _ name = pprName name
 
-pprName name@(Name {n_sort = sort, n_uniq = uniq, n_occ = occ})
+pprName (Name {n_sort = sort, n_uniq = uniq, n_occ = occ})
   = getPprStyle $ \ sty ->
     case sort of
-      External mod mb_p      -> pprExternal sty name uniq mod occ mb_p False
-      WiredIn mod mb_p thing -> pprExternal sty name uniq mod occ mb_p True
+      External mod mb_p      -> pprExternal sty uniq mod occ mb_p False
+      WiredIn mod mb_p thing -> pprExternal sty uniq mod occ mb_p True
       System                        -> pprSystem sty uniq occ
       Internal              -> pprInternal sty uniq occ
 
-pprExternal sty name uniq mod occ mb_p is_wired
-  | codeStyle sty        = ppr (moduleName mod) <> char '_' <> pprOccName occ
-  | debugStyle sty       = sep [ppr (moduleName mod) <> dot <> pprOccName occ,
+pprExternal sty uniq mod occ mb_p is_wired
+  | codeStyle sty        = ppr mod_name <> char '_' <> pprOccName occ
+  | debugStyle sty       = sep [ppr mod_name <> dot <> pprOccName occ,
                                hsep [text "{-" 
                                     , if is_wired then ptext SLIT("(w)") else empty
                                     , pprUnique uniq
@@ -318,14 +318,14 @@ pprExternal sty name uniq mod occ mb_p is_wired
 --                                      Nothing -> empty
 --                                      Just n  -> brackets (ppr n)
                                     , text "-}"]]
-  | unqualStyle sty name = pprOccName occ
-  | otherwise           = ppr (moduleName mod) <> dot <> pprOccName occ
+  | unqualStyle sty mod_name occ = pprOccName occ
+  | otherwise                   = ppr mod_name <> dot <> pprOccName occ
+  where
+    mod_name = moduleName mod
 
 pprInternal sty uniq occ
   | codeStyle sty  = pprUnique uniq
-  | debugStyle sty = hsep [pprOccName occ, text "{-", 
-                          text (briefOccNameFlavour occ), 
-                          pprUnique uniq, text "-}"]
+  | debugStyle sty = pprOccName occ <> text "{-" <> pprUnique uniq <> text "-}"
   | otherwise      = pprOccName occ    -- User style
 
 -- Like Internal, except that we only omit the unique in Iface style