
#8050: add a required wrapper around plugin installers ------------------------------------+------------------------------------- Reporter: nfrisby | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- While trying to expand [http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/compiler- plugins.html#writing-compiler-plugins the CoreMonad.reinitializeGlobals mechanism], I proposed an alternative that SPJ noted could be more generally useful. The nub of the idea is to require plugins to apply a distinguished function to their installation function. Instead of defining the plugin as {{{ module APlugin (plugin) where import GhcPlugins plugin :: Plugin plugin = defaultPlugin {installCoreToDos = install} install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] install = … }}} plugins would be defined as {{{ module APlugin (plugin) where import GhcPlugins plugin :: Plugin plugin = defaultPlugin {installCoreToDos = mkPluginInstaller install} install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] install = install = … }}} The new function `mkPluginInstaller` provides a hook for GHC developers to process the plugin, hidden from the plugin author. For example, it could encapsulate the current `reinitializeGlobals` mechanism. I'm not sure if using an abstract type to enforce that this function is called is necessary, but it's an option. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8050 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler