Create GHC plugins using composable Lens-like source edits.
Control.Editprovides aLens-like edit type and tools for editing Haskell source.Control.Edit.Pluginprovides a method to convert anEditedaction to aPlugin:
editToPlugin :: ([CommandLineOption] -> ModSummary -> EditedM HsParsedModule a) -> PluginMake 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 #-}