binary-tagged: Tagged binary serialisation.

[ bsd3, data, library ] [ Propose Tags ]

Structurally tag binary serialisation stream.

Say you have:

Say you have a data type

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

instance Binary Record
instance Structured Record

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

structuredEncode record :: LBS.ByteString
structuredDecode lbs    :: IO Record

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

The overhead is next to non-observable.

benchmarking encode/Binary
time                 352.8 μs   (349.5 μs .. 355.9 μs)

benchmarking encode/Tagged
time                 350.8 μs   (349.0 μs .. 353.1 μs)

benchmarking decode/Binary
time                 346.8 μs   (344.7 μs .. 349.9 μs)

benchmarking decode/Tagged
time                 353.8 μs   (352.0 μs .. 355.8 μs)
Versions [RSS] [faq] 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.3.1, 0.1.4.0, 0.1.4.1, 0.1.4.2, 0.1.5, 0.1.5.1, 0.1.5.2, 0.2, 0.3, 0.3.1
Change log CHANGELOG.md
Dependencies array (>=0.5.0.0 && <0.6), base (>=4.7.0.2 && <4.16), base16-bytestring (>=0.1.1.6 && <0.2 || >=1.0.0.0 && <1.1), binary (>=0.7.1.0 && <0.10), bytestring (>=0.10.4.0 && <0.12), containers (>=0.5.5.1 && <0.7), structured (==0.1.1.*), tagged (>=0.8.6 && <0.9) [details]
License BSD-3-Clause
Author Oleg Grenrus <oleg.grenrus@iki.fi>
Maintainer Oleg Grenrus <oleg.grenrus@iki.fi>
Category Data
Bug tracker https://github.com/phadej/binary-tagged/issues
Source repo head: git clone https://github.com/phadej/binary-tagged(binary-tagged)
Uploaded by phadej at 2021-10-09T20:49:20Z
Distributions Arch:0.3, Debian:0.1.5, LTSHaskell:0.3, NixOS:0.3, Stackage:0.3.1
Downloads 12820 total (233 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-10-09 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates