
Ivan Lazar Miljenovic wrote:
Except that binary and cereal are for serializing Haskell values directly; you seem to be wanting to parse and generate a particular encoding for a value. In which case, I don't think binary or cereal is really appropriate.
I meant "encode" as in "use a specific representation rather than directly converting it on a constructor-by-constructor basis as is the default for Get/Put".
I must still not be understanding what you meant in your original comment. Because in my view, cereal and binary are *exactly* designed for that use, and do it extremely well. The only place where a particular "constructor-by-constructor" approach is built in is in the facilities for automated generation of parsers using generic techniques. But when writing parsers directly, you have full flexibility, and a powerful set of built-in tools to back you up.