[Haskell-cafe] Re: Caching the Result of a Transaction?
Jake Mcarthur
jake.mcarthur at gmail.com
Mon Apr 28 23:58:54 EDT 2008
On Apr 28, 2008, at 10:01 PM, Ryan Ingram wrote:
> [...] if you have a :: TIVal a, and f :: a -> TIVal b, and you execute
> force (a >>= f)
>
> and the action returned by f executes retry for whatever reason, then
> the caching done in "a" gets undone.
Dangit, you're right. You just rained on the parade! Hmm...
Perhaps we could use the data structure Chris proposed and mix it with
my first approach involving forkIO. Another thread can perform the
caching in a separate transaction _or_ the main thread can perform the
caching itself in case the extra thread doesn't get a chance first.
This would ensure that it manages to get cached _sometime_ even when
the main transaction itself retries, but it loses some of the elegance
we had gained by not forking a new thread and still doesn't
_guarantee_ that the computations are run only once.
This is not ideal. :(
- Jake
More information about the Haskell-Cafe
mailing list