Plugins

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

Plugins

Synopsis

- data FrontendPlugin = FrontendPlugin {
  - frontend :: FrontendPluginAction
  }
- defaultFrontendPlugin :: FrontendPlugin
- type FrontendPluginAction = [String] -> [(String, Maybe Phase)] -> Ghc ()
- data Plugin = Plugin {
  - installCoreToDos :: CorePlugin
  - tcPlugin :: TcPlugin
  - pluginRecompile :: [CommandLineOption] -> IO PluginRecompile
  - parsedResultAction :: [CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule
  - renamedResultAction :: [CommandLineOption] -> TcGblEnv -> HsGroup GhcRn -> TcM (TcGblEnv, HsGroup GhcRn)
  - typeCheckResultAction :: [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv
  - spliceRunAction :: [CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc)
  - interfaceLoadAction :: forall lcl. [CommandLineOption] -> ModIface -> IfM lcl ModIface
  }
- type CommandLineOption = String
- data LoadedPlugin = LoadedPlugin {
  - lpPlugin :: Plugin
  - lpModule :: ModIface
  - lpArguments :: [CommandLineOption]
  }
- lpModuleName :: LoadedPlugin -> ModuleName
- defaultPlugin :: Plugin
- keepRenamedSource :: [CommandLineOption] -> TcGblEnv -> HsGroup GhcRn -> TcM (TcGblEnv, HsGroup GhcRn)
- withPlugins :: Monad m => DynFlags -> PluginOperation m a -> a -> m a
- withPlugins_ :: Monad m => DynFlags -> ConstPluginOperation m a -> a -> m ()
- data PluginRecompile
  - = ForceRecompile
  - | NoForceRecompile
  - | MaybeRecompile Fingerprint
- purePlugin :: [CommandLineOption] -> IO PluginRecompile
- impurePlugin :: [CommandLineOption] -> IO PluginRecompile
- flagRecompile :: [CommandLineOption] -> IO PluginRecompile

# Documentation

data FrontendPlugin #

Constructors

FrontendPlugin |
Fields frontend :: FrontendPluginAction

defaultFrontendPlugin :: FrontendPlugin #

type FrontendPluginAction = [String] -> [(String, Maybe Phase)] -> Ghc () #

data Plugin #

`Plugin` is the compiler plugin data type. Try to avoid constructing one of these directly, and just modify some fields of `defaultPlugin` instead: this is to try and preserve source-code compatibility when we add fields to this.

Nonetheless, this API is preliminary and highly likely to change in the future.

Constructors

Plugin |
Fields installCoreToDos :: CorePlugin 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 :: TcPlugin An optional typechecker plugin, which may modify the behaviour of the constraint solver. pluginRecompile :: [CommandLineOption] -> IO PluginRecompile Specify how the plugin should affect recompilation. parsedResultAction :: [CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule Modify the module when it is parsed. This is called by HscMain when the parsing is successful. renamedResultAction :: [CommandLineOption] -> TcGblEnv -> HsGroup GhcRn -> TcM (TcGblEnv, HsGroup GhcRn) Modify each group after it is renamed. This is called after each `HsGroup` has been renamed. typeCheckResultAction :: [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv Modify the module when it is type checked. This is called add the very end of typechecking. spliceRunAction :: [CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc) Modify the TH splice or quasiqoute before it is run. interfaceLoadAction :: forall lcl. [CommandLineOption] -> ModIface -> IfM lcl ModIface Modify an interface that have been loaded. This is called by LoadIface when an interface is successfully loaded. Not applied to the loading of the plugin interface. Tools that rely on information from modules other than the currently compiled one should implement this function.

type CommandLineOption = String #

Command line options gathered from the -PModule.Name:stuff syntax are given to you as this type

data LoadedPlugin #

A plugin with its arguments. The result of loading the plugin.

Constructors

LoadedPlugin |
Fields lpPlugin :: Plugin the actual callable plugin lpModule :: ModIface the module containing the plugin lpArguments :: [CommandLineOption] command line arguments for the plugin

lpModuleName :: LoadedPlugin -> ModuleName #

defaultPlugin :: Plugin #

Default plugin: does nothing at all! For compatibility reasons you should base all your plugin definitions on this default value.

keepRenamedSource :: [CommandLineOption] -> TcGblEnv -> HsGroup GhcRn -> TcM (TcGblEnv, HsGroup GhcRn) #

A renamer plugin which mades the renamed source available in a typechecker plugin.

withPlugins :: Monad m => DynFlags -> PluginOperation m a -> a -> m a #

Perform an operation by using all of the plugins in turn.

withPlugins_ :: Monad m => DynFlags -> ConstPluginOperation m a -> a -> m () #

Perform a constant operation by using all of the plugins in turn.

data PluginRecompile #

Constructors

ForceRecompile |
NoForceRecompile |
MaybeRecompile Fingerprint |

Instances

Semigroup PluginRecompile # |
Instance details Defined in Plugins Methods (<>) :: PluginRecompile -> PluginRecompile -> PluginRecompile Source # sconcat :: NonEmpty PluginRecompile -> PluginRecompile Source # stimes :: Integral b => b -> PluginRecompile -> PluginRecompile Source #
Monoid PluginRecompile # |
Instance details Defined in Plugins Methods mempty :: PluginRecompile Source # mappend :: PluginRecompile -> PluginRecompile -> PluginRecompile Source # mconcat :: [PluginRecompile] -> PluginRecompile Source #
Outputable PluginRecompile # |
Instance details Defined in Plugins Methods ppr :: PluginRecompile -> SDoc # pprPrec :: Rational -> PluginRecompile -> SDoc #

purePlugin :: [CommandLineOption] -> IO PluginRecompile #

impurePlugin :: [CommandLineOption] -> IO PluginRecompile #

flagRecompile :: [CommandLineOption] -> IO PluginRecompile #