haskell-suite / haskell-src-exts

Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
Other
193 stars 94 forks source link

bug fix. add a space in promoted list/tuple of some promoted type #423

Open pierric opened 5 years ago

pierric commented 5 years ago

Here is a bug. It happens when pretty print a promoted list or tuple of promoted type. For example:

Prelude Language.Haskell.Exts Language.Haskell.Exts.Syntax Language.Haskell.Exts.Pretty> a = TyPromoted () (PromotedList () True [TyPromoted () (PromotedTuple () [])])
Prelude Language.Haskell.Exts Language.Haskell.Exts.Syntax Language.Haskell.Exts.Pretty> prettyPrint a
"'['()]"

However GHC (8.4.4) does not accept '['()]

A.hs:4:10: error: parse error on input ‘'’
  |
4 | type X = '['()]
  |          ^

So I add one space after the bracket when pretty print. The above example will become "'[ '()]", which makes GHC very happy.

pierric commented 5 years ago

any idea about this PR?