[Haskell-cafe] Success and one last issue with Data.Binary

David Leimbach leimy2k at gmail.com
Tue Jun 2 12:20:43 EDT 2009

I've got the following "printHex"  string as a response from a 9P server
running on the Inferno Operating System. (thanks to a friendly mailing list
contributor who sent a nice example of using Data.Binary)

This is a little endian encoded ByteString with the following fields in it:

 Rversion {size :: Word32,
                mtype :: Word8,
                tag :: Word16,
                msize :: Word32,
                ssize :: Word16,
                version :: ByteString}

But when I try to use the following implementation of "get" to decode this
stream, I'm getting the following error:

"too few bytes. Failed reading at byte position 20"

Unfortunately, I'm only expecting 19 bytes, and in fact never asked for byte
20.  (I am just asking for everything up to ssize, and then

Is this a bug?    Is it mine or in Data.Binary?  :-)

Here's my "get" function:

 get = do s <- getWord32le
             mtype <- getWord8
             getSpecific s mtype
          getSpecific s mt
                      | mt == mtRversion = do t <- getWord16le
                                              ms <- getWord32le
                                              ss <- getWord16le
                                              v <-
                                              return $ MessageClient $
Rversion {size=s,






The good news is I'm talking 9P otherwise, correctly, just having some
decoding issues.  I hope to have a hackage package eventually for this.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090602/a1f191e9/attachment.html

More information about the Haskell-Cafe mailing list