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

Mark Spezzano mark.spezzano at chariot.net.au
Tue Nov 9 03:01:06 EST 2010


Hi Ivan,

Yes, I want it printed in a terminal window.

I want to be able to run it from the command line in a terminal window, and have the text come up in colours (but very fast). My current version is already very fast, but I've heard everyone raving about how slow Strings were to use for I/O, so I wanted to _experiment_ with ByteStrings to see the performance difference.

I'm experimenting with writing a Zork-like text adventure game and I just wanted to do some space/time profiling on different pieces of code and observe the results. I thought that ByteStrings might be the way to go, but can they be combined with the Doc type from the ansi-wl-pprint library? 

Mark

On 09/11/2010, at 5:37 PM, Ivan Lazar Miljenovic wrote:

> 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
> IvanMiljenovic.wordpress.com
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 



More information about the Haskell-Cafe mailing list