Commit c3133273 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan
Browse files

Minor improvement in CoreDump outputs:

Don't add parens unnecessarily when arguments of the application are all
hidden (because of parameters like -dsuppress-all,
-dsuppress-type-applications etc.)

Reviewers: bgamari, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1771
parent 6ea24af9
...@@ -147,11 +147,18 @@ ppr_expr add_par expr@(Lam _ _) ...@@ -147,11 +147,18 @@ ppr_expr add_par expr@(Lam _ _)
2 (pprCoreExpr body) 2 (pprCoreExpr body)
ppr_expr add_par expr@(App {}) ppr_expr add_par expr@(App {})
= case collectArgs expr of { (fun, args) -> = sdocWithDynFlags $ \dflags ->
case collectArgs expr of { (fun, args) ->
let let
pp_args = sep (map pprArg args) pp_args = sep (map pprArg args)
val_args = dropWhile isTypeArg args -- Drop the type arguments for tuples val_args = dropWhile isTypeArg args -- Drop the type arguments for tuples
pp_tup_args = pprWithCommas pprCoreExpr val_args pp_tup_args = pprWithCommas pprCoreExpr val_args
args'
| gopt Opt_SuppressTypeApplications dflags = val_args
| otherwise = args
parens
| null args' = id
| otherwise = add_par
in in
case fun of case fun of
Var f -> case isDataConWorkId_maybe f of Var f -> case isDataConWorkId_maybe f of
...@@ -164,9 +171,9 @@ ppr_expr add_par expr@(App {}) ...@@ -164,9 +171,9 @@ ppr_expr add_par expr@(App {})
tc = dataConTyCon dc tc = dataConTyCon dc
saturated = val_args `lengthIs` idArity f saturated = val_args `lengthIs` idArity f
_ -> add_par (hang (ppr f) 2 pp_args) _ -> parens (hang (ppr f) 2 pp_args)
_ -> add_par (hang (pprParendExpr fun) 2 pp_args) _ -> parens (hang (pprParendExpr fun) 2 pp_args)
} }
ppr_expr add_par (Case expr var ty [(con,args,rhs)]) ppr_expr add_par (Case expr var ty [(con,args,rhs)])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment