Typos in comments
[ghc.git] / compiler / main / Plugins.hs
1 module Plugins (
2 FrontendPlugin(..), defaultFrontendPlugin,
3 Plugin(..), CommandLineOption,
4 defaultPlugin
5 ) where
6
7 import CoreMonad ( CoreToDo, CoreM )
8 import TcRnTypes ( TcPlugin )
9 import GhcMonad
10 import DriverPhases
11
12
13 -- | Command line options gathered from the -PModule.Name:stuff syntax
14 -- are given to you as this type
15 type CommandLineOption = String
16
17 -- | 'Plugin' is the core compiler plugin data type. Try to avoid
18 -- constructing one of these directly, and just modify some fields of
19 -- 'defaultPlugin' instead: this is to try and preserve source-code
20 -- compatibility when we add fields to this.
21 --
22 -- Nonetheless, this API is preliminary and highly likely to change in
23 -- the future.
24 data Plugin = Plugin {
25 installCoreToDos :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo]
26 -- ^ Modify the Core pipeline that will be used for compilation.
27 -- This is called as the Core pipeline is built for every module
28 -- being compiled, and plugins get the opportunity to modify the
29 -- pipeline in a nondeterministic order.
30 , tcPlugin :: [CommandLineOption] -> Maybe TcPlugin
31 -- ^ An optional typechecker plugin, which may modify the
32 -- behaviour of the constraint solver.
33 }
34
35 -- | Default plugin: does nothing at all! For compatibility reasons
36 -- you should base all your plugin definitions on this default value.
37 defaultPlugin :: Plugin
38 defaultPlugin = Plugin {
39 installCoreToDos = const return
40 , tcPlugin = const Nothing
41 }
42
43 type FrontendPluginAction = [String] -> [(String, Maybe Phase)] -> Ghc ()
44 data FrontendPlugin = FrontendPlugin {
45 frontend :: FrontendPluginAction
46 }
47 defaultFrontendPlugin :: FrontendPlugin
48 defaultFrontendPlugin = FrontendPlugin { frontend = \_ _ -> return () }