Timothy Robin BARBOUR <[EMAIL PROTECTED]> writes:
> There is another way one might proceed. Why not just use a
> memory-mapped file (mmap) to make the data persistent in-place ? This
> would be a way of getting efficient persistence of (almost) any
> Haskell data structure without any code-writing and without any
> flattening. There are a few difficulties here, but it may well be
> feasible. The problems are:
If I understand this right, you're suggesting essentially dumping out
part of the Haskell heap to a file. Assuming the data you want to
dump out is closed (i.e. has no external references) and is fully
evaluated, there are still some problems remaining:
- The data is location-dependent, and the exact location the
data was originally resident at might not be available at
load-time, so it would have to be relocated.
- Heap-resident data in GHC refers (by address) to the code of
the program itself, and to parts of the run-time system.
You'd have to do some kind of dynamic linking to be able to
load data back again.
- The format of heap-resident data varies depending on things
like profiling, so you wouldn't be able (for instance) to
load data generated by a profiled program into one that isn't.
So, you could avoid these problems by always loading the data at the
same address in memory, and only using one program to save/load data.
If you recompiled the program, you'd have to regenerate the persistent
store. This seems overly restrictive, it might be simpler to just use
the Native or Binary classes.
Cheers,
Simon
--
Simon Marlow [EMAIL PROTECTED]
University of Glasgow http://www.dcs.gla.ac.uk/~simonm/
finger for PGP public key