-- The Name type
Name, -- Abstract
mkInternalName, mkSystemName,
- mkSystemNameEncoded, mkSystemTvNameEncoded, mkFCallName,
- mkIPName,
+ mkSystemNameEncoded, mkSysTvName,
+ mkFCallName, mkIPName,
mkExternalName, mkWiredInName,
nameUnique, setNameUnique,
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
\begin{code}
hashName :: Name -> Int
-hashName name = iBox (getKey (nameUnique name))
+hashName name = getKey (nameUnique name)
\end{code}
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,
- hsep [text "{-",
- if is_wired then ptext SLIT("(w)") else empty,
- pprUnique uniq,
- case mb_p of
- Nothing -> empty
- Just n -> brackets (ppr n),
- text "-}"]]
- | unqualStyle sty name = pprOccName occ
- | otherwise = 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
+-- (overkill) , case mb_p of
+-- Nothing -> empty
+-- Just n -> brackets (ppr n)
+ , text "-}"]]
+ | 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