Commit 67576ddc authored by thomie's avatar thomie

Pretty: bugfix fillNB (#10735)

This is a backport of a bug fix by Benedikt Huber (#2393), from commit
1e50748beaa4bd2281d323b18ea51c786bba04a1 in the pretty library.

From https://mail.haskell.org/pipermail/libraries/2008-June/009991.html:

    Law <l1> states that

    > sep (ps++[empty]++qs)   = sep (ps ++ qs)
    >         ...ditto hsep, hcat, vcat, fill...

    In the current implementation, this fails for the paragraph fill
    variants.

    > render' $ fsep [ text "c", text "c",empty, text "c", text "b"]
    >   where render' = renderStyle (Style PageMode 7 1.4)
    >> c c c
    >>     b
parent 8cce7e4b
......@@ -815,6 +815,7 @@ fillNB _ _ k _ | k `seq` False = undefined
fillNB g (Nest _ p) k ys = fillNB g p k ys
-- Never triggered, because of invariant (2)
fillNB _ Empty _ [] = Empty
fillNB g Empty k (Empty:ys) = fillNB g Empty k ys
fillNB g Empty k (y:ys) = fillNBE g k y ys
fillNB g p k ys = fill1 g p k ys
......
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