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

[Question] Type signature for ap #298

Closed
shineli1984 opened this issue Jul 15, 2018 · 2 comments
Closed

[Question] Type signature for ap #298

shineli1984 opened this issue Jul 15, 2018 · 2 comments

Comments

@shineli1984
Copy link

shineli1984 commented Jul 15, 2018

I had a look at a few fantasy-* repos where ap method is derived as below

SomeApplicative.prototype.ap = function(a) { return this.chain(f => a.map(f)) }

In the current ap type signature ap :: Apply f => f a ~> f (a -> b) -> f b, my understanding is that f a refers to this in the above method.

So I'm wondering if the type signature for ap should be:

ap :: Apply f => f (a -> b) ~> f a -> f b

?

@Avaq
Copy link
Contributor

Avaq commented Jul 15, 2018

See also: #169, #181, #228, #242, and #283.

How ptotoype.ap is implemented is up to library authors. Most of the time, it will be as ap :: Apply f => f (a -> b) ~> f a -> f b, because it favours readability when fluent-method chaining.

Fantasy land doesn't specify prototype.ap. It specifies prototype['fantasy-land/ap'], and that one is the other way around.

It was changed for reasons of consistency when Fantasy Land 1.0 was released. The fantasy-* repos were never updated to adopt the new prefixed method specifications.

@shineli1984
Copy link
Author

Thanks for the explaination.

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