-
Notifications
You must be signed in to change notification settings - Fork 40
Closed
Labels
Description
Currently we have:
> diag $ group . group . group $ "x" <> line
Union
( Cat ( Char 'x' ) ( Char ' ' ) )
( Union
( Cat ( Char 'x' ) ( Char ' ' ) )
( Union
( Cat ( Char 'x' ) ( Char ' ' ) )
( Cat ( Char 'x' )
( FlatAlt Line ( Char ' ' ) )
)
)
)It would be nice if we could get just
Union
( Cat ( Char 'x' ) ( Char ' ' ) )
( Cat ( Char 'x' )
( FlatAlt Line ( Char ' ' ) )
)instead. This patch should do the trick:
@@ -523,6 +523,7 @@ hardline = Line
-- use of it.
group :: Doc ann -> Doc ann
-- See note [Group: special flattening]
+group x@Union{} = x
group x = case changesUponFlattening x of
Nothing -> x
Just x' -> Union x' xBut maybe we could even get this?!
Union
( Cat ( Char 'x' ) ( Char ' ' ) )
( Cat ( Char 'x' ) Line )