-nameUnique :: Name -> Unique
-nameModAndOcc :: Name -> (Module, OccName) -- Globals only
-nameOccName :: Name -> OccName
-nameString :: Name -> FAST_STRING -- A.b form
-nameSrcLoc :: Name -> SrcLoc
-isLocallyDefinedName :: Name -> Bool
-isExportedName :: Name -> Bool
-isWiredInName :: Name -> Bool
-isLocalName :: Name -> Bool
-
-
-
-nameUnique (Local u _ _) = u
-nameUnique (Global u _ _ _ _) = u
-
-nameOccName (Local _ occ _) = occ
-nameOccName (Global _ _ occ _ _) = occ
-
-nameModAndOcc (Global _ mod occ _ _) = (mod,occ)
-
-nameString (Local _ occ _) = occNameString occ
-nameString (Global _ mod occ _ _) = mod _APPEND_ SLIT(".") _APPEND_ occNameString occ
-
-isExportedName (Global _ _ _ _ (LocalDef Exported _)) = True
-isExportedName other = False
+mkInternalName :: Unique -> OccName -> SrcLoc -> Name
+mkInternalName uniq occ loc = Name { n_uniq = uniq, n_sort = Internal, n_occ = occ, n_loc = loc }
+ -- 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)
+
+mkExternalName :: Unique -> Module -> OccName -> Maybe Name -> SrcLoc -> Name
+mkExternalName uniq mod occ mb_parent loc
+ = Name { n_uniq = uniq, n_sort = External mod mb_parent,
+ n_occ = occ, n_loc = loc }
+
+mkWiredInName :: Module -> OccName -> Unique
+ -> Maybe Name -> TyThing -> BuiltInSyntax -> Name
+mkWiredInName mod occ uniq mb_parent thing built_in
+ = Name { n_uniq = uniq,
+ n_sort = WiredIn mod mb_parent thing built_in,
+ n_occ = occ, n_loc = wiredInSrcLoc }
+
+mkSystemName :: Unique -> UserFS -> Name
+mkSystemName uniq fs = Name { n_uniq = uniq, n_sort = System,
+ n_occ = mkVarOcc fs, n_loc = noSrcLoc }
+
+-- Use this version when the string is already encoded. Avoids duplicating
+-- the string each time a new name is created.
+mkSystemNameEncoded :: Unique -> EncodedFS -> Name
+mkSystemNameEncoded uniq fs = Name { n_uniq = uniq, n_sort = System,
+ n_occ = mkSysOccFS varName 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
+mkFCallName uniq str = Name { n_uniq = uniq, n_sort = Internal,
+ n_occ = mkFCallOcc str, n_loc = noSrcLoc }
+
+mkIPName :: Unique -> OccName -> Name
+mkIPName uniq occ
+ = Name { n_uniq = uniq,
+ n_sort = Internal,
+ n_occ = occ,
+ n_loc = noSrcLoc }
+\end{code}