
Stefan O'Rear wrote:
On Thu, Mar 08, 2007 at 12:25:15PM +1100, Thomas Conway wrote:
Hi All,
Consider the following:
foo = do v <- newTVar "hi there!" throwDyn v
main = do catchDyn (atomically foo) \v -> do x <- atomically (readTVar v) putStr x
I.e. throw information that gets rolled back from inside a transaction, catch it and use it.
This looks like bad. I assume it actually works, but should it?
Read the paper!
it is quite explicitly documented that exceptions can take data out of a failing transaction, spj thought it preferable to simply erasing all error data.
Stefan
And one can always use unsafeIOToSTM to exchange data as well, which is what I used to implement MonadAdvSTM. This lets you queue IO actions to perform if there is a retry and queue IO actions to perform if there is a commit. http://haskell.org/haskellwiki/New_monads/MonadAdvSTM