Add fantasy-land canonical type references?
amsross opened this issue · comments
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:
fantasy-land/concat
fantasy-land/filter
fantasy-land/map
fantasy-land/of
fantasy-land/chain
fantasy-land/ap
(provided by #643)
Also worth nothing:
fantasy-land/reduce
conflicts with he current2.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 iffantasy-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?
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 asempty
.fantasy-land/chain
- Same asflatMap
.
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.