ghcide-2.9.0.0: The core of an IDE

Safe Haskell | None
Language | GHC2021

Development.IDE.GHC.Compat.Plugins

Contents

- Plugin Compat Types, and initialisation
- Static plugins
- Plugin messages

Description

Plugin Compat utils.

Synopsis

- data Plugin = Plugin {
  - installCoreToDos :: CorePlugin
  - tcPlugin :: TcPlugin
  - defaultingPlugin :: DefaultingPlugin
  - holeFitPlugin :: HoleFitPlugin
  - driverPlugin :: [CommandLineOption] -> HscEnv -> IO HscEnv
  - latePlugin :: LatePlugin
  - pluginRecompile :: [CommandLineOption] -> IO PluginRecompile
  - parsedResultAction :: [CommandLineOption] -> ModSummary -> ParsedResult -> Hsc ParsedResult
  - 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
  }
- defaultPlugin :: Plugin
- data PluginWithArgs = PluginWithArgs {
  - paPlugin :: Plugin
  - paArguments :: [CommandLineOption]
  }
- applyPluginsParsedResultAction :: HscEnv -> ModSummary -> ApiAnns -> ParsedSource -> PsMessages -> IO (ParsedSource, PsMessages)
- initializePlugins :: HscEnv -> IO HscEnv
- initPlugins :: HscEnv -> ModSummary -> IO (ModSummary, HscEnv)
- data StaticPlugin = StaticPlugin {
  - spPlugin :: PluginWithArgs
  }
- hsc_static_plugins :: HscEnv -> [StaticPlugin]
- data PsMessages = PsMessages {
  - psWarnings :: Messages PsWarning
  - psErrors :: Messages PsError
  }
- getPsMessages :: PState -> PsMessages

# Plugin Compat Types, and initialisation

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. defaultingPlugin :: DefaultingPlugin An optional defaulting plugin, which may specify the additional type-defaulting rules. holeFitPlugin :: HoleFitPlugin An optional plugin to handle hole fits, which may re-order or change the list of valid hole fits and refinement hole fits. driverPlugin :: [CommandLineOption] -> HscEnv -> IO HscEnv An optional plugin to update `HscEnv`, right after plugin loading. This can be used to register hooks or tweak any field of `DynFlags` before doing actual work on a module. Since: ghc-8.10.1 latePlugin :: LatePlugin A plugin that runs after interface creation and after late cost centre insertion. Useful for transformations that should not impact interfaces or optimization at all. Since: ghc-9.10.1 pluginRecompile :: [CommandLineOption] -> IO PluginRecompile Specify how the plugin should affect recompilation. parsedResultAction :: [CommandLineOption] -> ModSummary -> ParsedResult -> Hsc ParsedResult Modify the module when it is parsed. This is called by GHC.Driver.Main when the parser has produced no or only non-fatal errors. Compilation will fail if the messages produced by this function contain any errors. 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 at 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 GHC.Iface.Load 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.

defaultPlugin :: Plugin #

Default plugin: does nothing at all, except for marking that safe inference has failed unless `-fplugin-trustworthy` is passed. For compatibility reason you should base all your plugin definitions on this default value.

data PluginWithArgs #

Constructors

PluginWithArgs |
Fields paPlugin :: Plugin the actual callable plugin paArguments :: [CommandLineOption] command line arguments for the plugin

applyPluginsParsedResultAction :: HscEnv -> ModSummary -> ApiAnns -> ParsedSource -> PsMessages -> IO (ParsedSource, PsMessages) #

initializePlugins :: HscEnv -> IO HscEnv #

initPlugins :: HscEnv -> ModSummary -> IO (ModSummary, HscEnv) #

Plugins aren't stored in ModSummary anymore since GHC 9.2, but this function still returns it for compatibility with 8.10

# Static plugins

data StaticPlugin #

A static plugin with its arguments. For registering compiled-in plugins through the GHC API.

Constructors

StaticPlugin |
Fields spPlugin :: PluginWithArgs the actual plugin together with its commandline arguments

hsc_static_plugins :: HscEnv -> [StaticPlugin] #

# Plugin messages

data PsMessages #

Errors and warnings produced by the parser

Constructors

PsMessages |
Fields psWarnings :: Messages PsWarning psErrors :: Messages PsError

getPsMessages :: PState -> PsMessages #