Proposal: IntMap.differenceKeysSet for removing an IntSet of keys

Liyang HU at
Sun Jun 12 14:14:10 CEST 2011

wren ng thornton <wren <at>> writes:
> On 6/9/11 10:17 PM, Liyang HU wrote:
> > fromSet :: (Key ->  a) ->  IntSet ->  IntMap a
> One downside of using fromSet is that it clones the IntSet before 
> differencing. Since IntSet is spine-strict, this can be quite expensive 
> since it'll clone the whole thing no matter how much is used.

> I like the idea of having a fromSet function with the (Key->a) argument. 
> But there's also room for differenceKeysSet for efficiency reasons. 
> Perhaps you can come up with some fusion rules to get rid of the 
> overhead of difference m (fromSet f s)?

There's precisely this rule in patch 0005 on the ticket.

> Certainly there should be the rule:
>      map f . fromSet g = fromSet (f . g)
> and similar for the other mapping functions.

I have a bunch of similar RULES in my own code already… (map, filter &c.)
Should probably file them under a separate ticket.


More information about the Libraries mailing list