-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add filterKeys for Map and IntMap #972
Conversation
Please don't include your Stack files. While I won't require it, I would prefer to see validity tests and also property tests (with validity tests) added both for |
Hello. The stack files i committed accidentally in my last commit. I will try to fix the test again |
We have filter p m = filterWithKey (\_ x -> p x) m So why not filterKeys p m = filterWithKey (\k _ -> p k) m instead of duplicating the definition of |
I don't see the advantage of this over just using |
It's the equivalent of |
Sure, I know what it does, but why should we add it, when we can just use |
I can't speak for the original poster @emilypi but for my point of view is that haskell libraries have many convenience functions that potentially can be expressed in terms of extra functions. With |
@flip111 that's exactly it. |
Really? I don't think I've ever seen it anywhere, could you give some examples? |
Some examples:
There are many more examples, but I don't want to spend too much time on it. I don't see a valid argument against this other than "why not use |
This seems like something that:
|
I wanted this function a couple weeks ago. Of course I just used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be enough people who want this to overcome my general reluctance to add semi-unnecessary functions to this package. I want some documentation and testing tweaks for both versions, even though I only added line comments to one.
Looks fine to me, but it's up to @treeowl |
@treeowl could you take a look please? Is there anything i can do or something that needs to be done? |
@flip111 would you like to finish the work here? |
Sorry i didn't do this earlier, sometimes things seem like a mountain when it's actually not that hard. It went a bit out of focus, thanks for the reminder @meooow25 |
I guess now, sync with upstream master, rebase and adjust changelog? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just a few more comments and note the test build failure.
I guess now, sync with upstream master, rebase and adjust changelog?
Sure, you can do that if you like.
The test is broken. It's a small change so I'm just going to go ahead and fix it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I'll squash and merge this soon if there are no other concerns.
Thank you @meooow25 |
Thanks for wrapping this up @flip111! |
#866