Create GHC plugins using composable Lens
-like source edits.
Control.Edit
provides aLens
-like edit type and tools for editing Haskell source.Control.Edit.Plugin
provides a method to convert anEdited
action to aPlugin
:
editToPlugin :: ([CommandLineOption] -> ModSummary -> EditedM HsParsedModule a) -> Plugin
Make a splice for addTyClDeclTypeNameSplices
by using spliceApp
with the given TH function names, applied to each TyClDecl
name.
addTyClDeclTypeNameSpliceFunctions ::
(TyClDeclTypeName -> EditM () [(FastString, IdP GhcPs)])
-> EditedM (HsModule GhcPs) ()
An example plugin is provided in Control.Edit.Plugin.Echo
:
it prints the name and type (e.g. type family, data, etc.)
of each type declaration.
To use:
{-# OPTIONS_GHC -fplugin Control.Edit.Plugin.Echo #-}