Repository : ssh://g...@git.haskell.org/template-haskell On branch : wip/th-new Link : http://git.haskell.org/packages/template-haskell.git/commitdiff/1b6e8bd4d5c63ef63efd41c12a8864b42ffec79d
>--------------------------------------------------------------- commit 1b6e8bd4d5c63ef63efd41c12a8864b42ffec79d Author: Geoffrey Mainland <mainl...@apeiron.net> Date: Mon Jun 3 14:44:24 2013 +0100 Correctly pretty-print let and do expressions. >--------------------------------------------------------------- 1b6e8bd4d5c63ef63efd41c12a8864b42ffec79d Language/Haskell/TH/Ppr.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Language/Haskell/TH/Ppr.hs b/Language/Haskell/TH/Ppr.hs index ce9fe15..9bec103 100644 --- a/Language/Haskell/TH/Ppr.hs +++ b/Language/Haskell/TH/Ppr.hs @@ -136,12 +136,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 []) = text "<<Empty CompExp>>" -- This will probably break with fixity declarations - would need a ';' pprExp _ (CompE ss) = text "[" <> ppr s _______________________________________________ ghc-commits mailing list ghc-commits@haskell.org http://www.haskell.org/mailman/listinfo/ghc-commits