Containers and strictness continued

Johan Tibell johan.tibell at gmail.com
Fri Jul 9 08:44:27 EDT 2010


On Fri, Jul 9, 2010 at 11:56 AM, Milan Straka <fox at ucw.cz> wrote:

> Hi all,
>
> for my work on the containers I need to settle some questions about
> strictness.
> Thank you very much for your opinions.
>
> Discussion ends: 23. July 2010.
>
> 1) Strictness of keys and values in the datatype.
>
> Currently we have the following strictness flags in the datatypes:
> - IntMap: !key value
> - IntSet: !key
> - Map: !key value
> - Set: key
>
> I vote for changing Set to store keys also strict.
>
> Storing values as nonstrict probably makes sense.
>
> 2) Strictness of keys and values in the method definitions.
>
> The IntMap.lookup (lookup k t = ... seq k ...) evaluates the given key
> even if it is not needed (when searching empty tree). Some methods are
> more carefull.
>
> I vote for all IntMap, IntSet, Map and Set methods that are given a key
> value (insert, delete, member, ...) to be strict in the keys. This
> a) would be consistent with 1)
> b) would be a bit more efficient (~5% in the IntMap.lookup case)
>
> 3) Strict folds
>
> Currently there are no strict folds.
>
> I vote for adding strict folds (fold', foldWithKey' when appropriate) to
> all Map, Set, IntMap, IntSet.
>

I agree on all points. I've looked into the core generated for lookup,
insert, etc and it looks better when the key is strict. It's hard to
actually make use of the fact that some function aren't strict in the key,
as they are only non-strict in the case of an empty data structure (so
they're conditionally non-strict).

Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20100709/4335753d/attachment.html


More information about the Libraries mailing list