diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-11-03 12:04:53 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-11-21 01:14:09 -0500 |
commit | ecfd0278cb811c93853c176fe5df60222d1a8fb5 (patch) | |
tree | 7fc212d973a0d9e5e67e13011bf30907b1458228 /docs/users_guide | |
parent | 53ad67eacacde8fde452f1a323d5886183375182 (diff) | |
download | haskell-ecfd0278cb811c93853c176fe5df60222d1a8fb5.tar.gz |
Move Plugins into HscEnv (#17957)
Loaded plugins have nothing to do in DynFlags so this patch moves them
into HscEnv (session state).
"DynFlags plugins" become "Driver plugins" to still be able to register
static plugins.
Bump haddock submodule
Diffstat (limited to 'docs/users_guide')
-rw-r--r-- | docs/users_guide/extending_ghc.rst | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/docs/users_guide/extending_ghc.rst b/docs/users_guide/extending_ghc.rst index 483334d17c..dbd527cb2b 100644 --- a/docs/users_guide/extending_ghc.rst +++ b/docs/users_guide/extending_ghc.rst @@ -1341,13 +1341,17 @@ this idea can be seen below: import GHC.Tc.Utils.Monad plugin :: Plugin - plugin = defaultPlugin { dynflagsPlugin = hooksP } - - hooksP :: [CommandLineOption] -> DynFlags -> IO DynFlags - hooksP opts dflags = return $ dflags - { hooks = (hooks dflags) - { runMetaHook = Just (fakeRunMeta opts) } - } + plugin = driverPlugin { driverPlugin = hooksP } + + hooksP :: [CommandLineOption] -> HscEnv -> IO HscEnv + hooksP opts hsc_env = do + let dflags = hsc_dflags hsc_env + dflags' = dflags + { hooks = (hooks dflags) + { runMetaHook = Just (fakeRunMeta opts) } + } + hsc_env' = hsc_env { hsc_dflags = dflags' } + return hsc_env' -- This meta hook doesn't actually care running code in splices, -- it just replaces any expression splice with the "0" |