BSD-3-Clause licensed and maintained by Oleg Grenrus
This version can be pinned in stack with:binary-tagged-0.1.4.0@sha256:65ad0b97a568f35720fb0ba252701049fc8e84b9732757a8727a7cabcd9b9640,3965

Module documentation for 0.1.4.0

binary-tagged

Build Status Hackage Stackage LTS 2 Stackage LTS 3 Stackage Nightly

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.

Changes

  • 0.1.4.0 (2016-04-12)
    • Add semigroups types
    • Add Natural
  • 0.1.3.1 (2016-02-10)
    • Support GHC 8.0
  • 0.1.3.0 (2015-10-24)
    • Support generics-sop-0.2
  • 0.1.2.0 (2015-10-06)
    • Add tuple HasSemanticVersion instances
    • Add instances for
      • ()
      • Float
      • Double
      • Version`
      • Fixed
      • Ordering
    • Fix Interleave & SumUpTo, introduce Div2
  • 0.1.1.0
    • Add instances
      • Ratio
      • Word
      • HasSemanticVersion for primitive types