+%************************************************************************
+%* *
+\subsection{Predicates and selectors}
+%* *
+%************************************************************************
+
+\begin{code}
+nameUnique :: Name -> Unique
+nameModAndOcc :: Name -> (Module, OccName) -- Globals only
+nameOccName :: Name -> OccName
+nameModule :: Name -> Module
+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
+
+nameModule (Global _ mod occ _ _) = mod
+
+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
+
+nameSrcLoc (Local _ _ loc) = loc
+nameSrcLoc (Global _ _ _ _ (LocalDef _ loc)) = loc
+nameSrcLoc (Global _ _ _ _ (Imported _ loc)) = loc
+nameSrcLoc other = noSrcLoc
+
+isLocallyDefinedName (Local _ _ _) = True
+isLocallyDefinedName (Global _ _ _ _ (LocalDef _ _)) = True
+isLocallyDefinedName other = False
+
+-- Things the compiler "knows about" are in some sense
+-- "imported". When we are compiling the module where
+-- the entities are defined, we need to be able to pick
+-- them out, often in combination with isLocallyDefined.
+isWiredInName (Global _ _ _ (WiredInTyCon _) _) = True
+isWiredInName (Global _ _ _ (WiredInId _) _) = True
+isWiredInName _ = False
+
+maybeWiredInIdName :: Name -> Maybe Id
+maybeWiredInIdName (Global _ _ _ (WiredInId id) _) = Just id
+maybeWiredInIdName other = Nothing
+
+maybeWiredInTyConName :: Name -> Maybe TyCon
+maybeWiredInTyConName (Global _ _ _ (WiredInTyCon tc) _) = Just tc
+maybeWiredInTyConName other = Nothing
+
+
+isLocalName (Local _ _ _) = True
+isLocalName _ = False
+\end{code}