Skip to content
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 more examples for anonymous argument error #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

milesfrain
Copy link
Contributor

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.

@@ -5,31 +5,54 @@
```purescript
module Example where

add = (_ + _)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 add or (+).
  • 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?


mapArray = map _ [1, 2, 3]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _.

@JordanMartinez
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants