[Haskell] stack overflow - nonobvious thunks?
Udo Stenzel
u.stenzel at web.de
Wed Jul 27 14:01:47 EDT 2005
Scherrer, Chad wrote:
> f m x = Map.insertWith (+) x 1 m
insertWith is inserting the "nonobvious thunks". Internally it applies
(+) to the old value and the new one, producing a thunk. There is no
place you could put a seq or something to force the result. You
basically need insertWith', which isn't there.
I think, your best best is to manually lookup the old value, combine
with the new, force the result, then insert that, overwriting the old
value.
On top of that you still need foldl' to avoid building long chains of
Map.insert.
Udo.
--
The Second Law of Thermodynamics:
If you think things are in a mess now, just wait!
-- Jim Warner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell/attachments/20050727/80252a81/attachment-0001.bin
More information about the Haskell
mailing list