Skip to content

Simplify implementation of eval plugin #3249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

mpickering
Copy link
Contributor

@mpickering mpickering commented Oct 5, 2022

The plugin was implemented by calling "load" which circumvents all of HLSs caching mechanisms for interface files and linkables. Instead we should work like the other typechecking functions which get all the stuff we need using HLS rules and setup the HscEnv with all the state in the right places.

The key part to this is setting up all the HPT modules with linkables if they are depenedencies of the module we are trying to run a function from.

The plugin was implemented by calling "load" which circumvents all of
HLSs caching mechanisms for interface files and linkables. Instead we
should work like the other typechecking functions which get all the
stuff we need using HLS rules and setup the HscEnv with all the state in
the right places.

The key part to this is setting up all the HPT modules with linkables if
they are depenedencies of the module we are trying to run a function
from.
@mpickering mpickering requested a review from pepeiborra as a code owner October 5, 2022 13:44
@michaelpj
Copy link
Collaborator

Would you like to add yourself to CODEOWNERS for this plugin? :) Since it's currently totally unloved.

Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me, but I'm far from an expert on the GHC interactive evaluation internals.

Comment on lines -764 to -782
setupDynFlagsForGHCiLike :: HscEnv -> DynFlags -> IO DynFlags
setupDynFlagsForGHCiLike env dflags = do
let dflags3 = setInterpreterLinkerOptions dflags
platform = targetPlatform dflags3
evalWays = Compat.hostFullWays
dflags3a = setWays evalWays dflags3
dflags3b =
foldl gopt_set dflags3a $
concatMap (Compat.wayGeneralFlags platform) evalWays
dflags3c =
foldl gopt_unset dflags3b $
concatMap (Compat.wayUnsetGeneralFlags platform) evalWays
dflags4 =
dflags3c
`gopt_set` Opt_ImplicitImportQualified
`gopt_set` Opt_IgnoreOptimChanges
`gopt_set` Opt_IgnoreHpcChanges
`gopt_unset` Opt_DiagnosticsShowCaret
Compat.hsc_dflags <$> Compat.initializePlugins (Compat.hscSetFlags dflags4 env)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it ok to skip this setup? It was copied from GHCi to try and replicate the same behaviour

@wz1000
Copy link
Collaborator

wz1000 commented Dec 14, 2022

Superseded by #3391

@wz1000 wz1000 closed this Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants