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 fantasy-land canonical type references? #656

Closed
amsross opened this issue Oct 24, 2018 · 2 comments · Fixed by #658
Closed

Add fantasy-land canonical type references? #656

amsross opened this issue Oct 24, 2018 · 2 comments · Fixed by #658

Comments

@amsross
Copy link
Contributor

amsross commented Oct 24, 2018

Canonical references to the described types are provided via https://github.com/fantasyland/fantasy-land/blob/master/index.js.

These can probably be added with something like this:

addMethod('map', ...);
Stream.prototype[fl/map] = Stream.prototype.map;
_[fl/map] = _.map;

The benefit of doing this would be to provide interoperability between other fantasy-land-implementing libraries (ramda, fluture, zoom, crocks, etc).

It looks like the existing types covered are:

Also worth nothing:

  • fantasy-land/reduce conflicts with he current 2.x version _.reduce, but the ^3.0.0-beta.5 matches. I'm not sure how to handle this.
  • fantasy-land/traverse could be fulfilled by mixing some high-level functions if fantasy-land/reduce were fulfilled.
  • fantasy-land/alt could possibly be interpreted to be fulfilled by _.otherwise
  • fantasy-land/empty could be fulfilled simply by () => h.of(h.nil)

Would this be desirable?

@vqvu
Copy link
Collaborator

vqvu commented Oct 25, 2018

Yes, we should do this.

fantasy-land/reduce conflicts with he current 2.x version _.reduce, but the ^3.0.0-beta.5 matches. I'm not sure how to handle this.

reduce in Highland doesn't match reduce in fantasy land, even though it's very close. The type signature for reduce in Highland is

reduce :: Highland a ~> ((b, a) -> b, b) -> Highland b

Essentially, we can do the reduce operation, but we can't unwrap the value, because it's produced asynchronously.

fantasy-land/empty could be fulfilled simply by () => h.of(h.nil)

I'd prefer using h([]) instead.

I think we can also have

  • fantasy-land/zero - Same as empty.
  • fantasy-land/chain - Same as flatMap.

@amsross
Copy link
Contributor Author

amsross commented Oct 25, 2018

You're right about reduce, I overlooked the final signature somehow.

empty makes sense to me. I incorrectly wrote the one I mentioned above here as well as in #643 (#643 (comment)).

I'll look at opening a PR sometime soon.

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 a pull request may close this issue.

2 participants