Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- sizeSequence :: ( IsSequence mono, Flat ( Element mono)) => mono -> NumBits -> NumBits
- encodeSequence :: ( Flat ( Element mono), MonoFoldable mono) => mono -> Encoding
- decodeSequence :: ( Flat ( Element b), IsSequence b) => Get b
- sizeList :: ( MonoFoldable mono, Flat ( Element mono)) => mono -> NumBits -> NumBits
- encodeList :: ( Flat ( Element mono), MonoFoldable mono) => mono -> Encoding
- decodeList :: ( IsSequence b, Flat ( Element b)) => Get b
- sizeSet :: ( IsSet set, Flat ( Element set)) => Size set
- encodeSet :: ( IsSet set, Flat ( Element set)) => set -> Encoding
- decodeSet :: ( IsSet set, Flat ( Element set)) => Get set
- sizeMap :: ( Flat ( ContainerKey r), Flat ( MapValue r), IsMap r) => Size r
- encodeMap :: ( Flat ( ContainerKey map), Flat ( MapValue map), IsMap map) => map -> Encoding
- decodeMap :: ( Flat ( ContainerKey map), Flat ( MapValue map), IsMap map) => Get map
-
newtype
AsArray
a =
AsArray
{
- unArray :: a
-
newtype
AsList
a =
AsList
{
- unList :: a
-
newtype
AsSet
a =
AsSet
{
- unSet :: a
-
newtype
AsMap
a =
AsMap
{
- unMap :: a
Documentation
sizeSequence :: ( IsSequence mono, Flat ( Element mono)) => mono -> NumBits -> NumBits Source #
Calculate size of an instance of IsSequence as the sum: * of the size of all the elements * plus the size of the array constructors (1 byte every 255 elements plus one final byte)
encodeSequence :: ( Flat ( Element mono), MonoFoldable mono) => mono -> Encoding Source #
Encode an instance of IsSequence, as an array
decodeSequence :: ( Flat ( Element b), IsSequence b) => Get b Source #
Decode an instance of IsSequence, as an array
encodeList :: ( Flat ( Element mono), MonoFoldable mono) => mono -> Encoding Source #
decodeList :: ( IsSequence b, Flat ( Element b)) => Get b Source #
encodeMap :: ( Flat ( ContainerKey map), Flat ( MapValue map), IsMap map) => map -> Encoding Source #
Encode an instance of IsMap, as a list of (Key,Value) tuples
decodeMap :: ( Flat ( ContainerKey map), Flat ( MapValue map), IsMap map) => Get map Source #
Decode an instance of IsMap, as a list of (Key,Value) tuples
Sequences are defined as Arrays:
Array v = A0 | A1 v (Array v) | A2 v v (Array v) ... | A255 ... (Array v)
In practice, this means that the sequence is encoded as a sequence of blocks of up to 255 elements, with every block preceded by the count of the elements in the block and a final 0-length block.
Lists are defined as:
List a ≡ Nil | Cons a (List a)
The AsList/AsArray wrappers can be used to serialise sequences as Lists or Arrays
>>>
tst $ AsArray ([]::[()])
(True,8,[0])
>>>
tst $ AsArray [11::Word8,22,33]
(True,40,[3,11,22,33,0])
>>>
tst $ AsList ([]::[()])
(True,1,[0])
>>>
tst (AsList [11::Word8,22,33])
(True,28,[133,197,164,32])
>>>
tst (AsSet (Data.Set.fromList [11::Word8,22,33]))
(True,28,[133,197,164,32])
Instances
Eq a => Eq ( AsArray a) Source # | |
Ord a => Ord ( AsArray a) Source # | |
Defined in Flat.Instances.Mono |
|
Show a => Show ( AsArray a) Source # | |
( IsSequence r, Flat ( Element r)) => Flat ( AsArray r) Source # | |
Instances
Eq a => Eq ( AsList a) Source # | |
Ord a => Ord ( AsList a) Source # | |
Defined in Flat.Instances.Mono |
|
Show a => Show ( AsList a) Source # | |
( IsSequence l, Flat ( Element l)) => Flat ( AsList l) Source # | |
Instances
Eq a => Eq ( AsSet a) Source # | |
Ord a => Ord ( AsSet a) Source # | |
Defined in Flat.Instances.Mono |
|
Show a => Show ( AsSet a) Source # | |
( IsSet set, Flat ( Element set)) => Flat ( AsSet set) Source # | |
Maps are saved as lists of (key,value) tuples.
>>>
tst (AsMap (Data.Map.fromList ([]::[(Word8,())])))
(True,1,[0])
>>>
tst (AsMap (Data.Map.fromList [(3::Word,9::Word)]))
(True,18,[129,132,128])
Instances
Eq a => Eq ( AsMap a) Source # | |
Ord a => Ord ( AsMap a) Source # | |
Defined in Flat.Instances.Mono |
|
Show a => Show ( AsMap a) Source # | |
( IsMap map, Flat ( ContainerKey map), Flat ( MapValue map)) => Flat ( AsMap map) Source # | |