Bad pretty printer for let bindings in a do-notation with braces
Let bindings in do-notations with braces like this:
module Thing where
thing = do {let {x = 1};
print x}
get pretty printed with the braces around the bindings stripped, like this:
module Thing where
thing = do {let x = 1;
print x}
Steps to reproduce: copy the module into Try.hs then call: ghc -ddump-rn Try.hs
I traced the code to: https://github.com/ghc/ghc/blob/e28fbbb7c3d5904a88b4743d0d10f212d61d8293/compiler/hsSyn/HsExpr.hs#L1929 which points to the pretty printer for list of declarations: https://github.com/ghc/ghc/blob/95dc6dc070deac733d4a4a63a93e606a2e772a67/compiler/hsSyn/HsBinds.hs#L492 Indeed there is a comment on the two ways to pretty print binders - without braces in multiple lines and with braces in one line. However the comment does not explain the choice, and as discussed in #13302 (closed) the former won't parse in a do-notation.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |