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

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Tue Nov 9 03:09:48 EST 2010


On 9 November 2010 19:01, Mark Spezzano <mark.spezzano at chariot.net.au> wrote:
> 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 _think_ Bytestrings are more efficient when dealing with files,
networks, etc.; I don't think there would be any noticeable
improvement in efficiencies for terminal I/O (probably less, since I
think - but am quite possibly wrong - that printing to stdout and
reading from stdin still goes via String).

> 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?

Have you actually profiled your code to see if the I/O is indeed a bottleneck?

And no, unless you fork and convert it, ansi-wl-pprint can't use Bytestrings.

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list