Hey it works :D
Here is a proof of concept:
http://gist.github.com/189104
Maybe later today I'll try to make a version that can be safely used outside
IO.
- Job
On Fri, Sep 18, 2009 at 10:19 AM, Job Vranish wrote:
> Yeah it seems like the general solution to the problem would be some sort
> o
Yeah it seems like the general solution to the problem would be some sort of
map-like datastructure that you add items via a key/value pair, and if the
key gets GC'd, that entry gets removed from the structure.
I've been wanting something like this as well, but didn't know about weak
references so
I would also like to see a solution for problems like these.
Haskell provides a lot of nice memoizing / caching data structures -
like a trie - but the ones I know indeed keep growing, so no garbage
collection takes place?
It would be nice to have a data structure that performs caching but
does n
In my case, the results of each computation are used to generate a node
in a graph structure (dag). The key, oddly, is a hash of a two-tuple
that gets stored in the data structure after the computation of the
node finishes. If I don't memoize the function to build a node, the
cost of generating t
What are you trying to use this for? It seems to me that for memo tables you
almost never have references to they keys outside the lookup table since the
keys are usually computed right at the last minute, and then discarded
(otherwise it might be easier to just cache stuff outside the function).
How does garbage collection work in an example like the one below? You
memoize a function with some sort of lookup table, which stores function
arguments as keys and function results as values. As long as the
function remains in scope, the keys in the lookup table remain in
memory, which means th