[GHC] #3384: Add HsSyn prettyprinter tests

GHC ghc-devs at haskell.org
Wed Nov 16 18:37:56 UTC 2016


#3384: Add HsSyn prettyprinter tests
-------------------------------------+-------------------------------------
        Reporter:  igloo             |                Owner:
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:  ⊥
       Component:  Test Suite        |              Version:
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by alanz):

 Email response from Richard Eisenberg

 I'm afraid I've lost track of where this discussion took place (does
 someone else remember seeing it?), but I've advocated for faithful
 reproduction in the past. In particular, the pretty-printers for HsSyn
 should, in my opinion, never add or remove parentheses.

 There is a problem here, though: sometimes HsSyn is produced within GHC
 (for example, in the implementation of `deriving`, or in splicing TH,
 among a few other spots). This HsSyn can get away with missing
 parentheses, because it's built as an unambiguous AST. But if the pretty-
 printer is always faithful, then pretty-printing such an AST will produce
 an unparsable string. Perhaps the answer is that the generated code should
 be generous with parentheses -- essentially moving the paren-adding code
 from today's pretty-printer to the generation sites.

 Bottom line here: I fully support this direction of travel, but it's not
 without bumps in the road.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/3384#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list