Description
Pretty print haskell code with comments.
Description
Generate code from haskell-src-exts AST. To do it, I pretty print and parse AST, then adjust it to insert comments.
README.md
haskell-src-exts-sc
The library generates code from haskell-src-exts
AST. The procedure is as follows:
- pretty-print AST generated by
haskell-src-exts
- parse the generated code to get
SrcSpanInfo
for each node - combine AST annotated with comments and AST annotated with
SrcSpanInfo
- insert (non-empty) comments into each node, updating
SrcSpanInfo
of all nodes - profit!
As you can see, the algorithm is nor remarkably fast, because it prints and parses code and modifies SrcSpanInfo
of all nodes in an AST on each comment insertion. On the good side, it is quite flexible and compatible with many versions of haskell-src-exts
. Performance is also acceptable if you don't need to invoke it every millisecond.