[Haskell-cafe] Stack overflow
bertram.felgenhauer at googlemail.com
Wed May 27 14:38:24 EDT 2009
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.
More information about the Haskell-Cafe