Persistant (as in on disk) data

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Thu, 6 Mar 2003 15:06:52 +0000


"Simon Marlow" <simonmar@microsoft.com> writes:

> > i'd like to be able to dump data structures to disk, and later load 
> > them.
> 
> A Binary library was discussed recently on the libraries list.
> I think the outstanding issues are ...
>
>   (a) is the API for GHC's Binary library acceptable, or do we need
>       the extra bells and whistles that the NHC version has?

In particular, the NHC version is platform-independent with regard
to endian-ness issues, whereas I believe the GHC version is not?

>   (b) can we make a version of Binary that uses a bit-by-bit
>       rather than byte-by-byte serialisation of the data that is
>       as fast (or nearly as fast) as the current byte-by-byte
>       implementation?  Perhaps performance isn't that important
>       to the majority of people: please comment if you have
>       an opinion.

In experiments, I found the bit-by-bit serialisation at least an
order of magnitude faster than Show/Read.  The extra speed margin
obtained by going byte-wise might be nice, but isn't so important
(to me) as that first step from text to binary.

>   (c) how do we derive instances of Binary?

The nhc98 compiler already accepts a `deriving Binary' clause.
DrIFT likewise already supports {-! derives : Binary !-}.  I imagine
it wouldn't be too difficult to use GHC's support for Generics to code
up a simple deriving mechanism as well.

> IMHO: something is better than nothing, so I'd be in favour of just
> plugging in the Binary library from GHC, and marking it "experimental".

Something I have never got round to asking before is what were the
perceived defects in the nhc98 Binary library that encouraged (a) Sven
to rewrite it for GHC, and (b) Simon to rewrite it again?

Regards,
    Malcolm