BSD-3-Clause licensed by Sam Truzjan
Maintained by Sergey Vinokurov
This version can be pinned in stack with:bencoding-0.4.5.6@sha256:ceda320189ef3ee259654f08d26d8a1f103134ac60cb0d6aa7073e67015471a7,4584

Module documentation for 0.4.5.6

Synopsis

BEncode is JSON-like format used in bittorrent protocol but might be used anywhere else.

Description

This package implements fast seamless encoding/decoding to/from bencode format for many native datatypes. To achieve more performance we use bytestring builders and hand optimized attoparsec parser so this library is considered as replacement for BEncode and AttoBencode packages.

Format

Bencode is pretty similar to JSON: it has dictionaries(JSON objects), lists(JSON arrays), strings and integers. However bencode has a few advantages:

  • Compactness: no spaces in between any values — nor lists nor dicts nor anywhere else.
  • Dictionaries always sorted lexicographically by the keys. This allow us to test data on equality without decoding from raw bytestring. Moreover this allow to hash encoded data (this property is heavily used by core bittorrent protocol).
  • All strings prefixed with its length. This simplifies and speed up string parsing.

Hovewer there are some disadvantages comparing with JSON:

  • Bencode is certainly less human readable.
  • Bencode is rarely used, except bittorrent protocol of course.

Documentation

For documentation see package hackage page.

Build Status

build

Maintainer [email protected]

Feel free to report bugs and suggestions via issue tracker or the mail.

Changes

0.4.5.6

  • Fix build for GHC 9.10

0.4.5.5

  • Fix build for GHC 9.6

0.4.5.2

  • Fix build for GHC 8.8.1

0.4.5.1

  • Fix benchmark build when dependency on AttoBencode is switched off

0.4.5.0

  • Test against GHC 8.6. Make benchmark dependency on AttoBencode disableable

0.4.4.0

  • Fix build for GHC 8.0-8.4. Derive Generic instances. Add Semigroup instance.

0.4.3.0

  • Add lookAhead and match functions.

0.4.2.1

  • Override default Monad(fail) method so it is possible to catch Get monad failures from pure code.

0.4.2.0

  • Override default fixity for operators. Previously it has been impossible to mix bencode Get operators ((<$>!), (<$>?), (<*>!), (<*>?)) with applicative operators ((<$>), (<*>)).

0.4.1.0

  • Expose parser and builder so it is possible to use parser incrementally.

0.4.0.2

  • Minor fixes.

0.4.0.1

  • Nothing changed.

0.4.0.0

  • Faster dictionary conversion.

0.3.0.0

  • Rename BEncode to BValue and BEncodable to BEncode.

0.2.2.0

  • Arbitrary length integers. (by specification)

0.2.0.0

  • Added default decoders/encoders using GHC Generics.

0.1.0.0

  • Initial version.