[commit: ghc] master: Minor improvement in CoreDump outputs: (c313327)

git at git.haskell.org git at git.haskell.org
Wed Jan 13 22:44:31 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c3133273070b865011d848ec17b550168072f73c/ghc

>---------------------------------------------------------------

commit c3133273070b865011d848ec17b550168072f73c
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Wed Jan 13 09:16:38 2016 -0500

    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


>---------------------------------------------------------------

c3133273070b865011d848ec17b550168072f73c
 compiler/coreSyn/PprCore.hs | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/compiler/coreSyn/PprCore.hs b/compiler/coreSyn/PprCore.hs
index da2b311..147ff31 100644
--- a/compiler/coreSyn/PprCore.hs
+++ b/compiler/coreSyn/PprCore.hs
@@ -147,11 +147,18 @@ ppr_expr add_par expr@(Lam _ _)
          2 (pprCoreExpr body)
 
 ppr_expr add_par expr@(App {})
-  = case collectArgs expr of { (fun, args) ->
+  = sdocWithDynFlags $ \dflags ->
+    case collectArgs expr of { (fun, args) ->
     let
         pp_args     = sep (map pprArg args)
         val_args    = dropWhile isTypeArg args   -- Drop the type arguments for tuples
         pp_tup_args = pprWithCommas pprCoreExpr val_args
+        args'
+          | gopt Opt_SuppressTypeApplications dflags = val_args
+          | otherwise = args
+        parens
+          | null args' = id
+          | otherwise  = add_par
     in
     case fun of
         Var f -> case isDataConWorkId_maybe f of
@@ -164,9 +171,9 @@ ppr_expr add_par expr@(App {})
                              tc        = dataConTyCon dc
                              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)])



More information about the ghc-commits mailing list