Skip to content
Merged
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
14 changes: 10 additions & 4 deletions prettyprinter/src/Data/Text/Prettyprint/Doc/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,16 @@ hardline = Line
-- use of it.
group :: Doc ann -> Doc ann
-- See note [Group: special flattening]
group x = case changesUponFlattening x of
Flattened x' -> Union x' x
AlreadyFlat -> x
NeverFlat -> x
group x = case x of
Union{} -> x
FlatAlt a b -> case changesUponFlattening b of
Flattened b' -> Union b' a
AlreadyFlat -> Union b a
NeverFlat -> a
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should add some documentation that explains why Union and FlatAlt are treated specially.

_ -> case changesUponFlattening x of
Flattened x' -> Union x' x
AlreadyFlat -> x
NeverFlat -> x

-- Note [Group: special flattening]
--
Expand Down