Simplify Core output with -dsuppress-type-signatures
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Mon, 24 Dec 2018 12:02:27 +0000 (15:02 +0300)
committerÖmer Sinan Ağacan <omeragacan@gmail.com>
Mon, 24 Dec 2018 12:02:39 +0000 (15:02 +0300)
Currently we duplicate top-level binder ids for no reason:

    $fEqHsExpr_$c/=
    $fEqHsExpr_$c/=
      = \ @ id_a27U $dEq_a27V eta_B2 eta1_B1 ->
          case $fEqHsExpr_$c== $dEq_a27V eta_B2 eta1_B1 of {
            False -> True;
            True -> False
          }

with this patch we drop the first line when type signatures are not
printed (-dsuppress-type-signatures, which is implied by -dsuppress-all)

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5472

compiler/coreSyn/PprCore.hs
testsuite/tests/simplCore/should_compile/T16038/T16038.stdout
testsuite/tests/simplCore/should_compile/T5996.stdout

index f22d803..5fe033b 100644 (file)
@@ -115,7 +115,13 @@ ppr_bind ann (Rec binds)           = vcat (map pp binds)
 
 ppr_binding :: OutputableBndr b => Annotation b -> (b, Expr b) -> SDoc
 ppr_binding ann (val_bdr, expr)
-  = ann expr $$ pprBndr LetBind val_bdr $$ pp_bind
+  = sdocWithDynFlags $ \dflags ->
+      vcat [ ann expr
+           , if gopt Opt_SuppressTypeSignatures dflags
+               then empty
+               else pprBndr LetBind val_bdr
+           , pp_bind
+           ]
   where
     pp_bind = case bndrIsJoin_maybe val_bdr of
                 Nothing -> pp_normal_bind