
#14646: GHC 8.4.1 regression: rank-n types no longer parenthesized when pretty- printed -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: GHC API | Version: 8.4.1-alpha1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): I think this will be hard to fix. The problem is that `ppParendHsType` was bad, as `HsSyn` already tracks parentheses. It was silly to have another function guess at where to put more of them. And it often guessed wrong, leading to all sorts of pretty-printer infelicities. On the other hand, Template Haskell does ''not'' track parentheses. And so when GHC converts TH to `HsSyn`, the parentheses aren't inserted and so are not pretty-printed. I see two ways forward: 1. Track parentheses in TH, breaking lots and lots of client code. (Note that this is different than TH's usual churn of adding new constructs, because much code out there that consumes the TH AST will start silently failing in the presence of an unexpected ''old'' construct.) 2. Insert parens when converting TH AST to `HsSyn`. By using precedence rules, etc., it should be possible to do a passable job, but we'll never replicate exactly what the user wrote. I think I favor (2). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14646#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler