Proposal: Non-allocating way to iterate over a Data.Map: traverseWithKey_

Roman Cheplyaka roma at
Fri Aug 2 09:13:32 CEST 2013

* Ryan Newton <rrnewton at> [2013-08-01 10:58:48-0400]
> > I believe implementing traverseWithKey_ using a foldWithKey is
> > quite natural (you want to go over the elements and do something with
> > them, in this case perform some action on them). I expected it to work
> > and I am surprised it does not. So for me it is the other way around --
> > I have a function which I expected to behave nice as a fold and it does
> > not
> >
> Re: expectations.  You don't get a funny feeling when monadic values are
> used as first class rather than second class ;-)?  Whether in the
> accumulator of a fold, or in cases like this:
>   do act <- f x
>        act

I don't. I don't even believe that the compiler can spot the difference
between the two. (But maybe it's just my ignorance.)

Do you have a specific example where this is a problem?


More information about the Libraries mailing list