Skip to content

lambda-llama/bresson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 ____   ____     ___  _____ _____  ___   ____
|    \ |    \   /  _]/ ___// ___/ /   \ |    \
|  o  )|  D  ) /  [_(   \_(   \_ |     ||  _  |
|     ||    / |    _]\__  |\__  ||  O  ||  |  |
|  O  ||    \ |   [_ /  \ |/  \ ||     ||  |  |
|     ||  .  \|     |\    |\    ||     ||  |  |
|_____||__|\_||_____| \___| \___| \___/ |__|__|

bresson is an implementation of BSON bson, a binary format for storing objects, used by MongoDB mongodb.

Why is bresson better than the official [bson-haskell] bson-haskell driver? Here's why:

  • Stores document in a hash table, instead of a list, which obviously improves lookup time for large documents.
  • Uses [text] text for string-like data, instead of an unsupported [compact-string] ustring.
  • Provides separate classes ToBson and FromBson, instead of a single Val class.
  • Well tested (Build Status) and community maintained!

Example

If you ever used [bson-haskell] 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] docs. Stable documentation will be available as soon as first stable version will be released.

Benchmarks

There are two benchmarks currently:

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •