- ppr sty (Local u n _) | codeStyle sty ||
- ifaceStyle sty = pprUnique u
- ppr PprForUser (Local _ n _) = ppPStr (occNameString n)
- ppr other_sty (Local u n _) = ppBesides [ppPStr (occNameString n), ppPStr SLIT("_"), pprUnique u]
-
- ppr sty name@(Global u m n _ _) = ppBesides [pp_name, pp_debug sty name]
- where
- pp_name | codeStyle sty = identToC qual_name
- | otherwise = ppPStr qual_name
- qual_name = m _APPEND_ SLIT(".") _APPEND_ occNameString n
-
-pp_debug PprDebug (Global uniq m n _ prov) = ppBesides [ppStr "{-", pprUnique uniq, ppStr ",",
- pp_prov prov, ppStr "-}"]
- where
- pp_prov (LocalDef _ _) = ppChar 'l'
- pp_prov (Imported _ _) = ppChar 'i'
- pp_prov Implicit = ppChar 'p'
-pp_debug other name = ppNil
-
--- pprNameProvenance is used in error messages to say where a name came from
-pprNameProvenance :: PprStyle -> Name -> Pretty
-pprNameProvenance sty (Local _ _ loc) = pprProvenance sty (LocalDef NotExported loc)
-pprNameProvenance sty (Global _ _ _ _ prov) = pprProvenance sty prov
-
-pprProvenance :: PprStyle -> Provenance -> Pretty
-pprProvenance sty (Imported mod loc)
- = ppSep [ppStr "Imported from", pprModule sty mod, ppStr "at", ppr sty loc]
-pprProvenance sty (LocalDef _ loc)
- = ppSep [ppStr "Defined at", ppr sty loc]
-pprProvenance sty Implicit
- = panic "pprNameProvenance: Implicit"
-\end{code}
-
-
-%************************************************************************
-%* *
-\subsection[Sets of names}
-%* *
-%************************************************************************
-
-\begin{code}
-type NameSet = UniqSet Name
-emptyNameSet :: NameSet
-unitNameSet :: Name -> NameSet
-addListToNameSet :: NameSet -> [Name] -> NameSet
-mkNameSet :: [Name] -> NameSet
-unionNameSets :: NameSet -> NameSet -> NameSet
-unionManyNameSets :: [NameSet] -> NameSet
-minusNameSet :: NameSet -> NameSet -> NameSet
-elemNameSet :: Name -> NameSet -> Bool
-nameSetToList :: NameSet -> [Name]
-
-emptyNameSet = emptyUniqSet
-unitNameSet = unitUniqSet
-mkNameSet = mkUniqSet
-addListToNameSet = addListToUniqSet
-unionNameSets = unionUniqSets
-unionManyNameSets = unionManyUniqSets
-minusNameSet = minusUniqSet
-elemNameSet = elementOfUniqSet
-nameSetToList = uniqSetToList
+ -- When printing interfaces, all Internals have been given nice print-names
+ ppr name = pprName name
+
+instance OutputableBndr Name where
+ pprBndr _ name = pprName name
+
+pprName (Name {n_sort = sort, n_uniq = uniq, n_occ = occ})
+ = getPprStyle $ \ sty ->
+ case sort of
+ WiredIn mod _ _ BuiltInSyntax -> pprOccName occ -- Built-in syntax is never qualified
+ WiredIn mod _ _ UserSyntax -> pprExternal sty uniq mod occ True
+ External mod _ -> pprExternal sty uniq mod occ False
+ System -> pprSystem sty uniq occ
+ Internal -> pprInternal sty uniq occ
+
+pprExternal sty uniq mod occ is_wired
+ | unqualStyle sty mod_name occ = pprOccName occ
+ | 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 "-}"]]
+ | otherwise = ppr mod_name <> dot <> pprOccName occ
+ where
+ mod_name = moduleName mod
+
+pprInternal sty uniq occ
+ | codeStyle sty = pprUnique uniq
+ | 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
+pprSystem sty uniq occ
+ | codeStyle sty = pprUnique uniq
+ | otherwise = pprOccName occ <> char '_' <> pprUnique uniq
+ -- If the tidy phase hasn't run, the OccName
+ -- is unlikely to be informative (like 's'),
+ -- so print the unique