[Haskell-cafe] Combining wl-pprint and ByteString?

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Tue Nov 9 02:07:59 EST 2010

On 9 November 2010 17:53, Mark Spezzano <mark.spezzano at chariot.net.au> wrote:
> Hi all,
> I want to do the following tasks in this order:
> 1. Read text from standard input (should this be stored internally in my program as a ByteString or as a String?)
> 2. Process the text via left justifying it and making it word-wrap (again, internally, should I store this as a ByteString or String?)
> 3. Format the text using the Wadler-Leijen Pretty Printer (to the best of my knowledge this  only processes Strings, but not ByteStrings)
> 4. Print to Standard output the formatted (i.e. colourised, and justified) text (again, should this be as a ByteString or as a String?)
> I thought that the reason that most people use ByteString was for _performance_, but wl-pprint can only process Strings to the best of my knowledge.
> I would, ideally, like to use ByteStrings everywhere...all throughout my code. Is this possible with coloured text?
> I want to boost up the performance of my application dramatically, so in theory I could process everything as a String, then as the last second pack everything processed into a ByteString and print it out...I think that this might work. Then again it might not because of the types expected. Any help with this would be appreciated.

Well, I'm currently working on a Text version of wl-pprint, which will
probably suit your needs better than Bytestring.

As for coloured text, there's ansi-wl-pprint, but it's more for
terminals (how exactly do you want to output your results?).

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list