On Apr 28, 2008, at 10:01 PM, Ryan Ingram wrote:
The problem I have with all of these STM-based solutions to this
problem is that they don't actually cache until the action fully
executes successfully.
I just hacked together a new monad that I think might solve this, at
least with a little
*sigh* As is usual with my untested code, the code I just sent was
wrong. I will be able to actually test, correct, and refine it
tonight. If nobody else has picked it up by then I will do so.
- Jake
___
Haskell-Cafe mailing list
Alright, I have tested it now. I still feel funny about most of the
names I chose for the types and functions, and it's still very ugly,
but the code appears to work correctly. In this version I have also
added retry and orElse functions so that it can feel more like the
STM monad. I think
The garbage collector never gets to collect either the action used to populate
the cached value, or the private TMVar used to hold the cached value.
A better type for TIVal is given below. It is a newtype of a TVal. The
contents are either a delayed computation or the previously forced
Hi Chris,
Thanks a bunch for the new angle.
Question comments:
* I like the simplicity of using a single TVar whose state reflects the
not-computed/computed state of the IVal.
* I also like the public interface of taking an STM argument (newTIVal(IO))
over returning a sink
The problem I have with all of these STM-based solutions to this
problem is that they don't actually cache until the action fully
executes successfully.
For example, 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
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!
Thanks, Ryan, for the reminder and explanation of this problem. - Conal
On Mon, Apr 28, 2008 at 8:01 PM, Ryan Ingram [EMAIL PROTECTED] wrote:
The problem I have with all of these STM-based solutions to this
problem is that they don't actually cache until the action fully
executes