Changes between Version 2 and Version 3 of Commentary/Compiler/RdrNameType


Ignore:
Timestamp:
Sep 11, 2006 4:41:37 PM (9 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/RdrNameType

    v2 v3  
    11[ Up: [wiki:Commentary/Compiler/HscMain] ]
    22
    3 = {{{RdrNames}}} and {{{OccNames}}} =
     3= {{{RdrNames}}}, {{{Modules}}}, and {{{OccNames}}} =
    44
    55When 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)]]:
     
    3030        --  (c) by Template Haskell, when TH has generated a unique name
    3131}}}
    32 A {{{ModuleName}}} is just a {{{FastString}}} (see [[GhcFile(compiler/basicTypes/Module.lhs)]]). 
    33 But {{{OccName}}} is more interesting; next section.
     32
     33== The `Module` and `ModuleName` types ==
     34
     35In 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{{{
     37newtype PackageId = PId FastString
     38
     39newtype ModuleName = ModuleName FastString
     40
     41data Module = Module {
     42   modulePackageId :: !PackageId,  -- pkg-1.0
     43   moduleName      :: !ModuleName  -- A.B.C  }
     44}}}
     45You'll notice that a `Qual` `RdrName` contains a `ModuleName`; which module is referred to depends on the import declarations in that module.  In contrast, a `Orig` `RdrName` refers to a unique `Module`.
    3446
    3547== The {{{OccName}}} type ==