Simon Peyton-Jones wrote:
> 
> | But Haskell *really* needs some standard way of reading values in the
> | native format on a platform:
> 
> What about this specification?
It looks too slow and inflexible to me.  If I just want to get at the
byte representation of a Float, I have to create a whole MutableByteArray
just for that Float.  Also as far as I can see it just
copies pointers unless you make it a bit cleverer.  I think there are
two better ways to go.  You could implement either or both depending on
demand.
(1) be like SML/NJ and have blastRead/blastWrite functions (sorry, can't
    remember where you find them) from a to byte array and back,
    which write out a complete copy of their argument.  This is rather
    similar to garbage collection (you need to be clever with pointers,
    and avoid writing the same thing twice).  The user would be promised
    that if you read the result back in with the same program you would
    get the same value.  I think maybe you can even handle thunks under
    this assumption.
(2) have equivalents to Show/Read classes intended for machines.
    (MachineShow/MachineRead?)  So Show Double would produce the
    appropriate 8 IEEE bytes, and so on.

Reply via email to