-
Notifications
You must be signed in to change notification settings - Fork 14
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
Should _ fail with ArityError, or return a curried function? #7
Comments
What do you think of adding a "curried" submodule to fn.py? Example:
And when importing from the normal module, it produces an
|
that's definitely a good idea. Doesn't break existing code but gives the curry-all-the-things functional option. I was also thinking _ could be expanded to more operators. In particular I was thinking |
Making it easier to create lambda functions is (IMO) always a good thing. If we can incorporate the functionality of the whatever object into fn.py's _ object without backward-incompatible changes, then I think we should go for it. I will set the milestones for these features to be v1.1.0, to give us enough time to plan and build out this feature. |
Just redoing the milestones, and I noticed that I cannot set a milestone on this yet. If adding the "whatever" functionality to fn.py's _ will incorporate breaking changes, then this feature should be pushed to v1.0.0. But, if we manage to build out this new functionality without breaking changes, we can push this through in a new minor version (e.g. 0.5.0). |
Personally I am in favour of having the currying functionality and bumping the the version number. |
There are many possible flavours of underscore, with curry being just one of them. |
Improperly handling arity can be a hard to track down source of error, especially when composing functions, but I would want
(_ + _)(2)
to return a function that looked like"(x1) => (2 + x1)"
such that(_ + _)(2, 3)
and(_ + _)(2)(3)
would be equivalent and both result in5
.I can understand the intent of the TypeError and it could actually be the best approach to ease problems dealing with composition and with standard python functions, e.g.
would be problematic. However, it might be worth considering the curried behavior.
The text was updated successfully, but these errors were encountered: