From f75a5dbe2ec9fbc67df0936333e0665b033f9e22 Mon Sep 17 00:00:00 2001 From: Jiasen Wu Date: Sat, 15 Dec 2018 23:17:37 +0100 Subject: [PATCH] bug fix. add a space in promoted list/tuple of some promoted type --- src/Language/Haskell/Exts/Pretty.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Language/Haskell/Exts/Pretty.hs b/src/Language/Haskell/Exts/Pretty.hs index dfe574eb..2e9da313 100644 --- a/src/Language/Haskell/Exts/Pretty.hs +++ b/src/Language/Haskell/Exts/Pretty.hs @@ -892,14 +892,25 @@ instance Pretty (Promoted l) where PromotedCon _ hasQuote qn -> addQuote hasQuote (pretty qn) PromotedList _ hasQuote list -> - addQuote hasQuote $ bracketList . punctuate comma . map pretty $ list + addQuote hasQuote $ brackets . addSpace list . prettyList $ list PromotedTuple _ list -> - addQuote True $ parenList $ map pretty list + addQuote True $ parens . addSpace list . prettyList $ list PromotedUnit {} -> addQuote True $ text "()" where addQuote True doc = char '\'' <> doc addQuote False doc = doc + checkQuote (PromotedCon _ q _) = q + checkQuote (PromotedList _ q _) = q + checkQuote (PromotedTuple _ _) = True + checkQuote _ = False + + addSpace (TyPromoted _ l0:_) | checkQuote l0 = (space <>) + addSpace _ = id + + prettyList = myFsepSimple . punctuate comma . map pretty + + instance Pretty (TyVarBind l) where pretty (KindedVar _ var kind) = parens $ myFsep [pretty var, text "::", pretty kind] pretty (UnkindedVar _ var) = pretty var