
On Mon, Jun 28, 2010 at 2:32 PM, Don Stewart
claus.reinke:
To binary package users/authors: is there a typed version of binary (that is, one that records and checks a representation of the serialized type before actual (de-)serialization)? It would be nice to have such a type check, even though it wouldn't protect against missing bytes or strictness changes.
There is a wrapper, that wraps all encodes in a typeOf (iirC), I think by Edward Kmett, but I couldn't find e.g. binary-typed on Hackage.
In Happstack.Data there's a wrapper type called Object which we serialize through which has a type-rep field and a ByteString field, and the deserialize instance function checks that the type-string filed matches "show (typeOf result)": http://hackage.haskell.org/packages/archive/happstack-data/0.5.0.2/doc/html/... A similar technique might be approrpiate for 'binary' or 'cereal'. Antoine