[Haskell-cafe] Speed of character reading in Haskell

ok ok at cs.otago.ac.nz
Sun Sep 9 19:01:37 EDT 2007

On 7 Sep 2007, at 11:22 pm, Chaddaï Fouché wrote:

> From what I can see of your program, it would greatly benefit from
> using Data.ByteString, is there an obvious reason not to use it ?

I am writing a a set of tools to process a legacy programming
language, as I said.  Speed is not, in fact, a central issue.
It's just something that came up while I was exploring ways to
express it.

What *is* a central issue is getting something
Using getContents and walking down a list I get something which is
close to Lex in compactness but is much easier to work with; Lex
has a nasty habit of either failing to cope entirely or requiring
seriously nasty state hacking when you do anything even a little
out of the way; Haskell list processing doesn't.

Also, I greatly prefer writing to standards.  While I turn to GHC for
speed (when I can; trying to install GHC 6.6 under Solaris 2.9 was an
amazingly painful and ultimately unsuccessful experience), I try to
use other Haskell compilers as well, and that means sticking to standard
libraries.  Data.ByteString is many things, but defined in the  
Haskell 98
report is not one of them.

> (Some list operations are too expensive with ByteString but for most
> string processing it's perfectly fine and much faster than String).

I'm sure it's true, but it's quite irrelevant to my question, which is
"why is using getChar so much slower than using getContents"?

More information about the Haskell-Cafe mailing list