
27 May
2009
27 May
'09
11:08 p.m.
Thanks for the tip, although it seems tricky to get it right. I wonder why there is no strict version of atomicModifyIORef? Dually there might be a strict version of IORef datatype.
Alternatively, you could use STM, where you can write your own atomic update function, which has the strictness you need (untested): import Control.Concurrent.STM strictUpdate :: (a->a) -> TVar a -> STM () strictUpdate f v = do x <- readTVar v let x1 = f x x1 `seq` writeTVar v x1 g :: (Int->Int) -> TVar Int -> IO () g f v = atomically (strictUpdate f v) Tim