Skip to content

michaeljklein/ghc-edit-plugin

Repository files navigation

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

About

Create GHC plugins using composable Lens-like source edits

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published