[Haskell-cafe] Binary Parsing

Denis Bueno dbueno at gmail.com
Wed Mar 11 22:42:02 EDT 2009

2009/3/11 Rick R <rick.richardson at gmail.com>:
> I have basic beginning to a parser for the BSON spec:
> http://www.mongodb.org/display/DOCS/BSON
> It is basically a binary compressed form of JSON.
> The usage model should be general, but I intend to read this data over TCP.
> I was wondering if there is a tool set that exists for this purpose. For
> instance, should I use Data.Binary and make my Binary instance of get and
> put use the BSON protocol? Or is that not correct?

It sounds like this would work well.  I just used Data.Binary for the
first time yesterday to parse a few several-hundred-megabyte files,
and I have no complaints.  Its interface allows for testing of nice
properties, like that (decode . encode $ x) == x.  Along with
quickCheck and an Arbitrary instance for your unserialised types, this
makes it easy to find problems in your coding.

The Data.Binary authors have also gone to some trouble to make it all
efficient -- you really should try it out.


More information about the Haskell-Cafe mailing list