GHC pretty printer philosophy

Alan & Kim Zimmerman alan.zimm at gmail.com
Sat Nov 12 10:12:03 UTC 2016


I am currently working on #3384, with the intent of ensuring that

    parse (ppr (parse source)) == parse source

I have hit the issue where

   foo :: (Int)

has the parens reflected in the original parsed AST, but the types pretty
printer goes to a lot of trouble to remove any parens not required to
interpret the meaning of the type.

So the question is, should the default ppr faithfully reproduce the source
that was parsed to generate the given AST, or simplify it?

>From a round-tripping perspective I prefer the former, but there are other
use cases where the current behaviour is preferred.

If the original is preferred, it can perhaps be enabled via a flag to the
pretty printer, but before doing that I want to see if it actually matters.

Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20161112/9eb97901/attachment.html>


More information about the ghc-devs mailing list