summaryrefslogtreecommitdiff
path: root/compiler/hsSyn/HsDecls.hs
diff options
context:
space:
mode:
authorRichard Eisenberg <rae@cs.brynmawr.edu>2018-10-17 10:46:21 -0400
committerRichard Eisenberg <rae@cs.brynmawr.edu>2018-10-17 10:46:21 -0400
commit38c28c1a8bb129141e533866700e7318314f32c1 (patch)
treec7ba72ebd399fe15a6b520f28557dad0b7489f0a /compiler/hsSyn/HsDecls.hs
parent2e1df7c1556fc2fb6f7449ae07a382c57a0a536c (diff)
downloadhaskell-38c28c1a8bb129141e533866700e7318314f32c1.tar.gz
Fix #15761 by adding parens
This was just a pretty-printer infelicity. Fixed now. Test case: printer/T15761
Diffstat (limited to 'compiler/hsSyn/HsDecls.hs')
-rw-r--r--compiler/hsSyn/HsDecls.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/hsSyn/HsDecls.hs b/compiler/hsSyn/HsDecls.hs
index 2d2e911645..55f3b73686 100644
--- a/compiler/hsSyn/HsDecls.hs
+++ b/compiler/hsSyn/HsDecls.hs
@@ -1764,13 +1764,15 @@ pprFamInstLHS thing typats fixity context mb_kind_sig
-- explicit type patterns
= hsep [ pprHsContext context, pp_pats typats, pp_kind_sig ]
where
- pp_pats (patl:patsr)
- | fixity == Infix
- = hsep [pprHsType (unLoc patl), pprInfixOcc (unLoc thing)
- , hsep (map (pprHsType.unLoc) patsr)]
- | otherwise = hsep [ pprPrefixOcc (unLoc thing)
- , hsep (map (pprHsType.unLoc) (patl:patsr))]
- pp_pats [] = pprPrefixOcc (unLoc thing)
+ pp_pats (patl:patr:pats)
+ | Infix <- fixity
+ = let pp_op_app = hsep [ ppr patl, pprInfixOcc (unLoc thing), ppr patr ] in
+ case pats of
+ [] -> pp_op_app
+ _ -> hsep (parens pp_op_app : map ppr pats)
+
+ pp_pats pats = hsep [ pprPrefixOcc (unLoc thing)
+ , hsep (map ppr pats)]
pp_kind_sig
| Just k <- mb_kind_sig