[Haskell-cafe] STM, orElse and timed read from a channel
simonpj at microsoft.com
Mon Dec 5 05:50:13 EST 2005
| > 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?
It turns out to be easy to provide
newTVarIO :: a -> IO (TVar a)
which you can call from inside 'unsafePerformIO'. That means you can
allocate top-level TVars without fuss.
The whole question of top-level IO remains open, but this will address
the immediate question very nicely.
I've also added a SourceForge bug to remind us to fail more tidily if
you do atomically inside atomically.
More information about the Haskell-Cafe