-
Notifications
You must be signed in to change notification settings - Fork 101
Prepare release 0.2.11.0 #266
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Aside: I'm fine with the addition of
findWithDefault
for compatibility withcontainers
, but I'm wondering whether we really want to get rid oflookupDefault
, which is arguably the nicer name.Thoughts on this, @emilypi, @treeowl, @m-renaud?
The relevant commit is da5ac39.
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.
So, the reason I initially went with
findWithDefault
is because it had precedence in several packages(hoogle=findWithDefault), includingcontainers
which is a "core" package (for some definition of core) as well asnonempty-containers
,hashmap
,enummapset
, and others.lookupDefault
also exists in the ecosystem (hoogle=lookupDefault) but fewer, and none in a "core" package.I don't have a strong preference one way or the other, as long as there is consistency. imho if we decide to go with
lookupDefault
we should make sure its reflected in all the container-like packages.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.
As I've said elsewhere, I'd be ever so much happier ignoring or deprecating both of them and using a more "eliminator-style" function like
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
While I agree this is more generally applicable, I have a hunch this will just result in everyone defining differently named versions of (and likely with different argument orderings of)
lookupDefault a k m = lurkup a id k m
, which will just cause more fragmentation. The idea of "looking up a value from some container, and returning a default value if its missing" is pretty ubiquitous and imo thus deserves a function. If we were to deprecate find/lookupDefault would we then require all code to replace it with a call tolurkup
?Edit: ....or will lead to someone creating a
containers-missing
package which just wrapscontainers
and exportslookupDefault
and any other common operations that are removed fromcontainers
to have a more general API.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's definitely no need to deprecate these things. But it seems strange to me to focus on adding more of them when we haven't yet added the more general idea. Note that while you need to import
Data.Maybe
to getfromMaybe
andData.Either
to getfromLeft
andfromRight
,maybe
andeither
are right in thePrelude
. So isfoldr
. So this "eliminator style" is even more ubiquitous, and I'd say it's a high priority to get it in here andcontainers
. We just need an appropriate name!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.
I've thought about this some more (and regretted not making a proper issue).
findWithDefault
to achieve better consistency withcontainers
is OK.lookupDefault
is also OK.findWithDefault
norlurkup
because both can easily be derived fromlookup
. These days, I also find that explicit pattern matching helps with readability, so I'd generally recommend usinglookup
and pattern matching on the result.