[Haskell-cafe] Re: Comments on reading two ints off Bytestring
Benja Fallenstein
benja.fallenstein at gmail.com
Wed Dec 26 06:42:47 EST 2007
On Dec 23, 2007 1:44 PM, Isaac Dupree <isaacdupree at charter.net> wrote:
> parseHeader3 :: BS.ByteString -> Maybe (Int, Int)
> parseHeader3 bs = do
> (x, rest) <- BS.readInt $ BS.dropWhile (not . isDigit) bs
> (y, _) <- BS.readInt $ BS.dropWhile (not . isDigit) rest
> return (x, y)
But that version still itches! :-)
This is what it sounds like to me:
parseHeader :: BS.ByteString -> Maybe (Int,Int)
parseHeader = evalStateT $ liftM2 (,) parseInt parseInt where
parseInt = StateT $ BS.readInt . BS.dropWhile (not . isDigit)
- Benja
More information about the Haskell-Cafe
mailing list