Write a Blog >>
ICFP 2018
Sun 23 - Sat 29 September 2018 St. Louis, Missouri, United States
Sun 23 Sep 2018 10:45 - 11:10 at Illinois Central - GHC Chair(s): Ben Gamari

Source plugins are new in GHC 8.6 and provide a convenient mechanism for a user to inspect and modify the internal source code representation of a Haskell program. They are an extension to the existing plugins mechanism which adds passes which run after parsing, renaming and typechecking. This allows users to extend the compiler without having to modify GHC itself.

In this talk I will briefly explain the new extension points before demonstrating and explaining some different source plugins that I have experimented with. Some examples: a reimplementation of the graphmod library which is used to visualise a module graph of a package; a plugin to find unused names in an executable and a plugin which fills in specific instances for the Lift type class. Others have also implemented plugins which explain assertion failures and one which implements idiom brackets.

Tooling implemented using source plugins is robust and versatile. Plugins are invoked by passing additional options to GHC and so if your tool is implemented as a plugin, anyone can use it whether they use nix, cabal, stack or GHC manually.

Source plugins were implemented by Boldizsár Németh but the idea was previously suggested by Edsko de Vries.