Containers and folds

wren ng thornton wren at community.haskell.org
Sat Sep 25 18:26:46 EDT 2010


On 9/25/10 9:41 AM, Johan Tibell wrote:
> On Sat, Sep 25, 2010 at 2:41 PM, Ian Lynagh<igloo at earth.li>  wrote:
>> On Fri, Sep 24, 2010 at 07:09:56PM +0200, Milan Straka wrote:
>>>
>>> I therefore propose to:
>>> a) add foldrWithKey and foldlWithKey to IntMap, make foldWithKey
>>>     deprecated and synonymous for foldrWithKey.
>>
>> Agree.
>>
>> 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!). We probably* can't do much
> about the functions already in the API, but lets discuss whether we
> really want to continue that pattern.

Why not (a) only specify the *WithKey variants explicitly, and (b) 
provide the rest via the Foldable class?

There are no class methods which cannot be expressed easily by the 
explicit API; we'll want the Foldable instance anyways;... The only 
breakage I can foresee is that people can't use the qualified import 
name with the Foldable methods.

-- 
Live well,
~wren


More information about the Libraries mailing list