ghc-9.2.6: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Unit.Module.Graph

Synopsis

Documentation

data ModuleGraph Source #

A 'ModuleGraph' contains all the nodes from the home package (only). See 'ModuleGraphNode' for information about the nodes.

Modules need to be compiled. hs-boots need to be typechecked before the associated "real" module so modules with {-# SOURCE #-} imports can be built. Instantiations also need to be typechecked to ensure that the module fits the signature. Substantiation typechecking is roughly comparable to the check that the module and its hs-boot agree.

The graph is not necessarily stored in topologically-sorted order. Use topSortModuleGraph and flattenSCC to achieve this.

data ModuleGraphNode Source #

A 'ModuleGraphNode' is a node in the 'ModuleGraph'. Edges between nodes mark dependencies arising from module imports and dependencies arising from backpack instantiations.

Constructors

InstantiationNode InstantiatedUnit

Instantiation nodes track the instantiation of other units (backpack dependencies) with the holes (signatures) of the current package.

ModuleNode ExtendedModSummary

There is a module summary node for each module, signature, and boot module being built.

Instances

Instances details
Outputable ModuleGraphNode Source # 
Instance details

Defined in GHC.Unit.Module.Graph

extendMG :: ModuleGraph -> ExtendedModSummary -> ModuleGraph Source #

Add an ExtendedModSummary to ModuleGraph. Assumes that the new ModSummary is not an element of the ModuleGraph.

filterToposortToModules :: [SCC ModuleGraphNode] -> [SCC ModSummary] Source #

This function filters out all the instantiation nodes from each SCC of a topological sort. Use this with care, as the resulting "strongly connected components" may not really be strongly connected in a direct way, as instantiations have been removed. It would probably be best to eliminate uses of this function where possible.

mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph Source #

Map a function f over all the ModSummaries. To preserve invariants f can't change the isBoot status.

mgLookupModule :: ModuleGraph -> Module -> Maybe ModSummary Source #

Look up a ModSummary in the ModuleGraph

needsTemplateHaskellOrQQ :: ModuleGraph -> Bool Source #

Determines whether a set of modules requires Template Haskell or Quasi Quotes

Note that if the session's DynFlags enabled Template Haskell when depanal was called, then each module in the returned module graph will have Template Haskell enabled whether it is actually needed or not.