summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2021-04-25 08:14:03 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-27 00:00:43 -0400
commitdd121fa178c29a154233e95a15c755d0ca7cbdcc (patch)
treed5f8ef872539dad8c56eeedc4e583130565931f9 /compiler/GHC/Hs
parentd9ceb2fb51b037a330a6cfaf129c24ea7f1ac644 (diff)
downloadhaskell-dd121fa178c29a154233e95a15c755d0ca7cbdcc.tar.gz
Pretty-print HsArgPar applications correctly (#19737)
Previously, the `Outputable` instance for `HsArg` was being used to pretty-print each `HsArgPar` in a list of `HsArg`s individually, which simply doesn't work. In lieu of the `Outputable` instance, we now use a dedicated `pprHsArgsApp` function to print a list of `HsArg`s as a single unit. I have also added documentation to the `Outputable` instance for `HsArg` to more clearly signpost that it is only suitable for debug pretty-printing. Fixes #19737.
Diffstat (limited to 'compiler/GHC/Hs')
-rw-r--r--compiler/GHC/Hs/Decls.hs12
-rw-r--r--compiler/GHC/Hs/Type.hs2
2 files changed, 2 insertions, 12 deletions
diff --git a/compiler/GHC/Hs/Decls.hs b/compiler/GHC/Hs/Decls.hs
index 9f3f6469e5..9f7b278ef3 100644
--- a/compiler/GHC/Hs/Decls.hs
+++ b/compiler/GHC/Hs/Decls.hs
@@ -810,17 +810,7 @@ pprHsFamInstLHS :: (OutputableBndrId p)
pprHsFamInstLHS thing bndrs typats fixity mb_ctxt
= hsep [ pprHsOuterFamEqnTyVarBndrs bndrs
, pprLHsContext mb_ctxt
- , pp_pats typats ]
- where
- pp_pats (patl:patr:pats)
- | Infix <- fixity
- = let pp_op_app = hsep [ ppr patl, pprInfixOcc thing, ppr patr ] in
- case pats of
- [] -> pp_op_app
- _ -> hsep (parens pp_op_app : map ppr pats)
-
- pp_pats pats = hsep [ pprPrefixOcc thing
- , hsep (map ppr pats)]
+ , pprHsArgsApp thing fixity typats ]
instance OutputableBndrId p
=> Outputable (ClsInstDecl (GhcPass p)) where
diff --git a/compiler/GHC/Hs/Type.hs b/compiler/GHC/Hs/Type.hs
index a666a87519..917063d6f4 100644
--- a/compiler/GHC/Hs/Type.hs
+++ b/compiler/GHC/Hs/Type.hs
@@ -37,7 +37,7 @@ module GHC.Hs.Type (
HsContext, LHsContext, fromMaybeContext,
HsTyLit(..),
HsIPName(..), hsIPNameFS,
- HsArg(..), numVisibleArgs,
+ HsArg(..), numVisibleArgs, pprHsArgsApp,
LHsTypeArg, lhsTypeArgSrcSpan,
OutputableBndrFlag,