Safe Haskell | None |
---|---|
Language | Haskell98 |
GHC uses several kinds of name internally:
OccName
: see "OccName#name_types"RdrName
: see "RdrName#name_types"Name
is the type of names that have had their scoping and binding resolved. They have anOccName
but also aUnique
that disambiguates Names that have the sameOccName
and indeed is used for allName
comparison. Names also contain information about where they originated from, see "Name#name_sorts"Id
: see "Id#name_types"Var
: see "Var#name_types"
- External, if they name things declared in other modules. Some external Names are wired in, i.e. they name primitives defined in the compiler itself
- Internal, if they name things in the module being compiled. Some internal Names are system names, if they are names manufactured by the compiler
- data Name
- data BuiltInSyntax
- mkSystemName :: Unique -> OccName -> Name
- mkSystemNameAt :: Unique -> OccName -> SrcSpan -> Name
- mkInternalName :: Unique -> OccName -> SrcSpan -> Name
- mkClonedInternalName :: Unique -> Name -> Name
- mkDerivedInternalName :: (OccName -> OccName) -> Unique -> Name -> Name
- mkSystemVarName :: Unique -> FastString -> Name
- mkSysTvName :: Unique -> FastString -> Name
- mkFCallName :: Unique -> String -> Name
- mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> Name
- mkWiredInName :: Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
- nameUnique :: Name -> Unique
- setNameUnique :: Name -> Unique -> Name
- nameOccName :: Name -> OccName
- nameModule :: Name -> Module
- nameModule_maybe :: Name -> Maybe Module
- tidyNameOcc :: Name -> OccName -> Name
- hashName :: Name -> Int
- localiseName :: Name -> Name
- mkLocalisedOccName :: Module -> (Maybe String -> OccName -> OccName) -> Name -> OccName
- nameSrcLoc :: Name -> SrcLoc
- nameSrcSpan :: Name -> SrcSpan
- pprNameDefnLoc :: Name -> SDoc
- pprDefinedAt :: Name -> SDoc
- isSystemName :: Name -> Bool
- isInternalName :: Name -> Bool
- isExternalName :: Name -> Bool
- isTyVarName :: Name -> Bool
- isTyConName :: Name -> Bool
- isDataConName :: Name -> Bool
- isValName :: Name -> Bool
- isVarName :: Name -> Bool
- isWiredInName :: Name -> Bool
- isBuiltInSyntax :: Name -> Bool
- wiredInNameTyThing_maybe :: Name -> Maybe TyThing
- nameIsLocalOrFrom :: Module -> Name -> Bool
- stableNameCmp :: Name -> Name -> Ordering
- class NamedThing a where
- getOccName :: a -> OccName
- getName :: a -> Name
- getSrcLoc :: NamedThing a => a -> SrcLoc
- getSrcSpan :: NamedThing a => a -> SrcSpan
- getOccString :: NamedThing a => a -> String
- pprInfixName :: (Outputable a, NamedThing a) => a -> SDoc
- pprPrefixName :: (Outputable a, NamedThing a) => a -> SDoc
- pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc
- module OccName
The main types
A unique, unambigious name for something, containing information about where that thing originated.
data BuiltInSyntaxSource
BuiltInSyntax is for things like (:)
, []
and tuples,
which have special syntactic forms. They aren't in scope
as such.
Creating Name
s
mkSystemName :: Unique -> OccName -> NameSource
Create a name brought into being by the compiler
mkClonedInternalName :: Unique -> Name -> NameSource
mkSystemVarName :: Unique -> FastString -> NameSource
mkSysTvName :: Unique -> FastString -> NameSource
mkFCallName :: Unique -> String -> NameSource
Make a name for a foreign call
mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> NameSource
Create a name which definitely originates in the given module
mkWiredInName :: Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> NameSource
Create a name which is actually defined by the compiler itself
Manipulating and deconstructing Name
s
nameUnique :: Name -> UniqueSource
setNameUnique :: Name -> Unique -> NameSource
nameOccName :: Name -> OccNameSource
nameModule :: Name -> ModuleSource
tidyNameOcc :: Name -> OccName -> NameSource
localiseName :: Name -> NameSource
Make the Name
into an internal name, regardless of what it was to begin with
mkLocalisedOccName :: Module -> (Maybe String -> OccName -> OccName) -> Name -> OccNameSource
Create a localised variant of a name.
If the name is external, encode the original's module name to disambiguate.
nameSrcLoc :: Name -> SrcLocSource
nameSrcSpan :: Name -> SrcSpanSource
pprNameDefnLoc :: Name -> SDocSource
pprDefinedAt :: Name -> SDocSource
Predicates on Name
s
isSystemName :: Name -> BoolSource
isInternalName :: Name -> BoolSource
isExternalName :: Name -> BoolSource
isTyVarName :: Name -> BoolSource
isTyConName :: Name -> BoolSource
isDataConName :: Name -> BoolSource
isWiredInName :: Name -> BoolSource
isBuiltInSyntax :: Name -> BoolSource
nameIsLocalOrFrom :: Module -> Name -> BoolSource
stableNameCmp :: Name -> Name -> OrderingSource
Class NamedThing
and overloaded friends
class NamedThing a whereSource
A class allowing convenient access to the Name
of various datatypes
getSrcLoc :: NamedThing a => a -> SrcLocSource
getSrcSpan :: NamedThing a => a -> SrcSpanSource
getOccString :: NamedThing a => a -> StringSource
pprInfixName :: (Outputable a, NamedThing a) => a -> SDocSource
pprPrefixName :: (Outputable a, NamedThing a) => a -> SDocSource
module OccName