Commit 0e7ccf6d authored by Ryan Scott's avatar Ryan Scott
Browse files

Fix TH ppr output for list comprehensions with only one Stmt

A folow-up to D2521 (which addressed #12583), where the `Outputable` `ppr`
output was tweaked to display a list comprehension with only one `Stmt` as
`[Foo]` instead of `[Foo|]` (which isn't valid Haskell). I forgot to update
the corresponding code in `Language.Haskell.TH.Ppr` which pretty-prints
`CompE`, however, so this commit takes care of that.
parent 7b7ea8f4
......@@ -179,12 +179,17 @@ pprExp i (DoE ss_) = parensIf (i > noPrec) $ text "do" <+> pprStms ss_
pprExp _ (CompE []) = text "<<Empty CompExp>>"
-- This will probably break with fixity declarations - would need a ';'
pprExp _ (CompE ss) = text "[" <> ppr s
<+> bar
<+> commaSep ss'
<> text "]"
where s = last ss
ss' = init ss
pprExp _ (CompE ss) =
if null ss'
-- If there are no statements in a list comprehension besides the last
-- one, we simply treat it like a normal list.
then text "[" <> ppr s <> text "]"
else text "[" <> ppr s
<+> bar
<+> commaSep ss'
<> text "]"
where s = last ss
ss' = init ss
pprExp _ (ArithSeqE d) = ppr d
pprExp _ (ListE es) = brackets (commaSep es)
pprExp i (SigE e t) = parensIf (i > noPrec) $ ppr e <+> dcolon <+> ppr t
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment