[Haskell-cafe] Comments on reading two ints off Bytestring
ndmitchell at gmail.com
Sun Dec 23 07:52:01 EST 2007
> > parseHeader $ BS.pack "hello 252 359"
If this were strings, I'd start with:
map read . words
If you want to have error correction, I'd move to:
mapM readMay . words
(readMay comes from the safe package, http://www-users.cs.york.ac.uk/~ndm/safe/)
I don't know about the bytestring bit, but I guess the functions all map over.
> I have a bytestring containing two naturals. I was to get them as
> efficiently as possible. Here's my code:
Have you profiled your code and found that the parsing of two Int's
from a bytestring is the performance critial bit? If not, I'd just
keep it simple, and then optimise once you know where you should be
More information about the Haskell-Cafe