Fix #15307 by making nlHsFunTy parenthesize more

Authored by RyanGlScott on Jul 5 2018, 7:29 AM.


Fix Trac #15307 by making nlHsFunTy parenthesize more

nlHsFunTy wasn't parenthesizing its arguments at all,
which led to -ddump-deriv producing incorrectly parenthesized
types (since it uses nlHsFunTy to construct those types), as
demonstrated in Trac #15307. Fix this by changing nlHsFunTy to add
parentheses à la ppr_ty: always parenthesizing the argument type
with function precedence, and recursively processing the result type,
adding parentheses for each function type it encounters.

Test Plan: make test TEST=T14578

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: Trac #15307

Differential Revision:

(cherry picked from commit 59a15a56e180b59656e45df04f7df61de8298881)