Neo

Results 17 comments of Neo

My motivation was first performance (less allocation) and second convenience. Yes, ```insertWith``` has one less argument and is easier to understand but the scenario I describe has an impedance mismatch...

I covered your first point in my previous message (building a closure will allocate unless by magic everything gets inlined the right way -- which is no way to live...

Thank you for that insight. I rewrote it slightly to understand what you did: ``` insertWith' f g key x = M.insertWith (\vnew vold -> f x vold) key (g...

It appears to me (please correct me if I am wrong) that there is another performance issue with your implementation here: ``` insertWith' :: (Ord k) => (a -> b...

I have implemented the above proposal with an alternative interface as suggested by @konsumlamm . I have tentatively named the function insertWithFun (betters names are welcome). The new interface now...

@treeowl But how? It's not really possible with the existing apis (alter, insertWith). Boxes and closures are your only choice. And the case I am describing happens often enough in...

Let's have a closer look. Let for example v = Set w. Calling ```insyboggle``` we must create a singleton set for its first argument (which it may not use) and...

@Lysxia I have tried your code (with ghc 8.10.4, options -O2 -fno-full-laziness) but I was not able to get ghc to inline `alter`. I didn't change INLINABLE to INLINE so...

@treeowl I am sorry but I don't understand your comment regarding 'arity' at all. Please elaborate.

@Lysxia ghc may decide not to inline a function for all sorts of reasons. The INLINE directive forces the inline but is that the right thing in all cases? ```alter```...