Changes between Initial Version and Version 1 of Commentary/Compiler/ModuleTypes


Ignore:
Timestamp:
Feb 17, 2011 5:05:25 PM (4 years ago)
Author:
dterei
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/ModuleTypes

    v1 v1  
     1
     2
     3= Module Types =
     4
     5Here we attempt to describe some of the main data structures involved in GHC's representation and handling of Haksell modules. GHC uses a number of different data types to represent modules, for efficiency (some types load less information) and categorising how other modules relate to the one being compiled. Most these types are defined in [[GhcFile(compiler/main/HscTypes.lhs)]].
     6
     7== Module ==
     8
     9Location: [[GhcFile(compiler/basicTypes/Module.lhs)]]
     10
     11The '''Module''' data type is simply an identifier of a module; its fully qualified name.
     12
     13{{{
     14-- | A Module is a pair of a 'PackageId' and a 'ModuleName'.
     15data Module = Module {
     16   modulePackageId :: !PackageId,  -- pkg-1.0
     17   moduleName      :: !ModuleName  -- A.B.C
     18  }
     19  deriving (Eq, Ord)
     20
     21newtype ModuleName = ModuleName FastString
     22}}}
     23
     24== !ModIface ==
     25
     26Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     27
     28The '''!ModIface''' data type is one of the fullest representations of a module. It is a complete representation of a modules interface file ('''.hi'''). It is this data structure that is serialised to produce a modules '''.hi''' file.
     29
     30== !ModDetails ==
     31
     32Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     33
     34'''!ModDetails''' is essentially a cache for information in the '''!ModIface''' for home modules only. It stores information about a module after linking has taken place. '''!ModIface''' stores information about a module before linking. Information stored in a '''!ModDetails''' is created from a '''!ModIface''', typically during type checking.
     35
     36=== !ModGuts ===
     37
     38Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     39
     40A '''!ModGuts''' is carried through the compiler, accumulating stuff as it goes. There is only one '''!ModGuts''' at any time, the one for the module being compiled right now.  Once it is compiled, a '''!ModIface''' and '''!ModDetails''' are extracted and the '''!ModGuts''' is discarded.
     41
     42== !ModSummary ==
     43
     44Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     45
     46A '''!ModSummary''' stores a summary of a module that is suitable for recompilation checking. A '''!ModSummary''' is a node in the compilation manager's dependency graph.
     47
     48== !HomeModInfo ==
     49
     50Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     51
     52A '''!HomeModInfo''' stores information about a module in the package being compiled. It simply stores for the '''!ModIface''', '''!ModDetails''' and linkage information about a single module.
     53
     54== !HomePackageTable ==
     55
     56Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     57
     58The home package table describes already-compiled home-package modules, /excluding/ the module we are compiling right now.
     59
     60== !ExternalPackageState ==
     61
     62Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     63
     64Stores information about other packages that we have pulled in while compiling the current module.
     65