flat-0.6: Principled and efficient bit-oriented binary serialization.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Flat.Encoder

Description

Encoder and encoding primitives

Synopsis

Documentation

(<>) :: Semigroup a => a -> a -> a infixr 6 Source #

An associative operation.

>>> [1,2,3] <> [4,5,6]
[1,2,3,4,5,6]

type NumBits = Int Source #

Number of bits

mempty :: Monoid a => a Source #

Identity of mappend

>>> "Hello world" <> mempty
"Hello world"

eTrueF :: Prim Source #

>>> enc eTrueF
"1"

eFalseF :: Prim Source #

>>> enc eFalseF
"0"

encodeArrayWith :: (t -> Encoding) -> [t] -> Encoding Source #

Encode as Array

encodeListWith :: (t -> Encoding) -> [t] -> Encoding Source #

Encode as a List

type Size a = a -> NumBits -> NumBits Source #

Add the maximum size in bits of the encoding of value a to a NumBits