polytropos-cbor: Binary CBOR serialization for polytropos open records and variants

[ binary, codec, library ] [ Propose Tags ] [ Report a vulnerability ]

Binary CBOR serialization and deserialization for polytropos open records and variants via cborg and serialise.

Records serialize as an array length header followed by sequential flat payload encodings; variants serialize as an integer constructor tag followed by active payload fields. Eliminates intermediate tree allocations and boxing overhead entirely.

Start at the front door module Polytropos.CBOR for complete documentation, binary encoding formats, and worked examples.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.2
Change log CHANGELOG.md
Dependencies base (>=4.14 && <5), bytestring (>=0.10 && <0.13), cborg (>=0.2 && <0.3), polytropos-core (>=0.1 && <0.2), polytropos-plugin (>=0.1 && <0.2), serialise (>=0.2 && <0.3) [details]
License (EUPL-1.2 OR Apache-2.0)
Author Nadia Yvette Chambers
Maintainer nadia.yvette.chambers@ik.me
Uploaded by nyc at 2026-10-21T21:34:28Z
Category Codec, Binary
Home page https://github.com/NadiaYvette/polytropos
Bug tracker https://github.com/NadiaYvette/polytropos/issues
Source repo head: git clone https://github.com/NadiaYvette/polytropos(packages/polytropos-cbor)
Distributions
Downloads 3 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-10-21 [all 1 reports]

Readme for polytropos-cbor-0.1.0.2

[back to package description]

polytropos-cbor

Binary CBOR serialization and deserialization for polytropos open records and variants via cborg / serialise.

Overview

polytropos-cbor provides fast binary encoding and decoding for open records and variants, mapping contiguous payload slots to compact CBOR maps or arrays.

Features

  • Heterogeneous Serialise Codecs: Direct encoding of open records to CBOR byte streams.
  • Variant Serialization: Tag-based binary framing with \(O(1)\) tag decoding.
  • Compact Wire Representation: Minimizes overhead for high-throughput distributed messaging.

Quick Example

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fplugin=Polytropos.Plugin #-}

import Codec.Serialise (serialise, deserialise)
import Polytropos
import Polytropos.CBOR ()

type Packet = Record '[ "seq" := Int, "payload" := String ]

main :: IO ()
main = do
  let pkt = REC { seq = 1, payload = "ping" }
  let bytes = serialise pkt
  let pkt' :: Packet = deserialise bytes
  print pkt'

License

Dual-licensed under EUPL-1.2 OR Apache-2.0.