RE: [Haskell-cafe] STM, orElse and timed read from a channel

Can you provide a small test case that demonstrates the crash? I think it's pretty unlikely that we'll support nested atomically (via unsafePerformIO) anytime soon. UnsafePerformIO is, well, unsafe. I think you are really asking for some way to create top-level transactional variables? Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of | Tomasz Zielonka | Sent: 04 December 2005 18:32 | To: Simon Marlow | Cc: Haskell Cafe | Subject: Re: [Haskell-cafe] STM, orElse and timed read from a channel | | On Sat, Dec 03, 2005 at 10:35:54PM +0100, Tomasz Zielonka wrote: | > so I could export a waitUntil function with type | > | > waitUntil :: Time -> STM () | > | > but I tripped on something that was reported before, namely that STM | > transactions can't be nested (as a result of unsafePerformIO or | > unsafeInterleaveIO). Is there a plan to support such scenario? | | OK, it can be worked around by running the atomically block in a new | transaction. But still it would be nice if the program didn't segfault, | but cause an exception for example. | | Updated modules attached. | | Best regards | Tomasz | | -- | I am searching for a programmer who is good at least in some of | [Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland

On Mon, Dec 05, 2005 at 09:19:05AM -0000, Simon Peyton-Jones wrote:
Can you provide a small test case that demonstrates the crash?
Here it is: import Control.Concurrent.STM import System.IO.Unsafe (unsafePerformIO) {-# NOINLINE var #-} var :: TVar () var = unsafePerformIO (atomically (newTVar ())) main = atomically (readTVar var) I remember someone else posted a crash example with unsafeInterleaveIO.
I think it's pretty unlikely that we'll support nested atomically (via unsafePerformIO) anytime soon.
OK, it's fine with me. But maybe it would be easy to raise an exception in such scenario?
UnsafePerformIO is, well, unsafe.
And so is unsafeInterleaveIO.
I think you are really asking for some way to create top-level transactional variables?
Yes. Perhaps it would be easier to do it cleanly than arbitrary top-level IO bindings? In fact, almost every time I wanted a top-level unpure thingy, it was a concurrency variable. Best regards Tomasz -- I am searching for a programmer who is good at least in some of [Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
participants (2)
-
Simon Peyton-Jones
-
Tomasz Zielonka