[Haskell-cafe] Top-level TVars

Simon Marlow simonmar at microsoft.com
Wed Dec 14 04:51:16 EST 2005


On 13 December 2005 18:34, Tomasz Zielonka wrote:

> On Tue, Dec 13, 2005 at 06:08:23PM +0000, Joel Reymont wrote:
>> Can this be done now or is this a GHC 6.5 feature?
>> 
>> My combination of unsafePerformIO with atomically $ newTVar does not
>> seem to be working.
> 
> Here is an example how you can initialize a top-level STM variable.
>     http://www.uncurry.com/repos/TimeVar/TimeVar.hs
> It just forks a new thread inside unsafePerformIO, it runs
> "atomically" in it and passes the result through ordinary MVar.

A cheaper way is just to seq the top-level TVar at the beginning of
Main.main.

Cheers,
	Simon


More information about the Haskell-Cafe mailing list