-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
in ap.js #2414
Comments
When we try to match the FantasyLand specifications, it is more consistent with Ramda that the translation of FantasyLand methods put the receiving object as the last parameter. This is the FantasyLand signature: ap :: Apply f => f a ~> f (a -> b) -> f b (where the squiggly array ( This translates to a Ramda pure function as ap :: Apply f => f (a -> b) -> f a -> f b So I think this is right. Anyone disagree? |
function Container(value) {
this.__value = value;
}
Container.of = function (value) {
return new Container(value);
}
Container.prototype.map = function (fn) {
return Container.of(fn(this.__value));
} A. Implements 'fantasy-land/ap' Container.prototype['fantasy-land/ap'] = function (otherContainer) {
return otherContainer.map(this.__value);
} usage: ap(Container.of(3), map(add, Container.of(2))); // Container(5) B. Implements 'ap' Container.prototype['ap'] = function (otherContainer) {
return otherContainer.map(this.__value);
} usage: ap(map(add, Container.of(2)), Container.of(3)); // Container(5) both A and B are ap functor, and actually they are the same ap functor, but usage are different(params order). |
Ok, I see. The delegations to |
Implements 'fantasy-land/ap' function Container(value) {
this.__value = value;
}
Container.of = function (value) {
return new Container(value);
}
Container.prototype.map = function (fn) {
return Container.of(fn(this.__value));
}
Container.prototype['fantasy-land/ap'] = function (applyF) {
return this.map(applyF.__value);
} usage: ap(map(add, Container.of(2)), Container.of(3)) FantasyLand one is correct, and the delegation to ap is incorrect |
This was done intentionally, see #1900, #1900 (comment) |
so i should implement ap functor as below? Implements fantasy-land/ap Container.prototype['fantasy-land/ap'] = function (applyF) {
return this.map(applyF.__value);
} implements ap Container.prototype['ap'] = function (otherContainer) {
return otherContainer.map(this.__value);
} |
Even with @kedashoe's prompting, I still cannot remember why we didn't switch the order of This from @davidchambers:
Doesn't seem to add anything we should care about. Even if we could keep |
From my perspective we only dispatch to |
I'm sure you know that my perspective on dispatching is a bit different. 😈. But that's right, we kept that for backward compatibility not with our internal code but an older FL version. Hmmm. |
@CrossEye: if I understand this correctly I can confirm that this comment from @imchenglibin is still correct as of today:
Our next |
implement is like this:
not this:
why?
The text was updated successfully, but these errors were encountered: