Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix. add a space in promoted list/tuple of some promoted type #423

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/Language/Haskell/Exts/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -894,14 +894,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
Expand Down