Containers and folds

Daniel Fischer daniel.is.fischer at web.de
Fri Sep 24 16:42:18 EDT 2010


On Friday 24 September 2010 22:20:56, Johan Tibell wrote:
> On Fri, Sep 24, 2010 at 7:09 PM, Milan Straka <fox at ucw.cz> wrote:
> > There are two thinks to sort out: a) add left/right folds, b) add
> > strict folds.
> >
> > I therefore propose to:
> > a) add foldrWithKey and foldlWithKey to IntMap, make foldWithKey
> >   deprecated and synonymous for foldrWithKey.
>
> +1
>

ditto

> > b) add foldl and foldr to Set and IntSet, make fold deprecated
> >   and synonymous to foldr.
>
> +1
>

ditto

> > c) add strict variants of left and right folds, namely
> >  Data.Map, Data.IntMap: foldlWithKey' foldrWithKey'
> >  Data.Set, Date.IntSet: foldl', foldr'
>
> +1
>

ditto

> > Some issues:
> > - should we really rename fold -> foldr? Maybe we could cla
> >  that fold and foldWithKey are right folds and add only
> >  foldl and foldlWithKey.
>
> I'd prefer to rename. We need to keep the old version around for a long
> time though, with a DEPRECATED pragma encouraging people to upgrade.
>

I heartily agree.

> > - should we really deprecate fold and foldWithKey? It could break
> >  a lot of code.
>
> I think so. Give people a year or so to move over.
>

I agree here also.

> > - adding foldl, foldr, foldl' and foldr' to Set and IntSet is going to
> >  cause a lot of trouble because of shadowing. Maybe some better name?
> >  On the other hand, these are the "right" names.
>
>  I think we should go with the "right" names. I think many modules
> already import these modules qualified due to other name clashes (as
> they should). We should encourage proper use of namespaces to resolve
> name clashes. Breakages can be resolved by putting a upper version bound
> on containers in the .cabal file of the broken library.

And here too.

>
> -- Johan

Cheers,
Daniel


More information about the Libraries mailing list