bert: BERT implementation

[ bsd3, data, library ] [ Propose Tags ]

Implements the BERT serialization and RPC protocols described at

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 1.0, 1.1, 1.1.1, 1.1.2,, 1.2, 1.2.1,,, 1.2.2,,,,,
Change log
Dependencies base (>=4 && <5), binary (>=0.5), binary-conduit (>=1.2), bytestring (>=0.9), conduit (>=1.0), conduit-extra (>=1.1), containers (>=0.2), mtl (>=1.1), network (>=2.3), parsec (>=2.0), time (>=1.1), unix (>=2.0), void [details]
License BSD-3-Clause
Copyright (c) 2009-2011 marius a. eriksen; (c) 2013 Roman Cheplyaka
Author marius a. eriksen, Roman Cheplyaka
Maintainer Roman Cheplyaka <>
Category Data
Home page
Bug tracker
Source repo head: git clone
Uploaded by RomanCheplyaka at 2016-04-05T11:21:07Z
Reverse Dependencies 4 direct, 0 indirect [details]
Downloads 11354 total (17 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-04-05 [all 1 reports]

Readme for bert-

[back to package description]

BERT[-RPC] for Haskell

Originally written by marius a. eriksen (

This is a BERT serializer/deserializer and BERT-RPC client and server for Haskell. BERT-RPC currently supports synchronous (call) requests.

The primitives provided are fairly elementary: for the client, call provides the capability to perform the RPC call, while the server's serve is provided with a dispatch function providing the dispatching logic for the server. Thus, one can imagine building higher level abstractions on top of these primitives.


It's a cabal package, so

$ cabal install bert

should do the trick.


import qualified Data.ByteString.Lazy.Char8 as C
import Data.BERT

Creating BERT terms is simple.

TupleTerm [BytelistTerm (C.pack "hello"), IntTerm 123]

Or by using the BERT typeclass.

showBERT $ ("hello", 123)

The BERT class can also read terms back.

Right ("hello", 123) = readBERT . showBERT $ ("hello", 123)

BERT-RPC client

import Data.BERT
import Network.BERT.Client

Create a transport to the server endpoint, and issue a (synchronous) call with it.

t <- tcpClient "localhost" 8080
r <- call t "calc" "add" ([123, 3000]::[Int])
case r of
  Right res -> print (res :: Int)
  Left _    -> putStrLn "error"

BERT-RPC server

import Data.BERT
import Network.BERT.Server

Create a transport from which to accept connections, and provide a dispatch function for incoming RPCs. The dispatch function is issued in a new thread for each incoming request.

main = do
  s <- tcpServer 8080
  serve s dispatch

dispatch "calc" "add" [IntTerm a, IntTerm b] = 
  return $ Success $ IntTerm (a + b)
dispatch "calc" _ _ =
  return NoSuchFunction
dispatch _ _ _ = 
  return NoSuchModule


Roman Cheplyaka is the primary maintainer.

Oleksandr Manzyuk is the backup maintainer. Please get in touch with him if the primary maintainer cannot be reached.