On Feb 28, 2009, at 5:59 AM, Svein Ove Aas wrote:
I'm in the process of writing a distributed filesystem (in haskell,
yay), which of course means I'm using Binary for de/serialization.
Now, that's fine enough, but for simplicity (and for wireshark), I'd
like to be able to have Binary fall back on an instance based on
Show/Read for any type that lacks any other Binary instance.
Rather than something funny with extensions, why not write two
methods, of type
defBinaryPut :: Show a => a -> Put
defBinaryGet :: Read a => Get a
Then, if somebody tries to use something lacking a Binary instance,
they can just define a simple instance with those two methods. And
when they want to improve performance, they just write better
methods. :-)
In fact, these seem useful enough to go into, if not Data.Binary
itself, a separate package. After all, proper serialization shouldn't
be a barrier to rapid prototyping.
Cheers,
S.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe