STM and unsafePerformIO
Robert van Herk
rherk at cs.uu.nl
Wed Aug 3 06:58:39 EDT 2005
Never mind, I can probably use an MVar to work around this...
Robert van Herk wrote:
> Hello All,
> I think I've read somewhere that STM doesn't like unsafePerformIO.
> However, I would like to use a global STM variable. Something like this:
> module Main where
> import GHC.Conc
> import System.IO.Unsafe
> tSid = unsafePerformIO (atomically (newTVar 0))
> tickSessionID :: STM Int
> tickSessionID =
> do sid <- readTVar tSid
> writeTVar tSid (sid + 1)
> return sid
> main = atomically tickSessionID
> But, when I try this, the evaluation of main causes a segmentation
> fault. Is there a workaround for this bug?
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
More information about the Glasgow-haskell-users