BSD-2-Clause licensed and maintained by David Luposchainsky <dluposchainsky on googles email service>
This version can be pinned in stack with:binary-typed-1.0@sha256:c283ac0c9811f01b25333af3813d4985dac51a43b3c05729de3e7abb466cd5ca,4934

Binary serialization tagged with type information, allowing for typechecking and useful error messages at the receiving site.

This package serves the same purpose as tagged-binary, with a couple of key differences:

  • Support of different kinds of serialized type annotations, each with specific strengths and weaknesses.

  • Error messages can provide details on type errors at the cost of longer message lengths to include the necessary information.

  • Very small performance overhead compared to using standard Binary due to caching when using hashed type information. Since shown and full types are not cached, decoding them has a significant performance hit (ballpark: factor of two).

  • No depencency on Internal modules of other libraries, and a very small dependency footprint in general.

For information about usage, see the Data.Binary.Typed.Tutorial module.

Performance-wise, here is a value Right (Left <100 chars lipsum>) of type Either (Char, Int) (Either String (Maybe Integer)) benchmarked using the Hashed64 type representation:

(local copy)

Changes

binary-typed changelog

0.1

0.1.0.0

Initial release.

0.1.0.1

  • Add testsuite to compare generated message lengths with vanilla Binary and the various different typed serializations.
  • The .cabal file is hopefully fixed so that Hackage is able to build the docs automatically.

0.2

0.2.0.0

  • Add Hashed32 type representation with 32 bit, more suitable for short data than the previous Hashed, which was implicitly 64 bit long. Hashed64 is also available in case the longer hash is needed.
  • Type representations are now automatically cached by encodeTyped. If this data is long enough, it is even serialized in advance as well.

0.2.0.1

  • Fix whitespace in docs to make the docs build properly on Hackage, which presumably has an older Haddock version

0.2.1.0

  • Fix sharing not working at all (bad encodeTyped implementation)
  • Pre-calculate certain functions in the benchmarks so they can be properly shared among invocations

0.2.2

  • Add Hashed5 type representation that has no size overhead compared to Untyped
  • Add script to upload documentation to Hackage, since with the use of the new Typeable GHC 7.6.3, which Hackage currently runs, cannot build the docs itself.

0.2.3

  • Decoding now caches as well for Hashed* representations. This saves recalculating the TypeRep of the expected type, which previously was the bottleneck. Both encoding and decoding speeds are now very close to untyped Binary.

0.3

  • Add Debug module, which is a drop-in replacement for the ordinary API. However, a message is emitted via Debug.Trace every time a type representation is calculated, which makes it possible to debug proper sharing/caching.