-\begin{code}
-mkLocalName :: Unique -> OccName -> SrcLoc -> Name
-mkLocalName uniq occ loc = Name { n_uniq = uniq, n_sort = Local, n_occ = occ,
- n_prov = LocalDef loc NotExported }
- -- NB: You might worry that after lots of huffing and
- -- puffing we might end up with two local names with distinct
- -- uniques, but the same OccName. Indeed we can, but that's ok
- -- * the insides of the compiler don't care: they use the Unique
- -- * when printing for -ddump-xxx you can switch on -dppr-debug to get the
- -- uniques if you get confused
- -- * for interface files we tidyCore first, which puts the uniques
- -- into the print name (see setNameVisibility below)
-
-mkImportedLocalName :: Unique -> OccName -> SrcLoc -> Name
- -- Just the same as mkLocalName, except the provenance is different
- -- Reason: this flags the name as one that came in from an interface file.
- -- This is useful when trying to decide which of two type variables
- -- should 'win' when unifying them.
- -- NB: this is only for non-top-level names, so we use ImplicitImport
-mkImportedLocalName uniq occ loc = Name { n_uniq = uniq, n_sort = Local, n_occ = occ,
- n_prov = NonLocalDef ImplicitImport True }
-
-
-mkGlobalName :: Unique -> Module -> OccName -> Provenance -> Name
-mkGlobalName uniq mod occ prov = Name { n_uniq = uniq, n_sort = Global mod,
- n_occ = occ, n_prov = prov }
-
-
-mkKnownKeyGlobal :: (RdrName, Unique) -> Name
-mkKnownKeyGlobal (rdr_name, uniq)
- = mkGlobalName uniq (mkVanillaModule (rdrNameModule rdr_name))
- (rdrNameOcc rdr_name)
- systemProvenance
-
-mkSysLocalName :: Unique -> UserFS -> Name
-mkSysLocalName uniq fs = Name { n_uniq = uniq, n_sort = Local,
- n_occ = mkSrcVarOcc fs, n_prov = systemProvenance }
-
-mkTopName :: Unique -> Module -> FAST_STRING -> Name
- -- Make a top-level name; make it Global if top-level
- -- things should be externally visible; Local otherwise
- -- This chap is only used *after* the tidyCore phase
- -- Notably, it is used during STG lambda lifting
- --
- -- We have to make sure that the name is globally unique
- -- and we don't have tidyCore to help us. So we append
- -- the unique. Hack! Hack!
-mkTopName uniq mod fs
- = Name { n_uniq = uniq,
- n_sort = mk_top_sort mod,
- n_occ = mkSrcVarOcc (_PK_ ((_UNPK_ fs) ++ show uniq)),
- n_prov = LocalDef noSrcLoc NotExported }