____ ____ ___ _____ _____ ___ ____
| \ | \ / _]/ ___// ___/ / \ | \
| o )| D ) / [_( \_( \_ | || _ |
| || / | _]\__ |\__ || O || | |
| O || \ | [_ / \ |/ \ || || | |
| || . \| |\ |\ || || | |
|_____||__|\_||_____| \___| \___| \___/ |__|__|
bresson
is an implementation of BSON, a binary format for storing
objects, used by MongoDB.
Why is bresson
better than the official bson-haskell
driver? Here's why:
text
for string-like data, instead of an unsupported
compact-string
.ToBson
and FromBson
, instead of a single
Val
class.If you ever used bson-haskell
, the API should look
familiar, except for the !?
operator, which allows retrieving nested
labels:
{-# LANGUAGE OverloadedStrings #-}
import Data.Binary (encode, decode)
import Data.Bson (Document, document, (=:), (!?))
import qualified Data.ByteString.Lazy as L
buffer :: L.ByteString
buffer = encode $ document [ "foo" =: "bar"
, "bar" =: document [ "boo" =: 42 ]
]
doc :: Document
doc = decode buffer
value :: Int
value = doc !? "foo.bar.boo" -- ==> 42
Documentation for latest successful build is available here. Stable documentation will be available as soon as first stable version will be released.
There are two benchmarks currently:
fromBson . toBson
benchmarks on various types, latest buildencode . decode
benchmark against bson
library, latest build