2 % (c) The University of Glasgow, 2000
4 \section[HscTypes]{Types for the per-module compiler}
10 #include "HsVersions.h"
14 %************************************************************************
16 \subsection{Module details}
18 %************************************************************************
20 A @ModDetails@ summarises everything we know about a compiled module
25 moduleExports :: Avails, -- What it exports
26 moduleEnv :: GlobalRdrEnv, -- Its top level environment
28 fixityEnv :: NameEnv Fixity,
29 deprecEnv :: NameEnv DeprecTxt,
30 typeEnv :: NameEnv TyThing, -- TyThing is in TcEnv.lhs
33 ruleEnv :: IdEnv [CoreRule] -- Domain includes Ids from other modules
40 type DeprecationEnv = NameEnv DeprecTxt -- Give reason for deprecation
42 type GlobalRdrEnv = RdrNameEnv [Name] -- The list is because there may be name clashes
43 -- These only get reported on lookup,
44 -- not on construction
46 data GenAvailInfo name = Avail name -- An ordinary identifier
47 | AvailTC name -- The name of the type or class
48 [name] -- The available pieces of type/class.
49 -- NB: If the type or class is itself
50 -- to be in scope, it must be in this list.
51 -- Thus, typically: AvailTC Eq [Eq, ==, /=]
53 -- Equality used when deciding if the interface has changed
55 type AvailEnv = NameEnv AvailInfo -- Maps a Name to the AvailInfo that contains it
56 type AvailInfo = GenAvailInfo Name
57 type RdrAvailInfo = GenAvailInfo OccName
58 type Avails = [AvailInfo]
62 %************************************************************************
66 %************************************************************************
69 -- ModIFace is nearly the same as RnMonad.ParsedIface.
70 -- Right now it's identical :)
73 mi_mod :: Module, -- Complete with package info
74 mi_vers :: Version, -- Module version number
75 mi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
76 mi_usages :: [ImportVersion OccName], -- Usages
77 mi_exports :: [ExportItem], -- Exports
78 mi_insts :: [RdrNameInstDecl], -- Local instance declarations
79 mi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions
80 mi_fixity :: (Version, [RdrNameFixitySig]), -- Local fixity declarations,
82 mi_rules :: (Version, [RdrNameRuleDecl]), -- Rules, with their version
83 mi_deprecs :: [RdrNameDeprecation] -- Deprecations
87 %************************************************************************
89 \subsection{The persistent compiler state}
91 %************************************************************************
94 data PersistentCompilerState
96 pcsPST :: PackageSymbolTable, -- Domain = non-home-package modules
97 pcsHP :: HoldingPen, -- Pre-slurped interface bits and pieces
98 pcsNS :: NameSupply -- Allocate uniques for names
101 type PackageSymbolTable = ModuleEnv ModDetails
104 = NS { nsUniqs :: UniqSupply,
105 nsNames :: FiniteMap (Module,OccName) Name -- Ensures that one original name gets one unique
106 nsIParam :: FiniteMap OccName Name -- Ensures that one implicit parameter name gets one unique
110 %************************************************************************
112 \subsection{The result of compiling one module}
114 %************************************************************************
117 = CompOK ModDetails -- new details (HST additions)
118 (Maybe (ModIFace, Linkable))
119 -- summary and code; Nothing => compilation not reqd
120 -- (old summary and code are still valid)
121 PersistentCompilerState -- updated PCS
124 | CompErrs PersistentCompilerState -- updated PCS
129 -- These two are only here to avoid recursion between CmCompile and
130 -- CompManager. They really ought to be in the latter.
131 type ModuleEnv a = UniqFM a -- Domain is Module
133 type HomeModMap = FiniteMap ModuleName Module -- domain: home mods only
134 type HomeSymbolTable = ModuleEnv ModDetails -- ditto
135 type HomeInterfaceTable = ModuleEnv ModIFace