[GHC] #5941: Add compilation stage plugins
GHC
ghc-devs at haskell.org
Fri Nov 28 17:57:25 UTC 2014
#5941: Add compilation stage plugins
-------------------------------------+-------------------------------------
Reporter: tibbe | Owner:
Type: feature | Status: infoneeded
request | Milestone: 7.10.1
Priority: normal | Version: 7.4.1
Component: Compiler | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by rodlogic):
I find this a desirable feature, so I took a quick look.
It seems that tcPlugin is currently focused on a pluggable constraint
solver only:
{{{#!hs
data Plugin = Plugin {
installCoreToDos :: [CommandLineOption] -> [CoreToDo] -> CoreM
[CoreToDo]
-- ^ Modify the Core pipeline that will be used for compilation.
-- This is called as the Core pipeline is built for every module
-- being compiled, and plugins get the opportunity to modify the
-- pipeline in a nondeterministic order.
, tcPlugin :: [CommandLineOption] -> Maybe TcPlugin
-- ^ An optional typechecker plugin, which may modify the
-- behaviour of the constraint solver.
}
data TcPlugin = forall s. TcPlugin
{ tcPluginInit :: TcPluginM s
-- ^ Initialize plugin, when entering type-checker.
, tcPluginSolve :: s -> TcPluginSolver
-- ^ Solve some constraints.
-- TODO: WRITE MORE DETAILS ON HOW THIS WORKS.
, tcPluginStop :: s -> TcPluginM ()
-- ^ Clean up after the plugin, when exiting the type-checker.
}
type TcPluginSolver = [Ct] -- given
-> [Ct] -- derived
-> [Ct] -- wanted
-> TcPluginM TcPluginResult
}}}
At this point it seems that there are two main venues:
1. extend TcPlugin to add a hook for processing the final type-checked
module (and widening the scope of {{{tcPluginInit}}} and
{{{tcPluginSolve}}}), or
2. Add another plugin for AST hooks (ParsedModule, RenamedModule, and
TypecheckedModule).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/5941#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list