[commit: template-haskell] th-new-7.6: Correctly pretty-print let and do expressions. (5074c08)
Geoffrey Mainland
gmainlan at microsoft.com
Wed Jun 12 12:04:28 CEST 2013
Repository : ssh://darcs.haskell.org//srv/darcs/packages/template-haskell
On branch : th-new-7.6
http://hackage.haskell.org/trac/ghc/changeset/5074c080c6411d68a5068ceb48810b2cd2f2c1b3
>---------------------------------------------------------------
commit 5074c080c6411d68a5068ceb48810b2cd2f2c1b3
Author: Geoffrey Mainland <mainland at apeiron.net>
Date: Mon Jun 3 14:44:24 2013 +0100
Correctly pretty-print let and do expressions.
>---------------------------------------------------------------
Language/Haskell/TH/Ppr.hs | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Language/Haskell/TH/Ppr.hs b/Language/Haskell/TH/Ppr.hs
index 4de7588..71e7465 100644
--- a/Language/Haskell/TH/Ppr.hs
+++ b/Language/Haskell/TH/Ppr.hs
@@ -121,12 +121,22 @@ pprExp i (MultiIfE alts)
[] -> [text "if {}"]
(alt : alts') -> text "if" <+> pprGuarded arrow alt
: map (nest 3 . pprGuarded arrow) alts'
-pprExp i (LetE ds e) = parensIf (i > noPrec) $ text "let" <+> ppr ds
- $$ text " in" <+> ppr e
+pprExp i (LetE ds_ e) = parensIf (i > noPrec) $ text "let" <+> pprDecs ds_
+ $$ text " in" <+> ppr e
+ where
+ pprDecs [] = empty
+ pprDecs [d] = ppr d
+ pprDecs ds = braces $ sep $ punctuate semi $ map ppr ds
+
pprExp i (CaseE e ms)
= parensIf (i > noPrec) $ text "case" <+> ppr e <+> text "of"
$$ nest nestDepth (ppr ms)
-pprExp i (DoE ss) = parensIf (i > noPrec) $ text "do" <+> ppr ss
+pprExp i (DoE ss_) = parensIf (i > noPrec) $ text "do" <+> pprStms ss_
+ where
+ pprStms [] = empty
+ pprStms [s] = ppr s
+ pprStms ss = braces $ sep $ punctuate semi $ map ppr ss
+
pprExp _ (CompE []) = error "Can't happen: pprExp (CompExp [])"
-- This will probably break with fixity declarations - would need a ';'
pprExp _ (CompE ss) = text "[" <> ppr s
More information about the ghc-commits
mailing list