hi — i have a preliminary implementation up:
http://github.com/mariusaeriksen/bert
it handles most of BERT/BERP, but not yet
the RPC protocol.
terms are a type, and has a typeclass supporting
conversion, with implementations for common
haskell datatypes already. this is akin to the
haskell JSON library. eg.,
> showBERT ((1.0::Float), 2, False, "hello")
TupleTerm [FloatTerm 1.0,BigbigintTerm 2,BoolTerm False,BytelistTerm
(Chunk "hello" Empty)]
> readBERT $ showBERT ((1.0::Float), 2, False, "hello") :: Either String Term
Right (TupleTerm [FloatTerm 1.0,BigbigintTerm 2,BoolTerm
False,BytelistTerm (Chunk "hello" Empty)])
and supports binary encoding via the Data.Binary
class.
encode $ showBERT ((1.0::Float), 2, False, "hello")
Chunk "\131h\EOTc" (Chunk "1.000000000000000e0\NUL\NUL\NUL\NUL\NUL\NUL
\NUL\NUL\NUL\NUL\NUL\NUL" (Chunk "o\NUL\NUL\NUL\SOH\NUL" (Chunk
"\STX" (Chunk "h\STXd\NUL\EOT" (Chunk "bert" (Chunk "d\NUL\ENQ" (Chunk
"false" (Chunk "k\NUL\ENQ" (Chunk "hello" Empty)))))))))
or a packet:
ghci> encode $ Packet $ showBERT ((1.0::Float), 2, False, "hello")
Chunk "\NUL\NUL\NULC" (Chunk "\131h\EOTc" (Chunk
"1.000000000000000e0\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL
\NUL" (Chunk "o\NUL\NUL\NUL\SOH\NUL" (Chunk "\STX" (Chunk "h\STXd\NUL
\EOT" (Chunk "bert" (Chunk "d\NUL\ENQ" (Chunk "false" (Chunk "k\NUL
\ENQ" (Chunk "hello" Empty))))))))))