ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Unit.External

Synopsis

- newtype ExternalUnitCache = ExternalUnitCache {
  - euc_eps :: IORef ExternalPackageState
  }
- initExternalUnitCache :: IO ExternalUnitCache
- eucEPS :: ExternalUnitCache -> IO ExternalPackageState
- data ExternalPackageState = EPS {
  - eps_is_boot :: !(InstalledModuleEnv ModuleNameWithIsBoot)
  - eps_PIT :: !PackageIfaceTable
  - eps_free_holes :: InstalledModuleEnv (UniqDSet ModuleName)
  - eps_PTE :: !PackageTypeEnv
  - eps_iface_bytecode :: !(ModuleEnv (IO Linkable))
  - eps_inst_env :: !PackageInstEnv
  - eps_fam_inst_env :: !PackageFamInstEnv
  - eps_rule_base :: !PackageRuleBase
  - eps_ann_env :: !PackageAnnEnv
  - eps_complete_matches :: !PackageCompleteMatches
  - eps_mod_fam_inst_env :: !(ModuleEnv FamInstEnv)
  - eps_stats :: !EpsStats
  }
- initExternalPackageState :: ExternalPackageState
- data EpsStats = EpsStats {
  - n_ifaces_in :: !Int
  - n_decls_in :: !Int
  - n_decls_out :: !Int
  - n_rules_in :: !Int
  - n_rules_out :: !Int
  - n_insts_in :: !Int
  - n_insts_out :: !Int
  }
- addEpsInStats :: EpsStats -> Int -> Int -> Int -> EpsStats
- type PackageTypeEnv = TypeEnv
- type PackageIfaceTable = ModuleEnv ModIface
- type PackageInstEnv = InstEnv
- type PackageFamInstEnv = FamInstEnv
- type PackageRuleBase = RuleBase
- type PackageCompleteMatches = CompleteMatches
- emptyPackageIfaceTable :: PackageIfaceTable

# Documentation

newtype ExternalUnitCache Source #

Information about the currently loaded external packages. This is mutable because packages will be demand-loaded during a compilation run as required.

Constructors

ExternalUnitCache |

Fields

- euc_eps :: IORef ExternalPackageState

initExternalUnitCache :: IO ExternalUnitCache Source #

eucEPS :: ExternalUnitCache -> IO ExternalPackageState Source #

data ExternalPackageState Source #

Information about other packages that we have slurped in by reading their interface files

Constructors

EPS |

Fields

- eps_is_boot :: !(InstalledModuleEnv ModuleNameWithIsBoot)

  In OneShot mode (only), home-package modules accumulate in the external package state, and are sucked in lazily. For these home-pkg modules (only) we need to record which are boot modules. We set this field after loading all the explicitly-imported interfaces, but before doing anything else

  The `ModuleName` part is not necessary, but it's useful for debug prints, and it's convenient because this field comes direct from `imp_dep_mods`

- eps_PIT :: !PackageIfaceTable

  The `ModIface`s for modules in external packages whose interfaces we have opened. The declarations in these interface files are held in the `eps_decls`, `eps_inst_env`, `eps_fam_inst_env` and `eps_rules` fields of this record, not in the `mi_decls` fields of the interface we have sucked in.

  What is in the PIT is:

  - The Module
  - Fingerprint info
  - Its exports
  - Fixities
  - Deprecations and warnings
- eps_free_holes :: InstalledModuleEnv (UniqDSet ModuleName)

  Cache for `mi_free_holes`. Ordinarily, we can rely on the `eps_PIT` for this information, EXCEPT that when we do dependency analysis, we need to look at the `Dependencies` of our imports to determine what their precise free holes are (`moduleFreeHolesPrecise`). We don't want to repeatedly reread in the interface for every import, so cache it here. When the PIT gets filled in we can drop these entries.

- eps_PTE :: !PackageTypeEnv

  Result of typechecking all the external package interface files we have sucked in. The domain of the mapping is external-package modules

- eps_iface_bytecode :: !(ModuleEnv (IO Linkable))

  If an interface was written with `-fwrite-if-simplified-core`, this will contain an IO action that compiles bytecode from core bindings.

  See Note [Interface Files with Core Definitions]

- eps_inst_env :: !PackageInstEnv

  The total `InstEnv` accumulated from all the external-package modules

- eps_fam_inst_env :: !PackageFamInstEnv

  The total `FamInstEnv` accumulated from all the external-package modules

- eps_rule_base :: !PackageRuleBase

  The total `RuleEnv` accumulated from all the external-package modules

- eps_ann_env :: !PackageAnnEnv

  The total `AnnEnv` accumulated from all the external-package modules

- eps_complete_matches :: !PackageCompleteMatches

  The total `CompleteMatches` accumulated from all the external-package modules

- eps_mod_fam_inst_env :: !(ModuleEnv FamInstEnv)

  The family instances accumulated from external packages, keyed off the module that declared them

- eps_stats :: !EpsStats

  Statistics about what was loaded from external packages

initExternalPackageState :: ExternalPackageState Source #

data EpsStats Source #

Accumulated statistics about what we are putting into the `ExternalPackageState`. "In" means stuff that is just read from interface files, "Out" means actually sucked in and type-checked

Constructors

EpsStats |

Fields

- n_ifaces_in :: !Int
- n_decls_in :: !Int
- n_decls_out :: !Int
- n_rules_in :: !Int
- n_rules_out :: !Int
- n_insts_in :: !Int
- n_insts_out :: !Int

addEpsInStats :: EpsStats -> Int -> Int -> Int -> EpsStats Source #

Add stats for one newly-read interface

type PackageTypeEnv = TypeEnv Source #

type PackageIfaceTable = ModuleEnv ModIface Source #

Helps us find information about modules in the imported packages

type PackageInstEnv = InstEnv Source #

type PackageFamInstEnv = FamInstEnv Source #

type PackageRuleBase = RuleBase Source #

type PackageCompleteMatches = CompleteMatches Source #

emptyPackageIfaceTable :: PackageIfaceTable Source #

Constructs an empty PackageIfaceTable