2 Feb
2005
2 Feb
'05
8:57 p.m.
Tomasz Zielonka wrote:
This is ugly:
x $++$ y = (x <> text "") $+$ text "" $+$ (text "" <> y)
However, I don't know if it's OK that (show (empty $++$ empty) == "\n\n").
I want "empty" to be a unit of $++$ as well, so that -- | list version of '($++$)' vsep :: [Doc] -> Doc vsep = foldr ($++$) empty works. Therefore I suggest: -- | vertical composition with a specified number of blank lines aboveWithNLs :: Int -> Doc -> Doc -> Doc aboveWithNLs n d1 d2 = if isEmpty d2 then d1 else if isEmpty d1 then d2 else d1 $+$ foldr ($+$) d2 (replicate n $ text "") -- | vertical composition with one blank line ($++$) :: Doc -> Doc -> Doc ($++$) = aboveWithNLs 1 Cheers Christian