lambda-llama / bresson

BSON parser and encoder
MIT License
1 stars 1 forks source link
 ____   ____     ___  _____ _____  ___   ____
|    \ |    \   /  _]/ ___// ___/ /   \ |    \
|  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:

Example

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

Documentation for latest successful build is available here. Stable documentation will be available as soon as first stable version will be released.

Benchmarks

There are two benchmarks currently: