a dream of databases
John Meacham
john@repetae.net
Thu, 12 Jun 2003 19:02:55 -0700
so, I have been wanting to implement serialize to database functionality
for haskell in a certain way which may or may not be possible..
what would be nice is if I could dump an entire complex haskell data
structure (perhaps cyclic, but not infinite) to a hash-table database
(like berkeley db). pointers would be swizzled into hash keys and each
haskell thunk would become an entry in the database.
loading the database would return the haskell structure just as it was
put into the database but it would be demand loaded. meaning that
evaluating a data thunk will actually grab that entry out of the
database (like with lazy file reading) and entries that have not been
accessed in a while would be transparently reclaimed by the garbage
collector (and reloaded later if needed)
And of course, these haskell data structures should be albe to be
arbitrary and would look no different from other haskell data
structures. they would just have appropriate instances derived for them
by DrIFT (or perhaps template haskell).
now. I am pretty sure I can do the demand loading bit with some
goddawful code (inspired by HOODs internals) using unsafePerformIO and
Weak pointers in truly nefarious ways. The dumping to the database bit
is straightforward when working with trees. but I can't figure out a way
to do it for potentially complex datastructures. perhaps someone out
there has an idea? perhaps some template haskell tricks can be pulled to
make it happen? I realize that any solution will be quite hacky and
unlikely to be very portable.
John
--
---------------------------------------------------------------------------
John Meacham - California Institute of Technology, Alum. - john@foo.net
---------------------------------------------------------------------------