Provides tools for serializing data tagged with type information.

LTS Haskell 22.26:
Stackage Nightly 2024-06-21:
Latest on Hackage:

See all snapshots tagged-binary appears in

MIT licensed and maintained by Justin Le
This version can be pinned in stack with:tagged-binary-,2580

Module documentation for


tagged-binary on Hackage tagged-binary on Stackage LTS tagged-binary on Stackage Nightly Build Status

Very minimal (Haskell) library providing tools for serializing and decoding data into ByteString tagged with information about its type, inspired by Cloud Haskell and distributed-process.

Intended for use by libraries and frameworks in distributed contexts, such as distributed computation between native servers and communication between native servers and ghcjs/various front-ends, for behavior similar to the polymorphic communication channels of Cloud Haskell and distributed-process; servers can send tagged data, and clients can choose to selectively accept, ignore or queue incoming messages depending on their types.

For basic encoding and decoding, only Data.Binary.Tagged should be necessary. Data.Binary.Tagged.Internal is exported in case you need it.

Quick example

> let x = encodeTagged (1 :: Int)
> decodeTagged x :: Maybe Bool
> decodeTagged x :: Maybe Int
Just 1


Copyright (c) 2015 Justin Le



  • Compatibility with base-4.10 and ghc 8.2.


  • Removed Default instance on TagFingerprint in favor of just a normal emptyTagFP function. This is a breaking change, and is the reason for the “major” version bump.
  • Fixed bug on decoding badly formatted binary due to unexpected laziness.
  • Removed dependency on data-default and spoon packages.
  • Removed upper version bounds for all dependencies except for base.


  • Tagged ByteStrings now lead with a “TagLead” byte sequence that signifies that a Tagged is coming. For now, it is statically 0xfe 0xff, which are two bytes that are never found in any valid UTF-8 encoded string.
  • So that all TagFingerprints should be of the same length, TagFingerprints contain an MD5Digest, generated from the name of the type. Its Default instance is the MD5Digest of an empty string.


  • Initial version.