HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

GHC.Driver.Plugins

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.

  • 17 types
  • 14 values
  • Packageghc-9.10.3
  • Exports31
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourcePlugins.hs

Plugins

7 declarations
datadata Plugins
#

Constructors

  • Plugins
    • 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]

datadata 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

valuedefaultPlugin :: 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.

typetype CommandLineOption = String
#

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

External plugins

1 declaration

Recompilation checking

Plugin types

0 declarations

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:

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

datadata HoleFitPluginR
#

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.

Late plugins

Late plugins can access and modify the core of a module after optimizations have been applied and after interface creation.

Internal

10 declarations
valuewithPlugins :: Monad m => Plugins -> PluginOperation m a -> a -> m a
#

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

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

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