Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

ghc-mod and GHC hook functions #897

Open
alanz opened this issue Jun 25, 2017 · 0 comments
Open

ghc-mod and GHC hook functions #897

alanz opened this issue Jun 25, 2017 · 0 comments

Comments

@alanz
Copy link
Collaborator

alanz commented Jun 25, 2017

In haskell-ide-engine, and HaRe, we make use of runGmltWith.

The usage requires a GHC hscFrontendHook to store the GHC ASTs as the targets are loaded.

Since this usage is driven by IDE usage, we have no control of when a file will be loaded. As the GHC session is cached in ghc-mod, this means that calling runGmltWith with a specific target file name will call GHC loadTargets for it, but this may not result in actual compilation as the GHC session already has it, and the GHC recompilation checker will not allow re-loading.

So, we need to be able to adjust the DynFlags for the listed target modules to have

  • Set Opt_ForceRecomp to force a recompile despite the source not being newer
  • Set the hscFrontendHook

In the GHC API compilation process, this can be done after GHC.depanal which returns the ModuleGraph, where each component ModSummary has the DynFlags that will be used to load the module, but before calling GHC.load

After GHC.load the Opt_ForceRecomp should be unset, lest it results in unneeded recompilation in other loads.

From an API perspective, the question is how this requirement should be specified.

There are currently two alternatives

  1. Pass an additional parameter of the form Maybe (GHC.hook -> GHC.hook), which if set signals that the ModSummarys should be adjusted as above. This is currently implemented in the tweak-mod-summary branch.

  2. As proposed by @DanielG, amend the target list parameter, currently [Either FilePath ModuleName] to include a pair of functions for updating the DynFlags and the Hooks, so that future ModSummary and Hook requirements can also be met.

Note: in the current https://github.com/alanz/ghc-mod/tree/target-tweak-modsummary branch, implementing option 1 of the alternatives, there is an issue wrt to setting Interactive mode, in which case the individual modsummary tweaks do not seem to take effect. This would have to be sorted out to make option 2 viable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant