- = ParsedIface
- Module -- Module name
- Version -- Module version number
- [ImportVersion OccName] -- Usages
- [ExportItem] -- Exports
- [Module] -- Special instance modules
- [(OccName,Fixity)] -- Fixities
- [(Version, RdrNameHsDecl)] -- Local definitions
- [RdrNameInstDecl] -- Local instance declarations
-
-type InterfaceDetails = (VersionInfo Name, -- Version information for what this module imports
- ExportEnv, -- What this module exports
- [Module]) -- Instance modules
-
-type RdrNamePragma = () -- Fudge for now
--------------------
-
-data Ifaces = Ifaces
- Module -- Name of this module
- (FiniteMap Module (IfaceFlavour, -- Exports
- Version,
- Avails,
- [(OccName,Fixity)]))
- DeclsMap
-
- NameSet -- All the names (whether "big" or "small", whether wired-in or not,
- -- whether locally defined or not) that have been slurped in so far.
-
- [(Name,Version)] -- All the (a) non-wired-in (b) "big" (c) non-locally-defined names that
- -- have been slurped in so far, with their versions.
- -- This is used to generate the "usage" information for this module.
- -- Subset of the previous field.
-
- (Bag IfaceInst, NameSet) -- The as-yet un-slurped instance decls; this bag is depleted when we
- -- slurp an instance decl so that we don't slurp the same one twice.
- -- Together with them is the set of tycons/classes that may allow
- -- the instance decls in.
-
- (FiniteMap Name RdrNameTyDecl)
- -- Deferred data type declarations; each has the following properties
- -- * it's a data type decl
- -- * its TyCon is needed
- -- * the decl may or may not have been slurped, depending on whether any
- -- of the constrs are needed.
-
- [Module] -- Set of modules with "special" instance declarations
- -- Excludes this module
-
-
-type DeclsMap = FiniteMap Name (Version, AvailInfo, RdrNameHsDecl)
-type IfaceInst = ((Module, RdrNameInstDecl), -- Instance decl
- [Name]) -- "Gate" names. Slurp this instance decl when this
- -- list becomes empty. It's depleted whenever we
- -- slurp another type or class decl.
+ = ParsedIface {
+ pi_mod :: Module, -- Complete with package info
+ pi_vers :: Version, -- Module version number
+ pi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
+ pi_usages :: [ImportVersion OccName], -- Usages
+ pi_exports :: (Version, [ExportItem]), -- Exports
+ pi_decls :: [(Version, RdrNameTyClDecl)], -- Local definitions
+ pi_fixity :: [RdrNameFixitySig], -- Local fixity declarations,
+ pi_insts :: [RdrNameInstDecl], -- Local instance declarations
+ pi_rules :: (Version, [RdrNameRuleDecl]), -- Rules, with their version
+ pi_deprecs :: IfaceDeprecs -- Deprecations
+ }
+\end{code}
+
+%************************************************************************
+%* *
+\subsection{The renamer state}
+%* *
+%************************************************************************
+
+\begin{code}
+data Ifaces = Ifaces {
+ -- PERSISTENT FIELDS
+ iPIT :: PackageIfaceTable,
+ -- The ModuleIFaces for modules in other packages
+ -- whose interfaces we have opened
+ -- The declarations in these interface files are held in
+ -- iDecls, iInsts, iRules (below), not in the mi_decls fields
+ -- of the iPIT. What _is_ in the iPIT is:
+ -- * The Module
+ -- * Version info
+ -- * Its exports
+ -- * Fixities
+ -- * Deprecations
+ -- The iPIT field is initialised from the compiler's persistent
+ -- package symbol table, and the renamer incrementally adds
+ -- to it.
+
+ iImpModInfo :: ImportedModuleInfo,
+ -- Modules that we know something about, because they are mentioned
+ -- in interface files, BUT which we have not loaded yet.
+ -- No module is both in here and in the PIT
+
+ iDecls :: DeclsMap,
+ -- A single, global map of Names to unslurped decls
+
+ iInsts :: IfaceInsts,
+ -- The as-yet un-slurped instance decls; this bag is depleted when we
+ -- slurp an instance decl so that we don't slurp the same one twice.
+ -- Each is 'gated' by the names that must be available before
+ -- this instance decl is needed.
+
+ iRules :: IfaceRules,
+ -- Similar to instance decls, only for rules
+
+ -- EPHEMERAL FIELDS
+ -- These fields persist during the compilation of a single module only
+ iSlurp :: NameSet,
+ -- All the names (whether "big" or "small", whether wired-in or not,
+ -- whether locally defined or not) that have been slurped in so far.
+ --
+ -- It's used for two things:
+ -- a) To record what we've already slurped, so
+ -- we can no-op if we try to slurp it again
+ -- b) As the 'gates' for importing rules. We import a rule
+ -- if all its LHS free vars have been slurped
+
+ iVSlurp :: (ModuleSet, NameSet)
+ -- The Names are all the (a) non-wired-in
+ -- (b) "big"
+ -- (c) non-locally-defined
+ -- (d) home-package
+ -- names that have been slurped in so far, with their versions.
+ -- This is used to generate the "usage" information for this module.
+ -- Subset of the previous field.
+ --
+ -- The module set is the non-home-package modules from which we have
+ -- slurped at least one name.
+ -- It's worth keeping separately, because there's no very easy
+ -- way to distinguish the "big" names from the "non-big" ones.
+ -- But this is a decision we might want to revisit.
+ }