containers
containers copied to clipboard
Fix -incomplete-uni-patterns
#590.
@treeowl ping :)
Have you tried comparing the merge vs. mergeWithKey' approaches?
Oops, I thought the plan was to apply this simple case+error solution before that. I'll try out the merge vs. mergeWithKey' idea and update this patch in the next couple days.
[Changes planned]
I would like to make a release in the next week or so, now that #593 is fixed, but we can certainly wait a couple days.
Hi @treeowl, I wanted to get this done this week, but it didn't happen. I spent a little bit of time trying to understand various parts of the Data.Sequence implementation. I'll finish it soon, over the weekend perhaps, but please don't let this block a release :)
Oops, I didn't make a release as intended.... Can you rebase this and look into my question?
@treeowl sorry for squatting on this for so long. I'll pick this up and try to finish it by this weekend.
@ckoparkar Ping!
My impression is that there's very little left to do before this could be merged. Or maybe we could at least merge the non-controversial bits and leave out the "merge vs. mergeWithKey'" "controversy". (I have no idea what it's about.)
The PR definitely needs a rebase though.
@ckoparkar Can you bring this to completion?
Or would you, @mitchellwrosen, possibly volunteer to finish this?
@sjakobi I'm afraid I've forgotten most of the context here. As far as I can tell, David's suggestion was to try to use merge instead of mergeWithKey' in some of these places. Sorry, but I won't be able to contribute much here. If you or someone else wants to pick this up, please feel free.
mergeWithKey is a nasty API that basically forces users to supply partial functions and also allows the data structure invariants to be violated. merge is slightly less general API that nevertheless supports pretty much everything one might actually want from mergeWithKey. If we can use it without losing performance, that would be a good way to be rid of some incomplete patterns.
Thanks for the update, @ckoparkar, and thanks for the explanation, @treeowl! :)
I generally agree that it would be nice to use merge instead of mergeWithKey'. It's far from obvious to me though, that this could be done here without loss of performance: IntMap.merge is just runIdentity (mergeA ...) and mergeA has to do quite a bit of extra work to get the effects sequencing right. mergeWithKey' also offers a small optimization specifically for unionWithKey:
https://github.com/haskell/containers/blob/4ac960a01f058ae923cf51c6108aae0acbb802dd/containers/src/Data/IntMap/Internal.hs#L1372-L1375
It would of course still be interesting to benchmark results using merge, but I think the chances that the results would be good are fairly low.
I also kind of feel that contributors shouldn't be expected to solve a different problem than they originally intended to work on.
So, what I see that needs to be done for this PR to be accepted is:
- A rebase.
- Remove the outdated comments in
mergeWithKeythat @treeowl pointed out above.