@hackage binary-tagged0.3.1
Tagged binary serialisation.
Categories
License
BSD-3-Clause
Maintainer
Oleg Grenrus <oleg.grenrus@iki.fi>
Links
Versions
Installation
Tested Compilers
Dependencies (8)
- array ^>=0.5.0.0
- base >=4.7.0.2 && <4.20
- base16-bytestring ^>=0.1.1.6 || ^>=1.0.0.0
- binary >=0.7.1.0 && <0.10
- bytestring ^>=0.10.4.0 || ^>=0.11 || ^>=0.12.0.2
- containers >=0.5.5.1 && <0.7 Show all…
Dependents (3)
@hackage/stack, @hackage/flowdock-rest, @hackage/stackage-curator
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
structuredEncoderecord :: LBS.ByteStringstructuredDecodelbs :: 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)