ghc-lib-0.20210201: The GHC API, decoupled from GHC versions
Safe HaskellNone
LanguageHaskell2010

GHC.Driver.Make

Synopsis

Documentation

depanal Source #

Arguments

:: GhcMonad m 
=> [ModuleName]

excluded modules

-> Bool

allow duplicate roots

-> m ModuleGraph 

Perform a dependency analysis starting from the current targets and update the session with the new module graph.

Dependency analysis entails parsing the import directives and may therefore require running certain preprocessors.

Note that each ModSummary in the module graph caches its DynFlags. These DynFlags are determined by the current session DynFlags and the OPTIONS and LANGUAGE pragmas of the parsed module. Thus if you want changes to the DynFlags to take effect you need to call this function again. In case of errors, just throw them.

depanalE Source #

Arguments

:: GhcMonad m 
=> [ModuleName]

excluded modules

-> Bool

allow duplicate roots

-> m (ErrorMessages, ModuleGraph) 

Perform dependency analysis like in depanal. In case of errors, the errors and an empty module graph are returned.

depanalPartial Source #

Arguments

:: GhcMonad m 
=> [ModuleName]

excluded modules

-> Bool

allow duplicate roots

-> m (ErrorMessages, ModuleGraph)

possibly empty Bag of errors and a module graph.

Perform dependency analysis like depanal but return a partial module graph even in the face of problems with some modules.

Modules which have parse errors in the module header, failing preprocessors or other issues preventing them from being summarised will simply be absent from the returned module graph.

Unlike depanal this function will not update hsc_mod_graph with the new module graph.

load :: GhcMonad m => LoadHowMuch -> m SuccessFlag Source #

Try to load the program. See LoadHowMuch for the different modes.

This function implements the core of GHC's --make mode. It preprocesses, compiles and loads the specified modules, avoiding re-compilation wherever possible. Depending on the backend (see backend field) compiling and loading may result in files being created on disk.

Calls the defaultWarnErrLogger after each compiling each module, whether successful or not.

If errors are encountered during dependency analysis, the module depanalE returns together with the errors an empty ModuleGraph. After processing this empty ModuleGraph, the errors of depanalE are thrown. All other errors are reported using the defaultWarnErrLogger.

load' :: GhcMonad m => LoadHowMuch -> Maybe Messager -> ModuleGraph -> m SuccessFlag Source #

Generalized version of load which also supports a custom Messager (for reporting progress) and ModuleGraph (generally produced by calling depanal.

data LoadHowMuch Source #

Describes which modules of the module graph need to be loaded.

Constructors

LoadAllTargets

Load all targets and its dependencies.

LoadUpTo ModuleName

Load only the given module and its dependencies.

LoadDependenciesOf ModuleName

Load only the dependencies of the given module, but not the module itself.

instantiationNodes :: UnitState -> [ModuleGraphNode] Source #

Collect the instantiations of dependencies to create InstantiationNode work graph nodes. These are used to represent the type checking that is done after all the free holes (sigs in current package) relevant to that instantiation are compiled. This is necessary to catch some instantiation errors.

In the future, perhaps more of the work of instantiation could be moved here, instead of shoved in with the module compilation nodes. That could simplify backpack, and maybe hs-boot too.

downsweep Source #

Arguments

:: HscEnv 
-> [ExtendedModSummary]

Old summaries

-> [ModuleName] 
-> Bool 
-> IO [Either ErrorMessages ExtendedModSummary] 

Downsweep (dependency analysis)

Chase downwards from the specified root set, returning summaries for all home modules encountered. Only follow source-import links.

We pass in the previous collection of summaries, which is used as a cache to avoid recalculating a module summary if the source is unchanged.

The returned list of [ModSummary] nodes has one node for each home-package module, plus one for any hs-boot files. The imports of these nodes are all there, including the imports of non-home-package modules.

topSortModuleGraph Source #

Arguments

:: Bool

Drop hi-boot nodes? (see below)

-> ModuleGraph 
-> Maybe ModuleName

Root module name. If Nothing, use the full graph.

-> [SCC ModuleGraphNode] 

Topological sort of the module graph

Calculate SCCs of the module graph, possibly dropping the hi-boot nodes The resulting list of strongly-connected-components is in topologically sorted order, starting with the module(s) at the bottom of the dependency graph (ie compile them first) and ending with the ones at the top.

Drop hi-boot nodes (first boolean arg)?

  • False: treat the hi-boot summaries as nodes of the graph, so the graph must be acyclic
  • True: eliminate the hi-boot nodes, and instead pretend the a source-import of Foo is an import of Foo The resulting graph has no hi-boot nodes, but can be cyclic

summariseModule Source #

Arguments

:: HscEnv 
-> ModNodeMap ExtendedModSummary

Map of old summaries

-> IsBootInterface 
-> Located ModuleName 
-> Bool 
-> Maybe (StringBuffer, UTCTime) 
-> [ModuleName] 
-> IO (Maybe (Either ErrorMessages ExtendedModSummary)) 

hscSourceToIsBoot :: HscSource -> IsBootInterface Source #

Tests if an HscSource is a boot file, primarily for constructing elements of BuildModule. We conflate signatures and modules because they are bound in the same namespace; only boot interfaces can be disambiguated with `import {--}`.

findExtraSigImports :: HscEnv -> HscSource -> ModuleName -> IO [(Maybe FastString, Located ModuleName)] Source #

findExtraSigImports, but in a convenient form for GHC.Driver.Make and GHC.Tc.Module.

implicitRequirementsShallow :: HscEnv -> [(Maybe FastString, Located ModuleName)] -> IO ([ModuleName], [InstantiatedUnit]) Source #

Like implicitRequirements', but returns either the module name, if it is a free hole, or the instantiated unit the imported module is from, so that that instantiated unit can be processed and via the batch mod graph (rather than a transitive closure done here) all the free holes are still reachable.

noModError :: HscEnv -> SrcSpan -> ModuleName -> FindResult -> ErrMsg ErrDoc Source #

cyclicModuleErr :: [ModuleGraphNode] -> SDoc Source #

moduleGraphNodes :: Bool -> [ModuleGraphNode] -> (Graph SummaryNode, NodeKey -> Maybe SummaryNode) Source #

type SummaryNode = Node Int ModuleGraphNode Source #

data IsBootInterface #

Constructors

NotBoot 
IsBoot 

Instances

Instances details
Eq IsBootInterface 
Instance details

Defined in GHC.Unit.Types

Data IsBootInterface 
Instance details

Defined in GHC.Unit.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IsBootInterface -> c IsBootInterface #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c IsBootInterface #

toConstr :: IsBootInterface -> Constr #

dataTypeOf :: IsBootInterface -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c IsBootInterface) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsBootInterface) #

gmapT :: (forall b. Data b => b -> b) -> IsBootInterface -> IsBootInterface #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IsBootInterface -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IsBootInterface -> r #

gmapQ :: (forall d. Data d => d -> u) -> IsBootInterface -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> IsBootInterface -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> IsBootInterface -> m IsBootInterface #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IsBootInterface -> m IsBootInterface #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IsBootInterface -> m IsBootInterface #

Ord IsBootInterface 
Instance details

Defined in GHC.Unit.Types

Show IsBootInterface 
Instance details

Defined in GHC.Unit.Types

Binary IsBootInterface 
Instance details

Defined in GHC.Unit.Types

Methods

put_ :: BinHandle -> IsBootInterface -> IO ()

put :: BinHandle -> IsBootInterface -> IO (Bin IsBootInterface)

get :: BinHandle -> IO IsBootInterface

newtype ModNodeMap a Source #

Constructors

ModNodeMap 

Fields

Instances

Instances details
Functor ModNodeMap Source # 
Instance details

Defined in GHC.Driver.Make

Methods

fmap :: (a -> b) -> ModNodeMap a -> ModNodeMap b #

(<$) :: a -> ModNodeMap b -> ModNodeMap a #

Foldable ModNodeMap Source # 
Instance details

Defined in GHC.Driver.Make

Methods

fold :: Monoid m => ModNodeMap m -> m #

foldMap :: Monoid m => (a -> m) -> ModNodeMap a -> m #

foldMap' :: Monoid m => (a -> m) -> ModNodeMap a -> m #

foldr :: (a -> b -> b) -> b -> ModNodeMap a -> b #

foldr' :: (a -> b -> b) -> b -> ModNodeMap a -> b #

foldl :: (b -> a -> b) -> b -> ModNodeMap a -> b #

foldl' :: (b -> a -> b) -> b -> ModNodeMap a -> b #

foldr1 :: (a -> a -> a) -> ModNodeMap a -> a #

foldl1 :: (a -> a -> a) -> ModNodeMap a -> a #

toList :: ModNodeMap a -> [a] #

null :: ModNodeMap a -> Bool #

length :: ModNodeMap a -> Int #

elem :: Eq a => a -> ModNodeMap a -> Bool #

maximum :: Ord a => ModNodeMap a -> a #

minimum :: Ord a => ModNodeMap a -> a #

sum :: Num a => ModNodeMap a -> a #

product :: Num a => ModNodeMap a -> a #

Traversable ModNodeMap Source # 
Instance details

Defined in GHC.Driver.Make

Methods

traverse :: Applicative f => (a -> f b) -> ModNodeMap a -> f (ModNodeMap b) #

sequenceA :: Applicative f => ModNodeMap (f a) -> f (ModNodeMap a) #

mapM :: Monad m => (a -> m b) -> ModNodeMap a -> m (ModNodeMap b) #

sequence :: Monad m => ModNodeMap (m a) -> m (ModNodeMap a) #

modNodeMapLookup :: ModNodeKey -> ModNodeMap a -> Maybe a Source #

modNodeMapInsert :: ModNodeKey -> a -> ModNodeMap a -> ModNodeMap a Source #