... | ... | @@ -3,7 +3,7 @@ |
|
|
|
|
|
When the parser parses an identifier, it generates a `RdrName`. A `RdrName` is pretty much just a string, or a pair of strings, for a qualified name, such as `M.x`. Here's the data type declaration, from [compiler/GHC/Types/Name/Reader.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Types/Name/Reader.hs):
|
|
|
|
|
|
```wiki
|
|
|
```haskell
|
|
|
data RdrName
|
|
|
= Unqual OccName
|
|
|
-- Used for ordinary, unqualified occurrences
|
... | ... | @@ -36,7 +36,7 @@ For example, code generated by `deriving` might use an `Orig` to refer to `Prelu |
|
|
|
|
|
In GHC, a *module* is uniquely defined by a pair of the module name and the package where the module is defined. The details are in [compiler/GHC/Unit/Module.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Unit/Module.hs) and [compiler/GHC/Unit/Info.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Unit/Info.hs), but here are the key definitions:
|
|
|
|
|
|
```wiki
|
|
|
```haskell
|
|
|
newtype PackageId = PId FastString
|
|
|
|
|
|
newtype ModuleName = ModuleName FastString
|
... | ... | @@ -56,7 +56,7 @@ You'll notice that a `Qual` `RdrName` contains a `ModuleName`; which module is r |
|
|
An `OccName` is more-or-less just a string, like "foo" or "Tree", giving the (unqualified) name of an entity.
|
|
|
Well, not quite just a string, because in Haskell a name like "C" could mean a type constructor or data constructor, depending on context. So GHC defines a type `OccName` that is a pair of a `FastString` and a `NameSpace` indicating which name space the name is drawn from. The data type is defined (abstractly) in [compiler/GHC/Types/Name/Occurrence.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Types/Name/Occurrence.hs):
|
|
|
|
|
|
```wiki
|
|
|
```haskell
|
|
|
data OccName = OccName
|
|
|
{ occNameSpace :: !NameSpace
|
|
|
, occNameFS :: !FastString
|
... | ... | @@ -66,7 +66,7 @@ data OccName = OccName |
|
|
|
|
|
The name spaces are:
|
|
|
|
|
|
```wiki
|
|
|
```haskell
|
|
|
data NameSpace = VarName -- Variables, including "source" data constructors
|
|
|
| DataName -- "Real" data constructors
|
|
|
| TvName -- Type variables
|
... | ... | |