Containers and folds

Ian Lynagh igloo at earth.li
Sat Sep 25 09:57:17 EDT 2010


On Sat, Sep 25, 2010 at 03:41:53PM +0200, Johan Tibell wrote:
> On Sat, Sep 25, 2010 at 2:41 PM, Ian Lynagh <igloo at earth.li> wrote:
> >
> > Why not also add foldl and foldr to Map and IntMap, and deprecate fold?
> 
> I think having all these with and without key version of all the
> functions in Data.{Map,Set} is a misstake. They don't improve
> performance (I've checked) and they almost double the size of the API
> (which is a whopping ~150 functions!).

It does add a load more functions, but not much cognitive overhead. In
fact, I think users will find it easier if the simpler functions they
are used to from other type (e.g. [], Set) exist.

The WithKey functions are also klunkier to use if you don't need the
key, especially if you are using them in a point-free style (e.g. if
you're mapping or folding with them).

> * I'm working on a tool to check all of Hackage for use sites of
> particular functions. If that tool shows that no one uses some of
> these functions, we could consider removing them.

Yes, it would be very useful to see how many uses there are of the
WithKey functions vs the keyless functions. It may also be interesting
to see how many of the WithKey calls ignore the key.


Thanks
Ian



More information about the Libraries mailing list