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 )
= 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)
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
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.)