Typeclasses for binary serialization in PureScript.
Note: Although this library shares a lot of features similar to the cereal library from Haskell, it is not yet compatible.
It should feel fairly similar to Argonaut, but with a
binary spin on things - everything is very
Effect-ful, and will throw errors if something doesn't line-up as expected.
Just implement the
DecodeArrayBuffer typeclasses to support binary serialization for
your data type.
Arrayinstance first packs its length as a 4-byte
Uint32BE- I don't know of a perfect way around this without excessive testing.
CodePointinstances seem to reflect utf-8 pretty decently - Woo Hoo! Pure utf-8 serialization!! But wait...
Stringinstance just turns it into an
Array CodePoint, so there's an initial word denoting the string's length. Right now, I don't know of a clean way around this, without making every instance have a length argument.
Vecinstance actually sidesteps the length argument, because the length is assumed to be known at compile-time.
ArrayViewinstances also have a similar initial length argument. Writing is not as efficient as you'd hope.
Recordinstance first turns the record into an
Object ArrayBuffer, which then becomes a
Array (Tuple String ArrayBuffer)- it's not super efficient.
Genericinstances treat every
Sumas its own distinguished, isolated possability - for data types with multiple consecutive sum values, like
Ordering, it's suggested to write your own instance to pack each sum constructor as its own flag in the byte range
0 - 255.
Sums are treated like