[Haskell-cafe] strange stack overflow with Data.Map
Bulat Ziganshin
bulatz at HotPOP.com
Thu Dec 29 03:22:11 EST 2005
Hello David,
Thursday, December 29, 2005, 3:42:05 AM, you wrote:
>> stats elems = foldl add_elem Map.empty elems
DR> This program has a space leak and runs out of stack space. I'm guessing
DR> that I'm being bit here by an unnatural amount of laziness in
DR> Map.insertWith
stack overflows AFAIK is never occur because of laziness, but only
because your recursion is not tail-optimized. as Udo says, problem may
be fixed by using proper fold. if foldl' will not work - try to write
your own, explicit looping scheme
--
Best regards,
Bulat mailto:bulatz at HotPOP.com
More information about the Haskell-Cafe
mailing list