ghc-lib-parser-9.6.4.20240109: The GHC API, decoupled from GHC versions
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Driver.Plugins

Description

Definitions for writing plugins for GHC. Plugins can hook into several areas of the compiler. See the Plugin type. These plugins include type-checker plugins, source plugins, and core-to-core plugins.

Synopsis

Plugins

data Plugins Source #

Constructors

Plugins 

Fields

  • staticPlugins :: ![StaticPlugin]

    Static plugins which do not need dynamic loading. These plugins are intended to be added by GHC API users directly to this list.

    To add dynamically loaded plugins through the GHC API see addPluginModuleName instead.

  • externalPlugins :: ![ExternalPlugin]

    External plugins loaded directly from libraries without loading module interfaces.

  • loadedPlugins :: ![LoadedPlugin]

    Plugins dynamically loaded after processing arguments. What will be loaded here is directed by DynFlags.pluginModNames. Arguments are loaded from DynFlags.pluginModNameOpts.

    The purpose of this field is to cache the plugins so they don't have to be loaded each time they are needed. See initializePlugins.

  • loadedPluginDeps :: !([Linkable], PkgsLoaded)

    The object files required by the loaded plugins See Note [Plugin dependencies]

data Plugin Source #

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

defaultPlugin :: Plugin Source #

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.

type CommandLineOption = String Source #

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

data PsMessages Source #

Errors and warnings produced by the parser

data ParsedResult Source #

Result of running the parser and the parser plugin

Constructors

ParsedResult 

Fields

External plugins

Recompilation checking

Plugin types

Frontend plugins

Core plugins

Core plugins allow plugins to register as a Core-to-Core pass.

Typechecker plugins

Typechecker plugins allow plugins to provide evidence to the typechecker.

Source plugins

GHC offers a number of points where plugins can access and modify its front-end ("source") representation. These include:

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

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

Defaulting plugins

Defaulting plugins can add candidate types to the defaulting mechanism.

Hole fit plugins

hole fit plugins allow plugins to change the behavior of valid hole fit suggestions

data HoleFitPluginR Source #

HoleFitPluginR adds a TcRef to hole fit plugins so that plugins can track internal state. Note the existential quantification, ensuring that the state cannot be modified from outside the plugin.

Internal

data PluginWithArgs Source #

Constructors

PluginWithArgs 

Fields

data LoadedPlugin Source #

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

Constructors

LoadedPlugin 

Fields

data StaticPlugin Source #

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

Constructors

StaticPlugin 

Fields

data ExternalPlugin Source #

External plugin loaded directly from a library without loading module interfaces

Constructors

ExternalPlugin 

Fields

withPlugins :: Monad m => Plugins -> PluginOperation m a -> a -> m a Source #

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

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

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