I am working on a Haskell application, running in the browser compiled with GHCJS, which communicates with a server, also written in Haskell, over websockets. Both programs share the same Haskell data type definition, and I “just” have to pick serialization format.
At the moment, for simplicity, the program runs on Read and Show, which works, but is obviously not ideal.
On the other hand, it is unclear if the usual contenders for fast serialization, such as the cereal library, which work on ByteStrings are actually going to be efficient in GHCJS. Furthermore, GHCJS’s API seems to make it hard to let ByteStrings interact with the binary Blob type that the JavaScript bindings to Websockets provide.
Generic code generation (using GHC.Generics) would be nice.
Has anyone solved this problem before? Possibly even benchmarked various serialization variants on GHCJS?