[Haskell-cafe] TVars & throw

Stefan O'Rear stefanor at cox.net
Wed Mar 7 20:34:05 EST 2007


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


More information about the Haskell-Cafe mailing list