Tweak ... generation
[ghc-hetmet.git] / compiler / hsSyn / HsExpr.lhs
index a5f5f30..11b4df3 100644 (file)
@@ -285,8 +285,18 @@ pprLExpr :: OutputableBndr id => LHsExpr id -> SDoc
 pprLExpr (L _ e) = pprExpr e
 
 pprExpr :: OutputableBndr id => HsExpr id -> SDoc
-pprExpr e | isAtomicHsExpr e = ppr_expr e      -- Never replace 'x' by "..."
-         | otherwise        = pprDeeper (ppr_expr e)
+pprExpr e | isAtomicHsExpr e || isQuietHsExpr e =            ppr_expr e
+          | otherwise                           = pprDeeper (ppr_expr e)
+
+isQuietHsExpr :: HsExpr id -> Bool
+-- Parentheses do display something, but it gives little info and
+-- if we go deeper when we go inside them then we get ugly things
+-- like (...)
+isQuietHsExpr (HsPar _) = True
+-- applications don't display anything themselves
+isQuietHsExpr (HsApp _ _) = True
+isQuietHsExpr (OpApp _ _ _ _) = True
+isQuietHsExpr _ = False
 
 pprBinds :: OutputableBndr id => HsLocalBinds id -> SDoc
 pprBinds b = pprDeeper (ppr b)
@@ -684,11 +694,9 @@ pprMatch ctxt (Match pats maybe_ty grhss)
 
 pprGRHSs :: OutputableBndr id => HsMatchContext id -> GRHSs id -> SDoc
 pprGRHSs ctxt (GRHSs grhss binds)
-  = pprDeeper
-    (vcat (map (pprGRHS ctxt . unLoc) grhss)
-      $$
-     if isEmptyLocalBinds binds then empty
-     else text "where" $$ nest 4 (pprBinds binds))
+  = vcat (map (pprGRHS ctxt . unLoc) grhss)
+ $$ if isEmptyLocalBinds binds then empty
+                               else text "where" $$ nest 4 (pprBinds binds)
 
 pprGRHS :: OutputableBndr id => HsMatchContext id -> GRHS id -> SDoc