Text.PrettyPrint.HughesPJ inserting blank lines

I've found myself using "$+$ space $+$" in order to insert a blank line between two docs. There are probably other ways to do it. "(test "")" (and $$) instead of "space" (or $+$) also work in many cases (but not "empty"). Which way would be the best? Maybe one could add a further function "$++$" to do this and a list version "vsep" of "$++$"? Another idea might be something like a vertical space "vspace" so that several blank lines would be created by: $$ vspace $$ vspace $$ ... Cheers Christian

Hi,
Nothing constructive here, I just like to second the suggestion,
as I often need a vertical space document for things like:
vcat (punctuate vspace lines)
or is there already a way to do that?
-Iavor
On Wed, 26 Jan 2005 19:51:27 +0100, Christian Maeder
I've found myself using "$+$ space $+$" in order to insert a blank line between two docs.
There are probably other ways to do it. "(test "")" (and $$) instead of "space" (or $+$) also work in many cases (but not "empty"). Which way would be the best?
Maybe one could add a further function "$++$" to do this and a list version "vsep" of "$++$"?
Another idea might be something like a vertical space "vspace" so that several blank lines would be created by: $$ vspace $$ vspace $$ ...
Cheers Christian _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Wed, Jan 26, 2005 at 07:51:27PM +0100, Christian Maeder wrote:
I've found myself using "$+$ space $+$" in order to insert a blank line between two docs.
There are probably other ways to do it. "(test "")" (and $$) instead of "space" (or $+$) also work in many cases (but not "empty"). Which way would be the best?
Maybe one could add a further function "$++$" to do this and a list version "vsep" of "$++$"?
Another idea might be something like a vertical space "vspace" so that several blank lines would be created by: $$ vspace $$ vspace $$ ...
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"). Best regards, Tomasz

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
participants (3)
-
Christian Maeder
-
Iavor Diatchki
-
Tomasz Zielonka