Re: [Haskell-cafe] Comments on reading two ints off Bytestring

2007-12-24 Thread Conal Elliott
To clean up even more, use StateT B.ByteString Maybe. Then the ByteString threading will be invisible, leading to just liftM2 (,) readI readI, for suitably defined readI. On Dec 23, 2007 6:45 AM, Bryan O'Sullivan [EMAIL PROTECTED] wrote: Paulo J. Matos wrote: I guess the latter is the

[Haskell-cafe] Comments on reading two ints off Bytestring

2007-12-23 Thread Paulo J. Matos
Hello all, It is either too difficult to get two integers of a bytestring, in which case something should be done to ease the process or I should learn much more Haskell. I guess the latter is the correct guess. I have a bytestring containing two naturals. I was to get them as efficiently as

Re: [Haskell-cafe] Comments on reading two ints off Bytestring

2007-12-23 Thread Neil Mitchell
Hi parseHeader $ BS.pack hello 252 359 (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

Re: [Haskell-cafe] Comments on reading two ints off Bytestring

2007-12-23 Thread Bryan O'Sullivan
Paulo J. Matos wrote: I guess the latter is the correct guess. Good guess! You can take advantage of the fact that the Maybe type is an instance of the Monad typeclass to chain those computations together, getting rid of all of the explicit case analysis. import qualified