Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 1.06 KB

README.md

File metadata and controls

41 lines (25 loc) · 1.06 KB

Build Status

ghc-edit-plugin

Create GHC plugins using composable Lens-like source edits.

Control.Edit

  • Control.Edit provides a Lens-like edit type and tools for editing Haskell source.
  • Control.Edit.Plugin provides a method to convert an Edited action to a Plugin:
editToPlugin :: ([CommandLineOption] -> ModSummary -> EditedM HsParsedModule a) -> Plugin

Control.Edit.HsModule

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) ()

Example Plugin

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 #-}