[Haskell-cafe] Re: Pretty Print, text or ++?

Christian Maeder Christian.Maeder at dfki.de
Fri Aug 15 09:50:16 EDT 2008

Paul Keir wrote:
> Hi there,
> I'm writing a pretty printer using the Text.PrettyPrint library, and 
> there's a pattern I'm coming across quite often. Does anyone know whether,
> text (a ++ b ++ c ++ d)
> or
> text a <+> text b <+> text c <+> text d
> runs quicker?

Don't worry about speed. Write it as:

   hsep[text a, text b, text c, text d]

and you can easily change hsep to sep or fsep, if the lines get too 
long. (And maybe you have some other docs that may be part of the list 
that are not constructed using "text".)

HTH Christian

More information about the Haskell-Cafe mailing list