@hackage / dahdit

Binary parsing and serialization with integrated size

Latest0.8.0

About

Metadata

  • Last updated , by ejconlon
  • License BSD-3-Clause
  • Maintained by: ejconlon@gmail.com

  • Lottery factor: 1

Links

Installation

Tested Compilers

  1. 9.8.4

Readme

dahdit

Binary parsing and serialization with integrated size.

(dahs and dits are signal durations in Morse code)

This differs from binary in a few ways:

  • It supports parsing from (or rendering into) pinned or unpinned memory.
  • It uses ByteArray internally to avoid generating new or retaining references to old pinned memory.
  • Examining Put can yield required byte size without serializing.
  • Derivation uses via and not anyclass for better control of derived instances.
  • Types implementing Binary can implement byteSized for size calculation (or it will reflect on put).
  • Known-statically-sized types can implement StaticByteSized for size speedups.
  • Provides several additional types representing fixed-length strings or sequences (using TypeLits).

Static sizes

You may find it necessary to discharge simple KnownNat constraints with a plugin like ghc-typelits-knownnat. Add that package to your dependencies and add this to the top of the necessary files:

{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}