[Haskell-cafe] strange stack overflow with Data.Map

Udo Stenzel u.stenzel at web.de
Wed Dec 28 22:05:05 EST 2005

David Roundy wrote:
> > stats elems = foldl add_elem Map.empty elems
> > add_elem m x = Map.insertWith (+) x 1 m
> [...]
> I tried defining
> add_elem m x = let m' = Map.insertWith (+) x 1 m
>                    Just num = Map.lookup x m'
>                in seq num m'
> to force the (+) to be evaluated strictly, but that didn't help.

No, it doesn't, unless you also use foldl'.  Not tested, but been
there, seen it, bought the t-shirt.

The Force is what holds everything together.  It has its dark side, and
it has its light side.  It's sort of like cosmic duct tape.
-------------- 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-cafe/attachments/20051229/1c30e5b9/attachment.bin

More information about the Haskell-Cafe mailing list