ghc-9.13: The GHC API
Safe HaskellNone
LanguageGHC2021

GHC.Unit.Module.External.Graph

Description

Like Graph but for the ExternalModuleGraph which is stored in the EPS.

Synopsis

External Module Graph

A module graph for the EPS.

data ExternalModuleGraph Source #

Instances

Instances details
Outputable ExternalModuleGraph Source # 
Instance details

Defined in GHC.Unit.Module.External.Graph

data ExternalGraphNode Source #

Constructors

NodeHomePackage

A node for a home package module that is inserted in the EPS.

INVARIANT: This type of node can only ever exist if compiling in one-shot mode. In --make mode, it is imperative that the EPS doesn't have any home package modules ever.

NodeExternalPackage

A node for packages with at least one module loaded in the EPS.

Edge from A to NodeExternalPackage p when A has p as a direct package dependency.

Instances

Instances details
Outputable ExternalGraphNode Source # 
Instance details

Defined in GHC.Unit.Module.External.Graph

emgNodeKey :: ExternalGraphNode -> ExternalKey Source #

The graph key for a given node

emgNodeDeps :: Bool -> ExternalGraphNode -> [ExternalKey] Source #

Get the dependencies of an ExternalNode

Extending

The ExternalModuleGraph is a structure which is incrementally updated as the ExternalPackageState (EPS) is updated (when an iface is loaded, in loadInterface).

Therefore, there is an operation for extending the ExternalModuleGraph, unlike ModuleGraph, which is constructed once during downsweep and never altered (since all of the home units dependencies are fully known then).

Loading

As mentioned in the top-level haddocks for the extendExternalModuleGraph, the external module graph is incrementally updated as interfaces are loaded. This module graph keeps an additional cache registering which modules have already been fully loaded.

This cache is necessary to quickly check when a full-transitive-closure reachability query would be valid for some module.

Such a query may be invalid if ran on a module in the ExternalModuleGraph whose dependencies have not yet been fully loaded into the EPS. (Recall that interfaces are lazily loaded, and the ExternalModuleGraph is only incrementally updated).

To guarantee the full transitive closure of a given module is completely loaded into the EPS (i.e. all interfaces of the modules below this one are also loaded), see loadExternalGraphBelow in Load.

Reachability

Fast reachability queries on the external module graph. Similar to reachability queries on Graph.

emgReachableLoop :: ExternalModuleGraph -> ExternalKey -> Maybe [ExternalGraphNode] Source #

Return all nodes reachable from the given key, also known as its full transitive closure.

Nothing if the key couldn't be found in the graph.

emgReachableLoopMany :: ExternalModuleGraph -> [ExternalKey] -> [ExternalGraphNode] Source #

Return all nodes reachable from all of the given keys.