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

Feb 17, 2011 5:05:25 PM (9 years ago)



  • Commentary/Compiler/ModuleTypes

    v1 v1  
     3= Module Types =
     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)]].
     7== Module ==
     9Location: [[GhcFile(compiler/basicTypes/Module.lhs)]]
     11The '''Module''' data type is simply an identifier of a module; its fully qualified name.
     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)
     21newtype ModuleName = ModuleName FastString
     24== !ModIface ==
     26Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     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.
     30== !ModDetails ==
     32Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     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.
     36=== !ModGuts ===
     38Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     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.
     42== !ModSummary ==
     44Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     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.
     48== !HomeModInfo ==
     50Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     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.
     54== !HomePackageTable ==
     56Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     58The home package table describes already-compiled home-package modules, /excluding/ the module we are compiling right now.
     60== !ExternalPackageState ==
     62Location: [[GhcFile(compiler/main/HscTypes.lhs)]]
     64Stores information about other packages that we have pulled in while compiling the current module.