Changes between Version 15 and Version 16 of Commentary/Compiler/RdrNameType
- Timestamp:
- Sep 21, 2015 1:39:15 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Commentary/Compiler/RdrNameType
v15 v16 4 4 = {{{RdrNames}}}, {{{Modules}}}, and {{{OccNames}}} = 5 5 6 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 [[GhcFile(compiler/basicTypes/RdrName. lhs)]]:6 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 [[GhcFile(compiler/basicTypes/RdrName.hs)]]: 7 7 {{{ 8 8 data RdrName … … 34 34 == The `Module` and `ModuleName` types == 35 35 36 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 [[GhcFile(compiler/basicTypes/Module. lhs)]] and [[GhcFile(compiler/main/PackageConfig.hs)]], but here are the key definitions:36 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 [[GhcFile(compiler/basicTypes/Module.hs)]] and [[GhcFile(compiler/main/PackageConfig.hs)]], but here are the key definitions: 37 37 {{{ 38 38 newtype PackageId = PId FastString … … 49 49 50 50 An {{{OccName}}} is more-or-less just a string, like "foo" or "Tree", giving the (unqualified) name of an entity. 51 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 [[GhcFile(compiler/basicTypes/OccName. lhs)]]:51 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 [[GhcFile(compiler/basicTypes/OccName.hs)]]: 52 52 {{{ 53 53 data OccName = OccName