Safe Haskell | None |
---|---|
Language | Haskell2010 |
Flat instances for the bytestring library
Orphan instances
Flat ShortByteString Source # |
|
Flat ByteString Source # |
|
Flat ByteString Source # | ByteString, ByteString.Lazy and ByteString.Short are all encoded as Prealigned Arrays: PreAligned a ≡ PreAligned {preFiller :: Filler, preValue :: a} Filler ≡ FillerBit Filler | FillerEnd Array v = A0 | A1 v (Array v) | A2 v v (Array v) ... | A255 ... (Array v) That's to say as a byte-aligned 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.
where: 1= PreAlignment (takes a byte if we are already on a byte boundary) 3= Number of bytes in ByteString 11,22,33= Bytes 0= End of Array
Pre-alignment ensures that a ByteString always starts at a byte boundary:
All ByteStrings are encoded in the same way:
|