Skip to content

add a required wrapper around plugin installers

While trying to expand 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.

Trac metadata
Trac field Value
Version 7.6.3
Type Task
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information