[Git][ghc/ghc][master] Don't indent single alternative case expressions for STG.
Marge Bot
gitlab at gitlab.haskell.org
Sat Apr 20 03:44:22 UTC 2019
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
fcef26b6 by klebinger.andreas at gmx.at at 2019-04-20T03:38:16Z
Don't indent single alternative case expressions for STG.
Makes the width of STG dumps slightly saner.
Especially for things like unboxing.
Fixes #16580
- - - - -
1 changed file:
- compiler/stgSyn/StgSyn.hs
Changes:
=====================================
compiler/stgSyn/StgSyn.hs
=====================================
@@ -831,18 +831,31 @@ pprStgExpr (StgTick tickish expr)
else sep [ ppr tickish, pprStgExpr expr ]
+-- Don't indent for a single case alternative.
+pprStgExpr (StgCase expr bndr alt_type [alt])
+ = sep [sep [text "case",
+ nest 4 (hsep [pprStgExpr expr,
+ whenPprDebug (dcolon <+> ppr alt_type)]),
+ text "of", pprBndr CaseBind bndr, char '{'],
+ pprStgAlt False alt,
+ char '}']
+
pprStgExpr (StgCase expr bndr alt_type alts)
= sep [sep [text "case",
nest 4 (hsep [pprStgExpr expr,
whenPprDebug (dcolon <+> ppr alt_type)]),
text "of", pprBndr CaseBind bndr, char '{'],
- nest 2 (vcat (map pprStgAlt alts)),
+ nest 2 (vcat (map (pprStgAlt True) alts)),
char '}']
-pprStgAlt :: OutputablePass pass => GenStgAlt pass -> SDoc
-pprStgAlt (con, params, expr)
- = hang (hsep [ppr con, sep (map (pprBndr CasePatBind) params), text "->"])
- 4 (ppr expr <> semi)
+
+pprStgAlt :: OutputablePass pass => Bool -> GenStgAlt pass -> SDoc
+pprStgAlt indent (con, params, expr)
+ | indent = hang altPattern 4 (ppr expr <> semi)
+ | otherwise = sep [altPattern, ppr expr <> semi]
+ where
+ altPattern = (hsep [ppr con, sep (map (pprBndr CasePatBind) params), text "->"])
+
pprStgOp :: StgOp -> SDoc
pprStgOp (StgPrimOp op) = ppr op
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/fcef26b62569428d47e96fcd8946a733540783ab
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/fcef26b62569428d47e96fcd8946a733540783ab
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190419/52558005/attachment-0001.html>
More information about the ghc-commits
mailing list