BSD-3-Clause licensed and maintained by Oleg Grenrus
This version can be pinned in stack with:binary-tagged-0.1.1.0@sha256:fd550ffa78871db7e461ba3fba5b85ec3bafe4c75a60f4f70237df6812045926,3779

Module documentation for 0.1.1.0

binary-tagged

Build Status Hackage

Structurally tag binary serialisation stream.

Say you have:

data Record = Record
  { _recordFields :: HM.HashMap Text (Integer, ByteString)
  , _recordEnabled :: Bool
  }
  deriving (Eq, Show, Generic)

instance Binary Record
instance HasStructuralInfo Record
instance HasSemanticVersion Record

then you can serialise and deserialise Record values with a structure tag by simply

encodeTaggedFile "cachefile" record
decodeTaggedFile "cachefile" :: IO Record

If structure of Record changes in between, deserialisation will fail early.

The overhead is next to non-observable, see a simple benchmark and the results.