Re: [Haskell-cafe] TVars & throw

2007-03-08 Thread Thomas Conway
On 3/8/07, Chris Kuklewicz <[EMAIL PROTECTED]> wrote: What happens in your throw/catch case if I have stm1 = do some_stm_code_that_throws_your_exception stm2 = return Foo and I run "atomically (stm1 `orElse` stm2)" ? Answer: The exception will prevent running stm2. In the *specific* case of

Re: [Haskell-cafe] TVars & throw

2007-03-08 Thread Chris Kuklewicz
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) >>put

Re: [Haskell-cafe] TVars & throw

2007-03-07 Thread Stefan O'Rear
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 informa

[Haskell-cafe] TVars & throw

2007-03-07 Thread Thomas Conway
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