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

with has undocumented behaviour #95

Closed
ajb-in opened this issue Jul 1, 2016 · 5 comments
Closed

with has undocumented behaviour #95

ajb-in opened this issue Jul 1, 2016 · 5 comments

Comments

@ajb-in
Copy link
Contributor

ajb-in commented Jul 1, 2016

This will not work as documented:

$f = static function ($x) { return $x + 1; };
with($f, partial_any('map', [1, 2, 3], …));
lstrojny added a commit that referenced this issue Jul 1, 2016
@lstrojny
Copy link
Owner

lstrojny commented Jul 1, 2016

@ajb-in thank you, good point. Have a look at the commit, what do you think?

@lstrojny
Copy link
Owner

lstrojny commented Jul 1, 2016

Alternative would be to deprecate with() entirely and introduce with_value() and with_func() or something.

@ajb-in
Copy link
Contributor Author

ajb-in commented Jul 1, 2016

with should behave like with_value, period. If the value is callable, calling it should be the job of with's second argument.
Instead of with_func($f, $g) you could have with($f, partial_any(compose($g, …))).
Of course that breaks BC, but it could be a thing for the next major. No strong opinion on how to handle the transition.

@ajb-in
Copy link
Contributor Author

ajb-in commented Jul 1, 2016

Of course I'm an idiot; 496f677 does just that. LGTM.

lstrojny added a commit that referenced this issue Jul 1, 2016
@lstrojny
Copy link
Owner

lstrojny commented Jul 1, 2016

Fixed in 1.2.1

@lstrojny lstrojny closed this as completed Jul 1, 2016
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

No branches or pull requests

2 participants