Fix #15738 by defining (and using) parenthesizeHsContext
authorRyan Scott <ryan.gl.scott@gmail.com>
Mon, 15 Oct 2018 17:49:11 +0000 (13:49 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 15 Oct 2018 21:59:20 +0000 (17:59 -0400)
commit02b2116e458357e87718e7378a80579a7021e2a7
tree1849ba48aa90364997602ea5e8a175ef819bc9fa
parentc5b477c29127d8375b3f23d37f877278b52547f6
Fix #15738 by defining (and using) parenthesizeHsContext

With `QuantifiedConstraints`, `forall`s can appear in more
nested positions than they could before, but `Convert` and the TH
pretty-printer were failing to take this into account. On the
`Convert` side, this is fixed by using a `parenthesizeHsContext`
to parenthesize singleton quantified constraints that appear to the
left of a `=>`. (A similar fix is applied to the TH pretty-printer.)

Test Plan: make test TEST=T15738

Reviewers: goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15738

Differential Revision: https://phabricator.haskell.org/D5222
compiler/hsSyn/Convert.hs
compiler/hsSyn/HsTypes.hs
libraries/template-haskell/Language/Haskell/TH/Ppr.hs
testsuite/tests/th/T15738.hs [new file with mode: 0644]
testsuite/tests/th/T15738.stderr [new file with mode: 0644]
testsuite/tests/th/all.T