Change a beautiful printer from haskell-src-exts

The haskell-src-exts package has functions for printing the Haskell AST. What I want to do is change my behavior on some constructors, in my case SCC pragmas are printed. Thus, everything else should be printed by default, only SCCs are handled differently. Can this be done without copying the source file and editing it, what am I doing now?

+5
source share
1 answer

Well, the library did one thing correctly using a class like Pretty. Then the task arises of choosing a different instance for the designers that you want to print in different ways. Ideally, you would just update the AST node you care about, and somehow replace this with AST.

Now the problem is that the Haskell AST exported by the library has a fixed type structure. This does not mean, for example, use two-level types that will allow you to replace newtypes for parts of the tree. Thus, you will need to override the AST type to the node you want to change.

+2
source

All Articles