2008/10/14 Mitchell, Neil <[EMAIL PROTECTED]>:
> Hi,
>
> There is an alternative 4:
>
> Require Data/Typeable instances for all items, then using runtime
> reflection provided by Data serialise the values into binary (or however
> else you want them).

Yes, we did consider this, and should have mentioned it on the wiki.
The reasons that I'm not keen are:

1) What if a type is somewhat abstract and so has a Data instance
which doesn't reflect the full internal structure of a type?
Serialization becomes a lossy process (and gunfold wouldn't be defined
in such a case anyway). I don't know how common this (anti?)pattern is
in practice but I have used it myself.

2) (Somewhat related) What if a type contains some computed fields
that should not be serialized? An example is TypeRep, which is
"really" a rose tree of strings but as an optimization for comparison
has unique numbers added to it by the constructor functions.
Unfortunately these numbers are only unique for one run of the
process, so what you really want to do is serialize the strings and
then rebuild the TypeRep using its public interface. I don't think any
Data based serialization mechanism could figure this out.

IMHO Data really "means" something different than Binary, so you could
probably find some more odd cases like the above.. Maybe I'm worrying
too much though.

Cheers,
Max

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to