
27 May
2009
27 May
'09
6:38 p.m.
Krzysztof Skrzętnicki wrote:
The code for modifying the counter: (\ msg -> atomicModifyIORef ioref (\ cnt -> (cntMsg cnt msg,())))
atomicModifyIORef does not force the new value of the IORef. If the previous contents of the IORef is x, the new contents will be a thunk, (\ cnt -> (cntMsg cnt msg,())) x You can try forcing the new value, say by adding
readIORef ioref >>= (return $!)
after the atomicModifyIORef.
The datatype itself is strict. So where is the thunk actually accumulating?
In the IORef. HTH, Bertram