RFC: Should Data.IntMap.Strict be value-strict in the function arguments or the map itself

Johan Tibell johan.tibell at gmail.com
Thu Oct 27 18:56:10 CEST 2011


Hi all,

As discussed in an earlier (accepted) proposal we're adding
Data.[Int]Map.{Strict,Lazy} APIs to make it easier for users to get the
desired strictness.

There are two subtly different ways these APIs can be strict:

1. All the functions are strict in the value argument, or
2. The structure is strict in the value field.

The difference shows up in functions like insertWith. For example, given

    insertWith (\ old _new -> old + 1) k v someMap

should 'v' be evaluated is the key 'k' is already in the map. (Note that the
value isn't used in the update function.)

If we go with option 2 it is more difficult for the user to reason about if
a given value passed to the API is evaluated or not (as in the above
example). We currently use option 1 for keys i.e.

    insert k v someMap

is strict in the key even if the map is empty (which wouldn't require us to
look at the key).

Thoughts? I'd love to see some design pros/cons of both approaches.

-- Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20111027/b977405c/attachment.htm>


More information about the Libraries mailing list