[Haskell-cafe] Data.Map and strictness (was: Is Haskell aGoodChoice for WebApplications?(ANN: Vocabulink))

Daniel McAllansmith dm.maillists at gmail.com
Thu May 7 18:53:26 EDT 2009


On Fri, 08 May 2009 00:30:34 Claus Reinke wrote:
> > seq something like size map that will force a traversal of the entire
> > tree, and ensure that the result is actually demanded, ..
> > (Not tested)
>
> and not recommended, either, I'm afraid!-)
>
> |> Actually, I'm unsure how to fix this. For an expression like this:
> |>
> |>    Data.Map.delete key map
> |>
> |> how can I use seq (or something else) to sufficiently evaluate the above
> |> to ensure that the value associated with key can be garbage collected?

[snip]

> Anyway;-) You can see that size is actually pre-computed, so there's
> no guarantee that asking for it will traverse the internal representation,

Presumably seq'ing the Maybe you get from looking up the key will be 
sufficient to dereference the key, and will avoid unnecessary traversal of 
unrelated parts of the map.

Dan


More information about the Haskell-Cafe mailing list