Proposal: add traverseWithKey to Data.Map

Milan Straka fox at
Thu Mar 15 17:02:18 CET 2012


> > This is a rather useful function, and if we define it in SATed style
> > and with an INLINE pragma (as in my attached patch), GHC can generate
> > really good code for it at use sites.
> I think we're moving away from INLINE in favour of INLIN[E]ABLE.  In
> this case it seems fine since it's just building a closure +
> tailcalling which probably would get optimised away.  Still, would
> using INLINEABLE have a drawback in this case?

Reasonably small high order functions are marked INLINE, for example all
folds, and I would consider traverseWithKey to be reasonably small.

This allows to inline all calls to f in traverseWithKey, which can be
a huge win (for example, if f only uses primops).


More information about the Libraries mailing list