Add more examples for anonymous argument error#369
Open
milesfrain wants to merge 1 commit intopurescript:masterfrom
Open
Add more examples for anonymous argument error#369milesfrain wants to merge 1 commit intopurescript:masterfrom
milesfrain wants to merge 1 commit intopurescript:masterfrom
Conversation
milesfrain
commented
Jan 2, 2021
| ```purescript | ||
| module Example where | ||
|
|
||
| add = (_ + _) |
Contributor
Author
There was a problem hiding this comment.
This add example is problematic because:
- Not ideal to overwrite Prelude functions, while also using the corresponding infix operator.
- Even with a different name, it's trivially replaced with
addor(+). - Unclear whether the intention in the broken case is to reuse the same anonymous arg, or consider these separate args. And if separate args, is the expectation that they are populated in order?
milesfrain
commented
Jan 2, 2021
| add = (_ + _) | ||
| sub3 = _ - 3 | ||
|
|
||
| mapArray = map _ [1, 2, 3] |
Contributor
Author
There was a problem hiding this comment.
I think this second-order example adds another layer of potential confusion for beginners. I changed all these map examples to use first-order arguments for _.
Contributor
|
This PR hasn't been merged because I'm not sure if the new content is actually correct. There's some release notes in PureScript that clarify this further. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Also modified the original examples to make them closer to what you'd find in real-world code.
I think this would be clearer if we split this up into multiple Example/Cause/Fix sections. Don't know if that deviation from the common format is allowed.