-
Notifications
You must be signed in to change notification settings - Fork 147
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
Fantasy Land compatibility? #114
Conversation
On 4, the standard implementation of Thing.prototype.ap = function(xs) {
return this.chain(function(f) {
return xs.map(f);
});
}; Of course, we can't do this directly, as |
On 5, Fantasy-check can verify Fantasy Land laws, and is NodeUnit compatible. |
I'm fairly keen to see this happen, would enable all kinds of cool interop with e.g. sweet.js macros for do-notation. Property-based testing would also give us a bit more confidence in our tests. |
+1 on this; I had never heard of Fantasy Land before, but I've certainly picked up on (and appreciated) the similarities between HL streams and monoids/monads. It would be really cool to formalize it, and having a nodeunit-compatible quickcheck seems too convenient. |
Found the branch I was working on: https://github.com/quarterto/highland/compare/fantasy |
Status on this? 3.0.0 seems like a good place to get this out. |
at this stage we should not add new features to the 3.0.0 branch. We first need to get caolan's approval on the engine rewrite. The only features that can should be added to 3.0.0 right now are the ones that accepted and commited on 2.x. otherwise I fear that 3.0.0 will never see the light of day ;-) 2.x and 3.x have already started forking. Maybe this issue can be tagged 3.0.0 and we will make sure it gets done once everybody is ok on the engine rewrite. |
Current status: I got stuck trying to get Fantasy-check working, and I'm not sure if we can get Applicative to work. I'd be happy to wait for a 3.1 release. |
Good call :) I checked in on the 3.0.0 issue instead and made that label. |
@quarterto couldn't we just implement ap = function (xs) {
var self = this;
return xs.collect().flatMap(function (array) {
return self.chain(function (f) {
return _(array).map(f);
});
});
} but with smarter handling for the infinite |
Quick update on this, for fantasy-check to work there needs to be a synchronous way of getting stream contents, any ideas @vqvu? |
Also, since this is planned for post-3.0 should I rebase it on the 3.0.0 branch? |
@quarterto this gist may help you regarding a 'synchronous way of getting stream contents' - https://gist.github.com/vqvu/a7838e456783432a2e45 I suggest you wait a bit before rebasing. We don't know yet how 3.0.0 is going to be rebased/merged over the next 2.x |
@quarterto I'm not too familiar with fantasy-check, but can't you just use an ArrayStream when testing? That would make everything synchronous. |
This reverts commit 52d8a44.
Here's the work in progress, I'll flesh out the tests, remove the non-fantasy-check ones I added and implement |
Can this be closed now because of the recent PRs @amsross has done? |
Cool, I'll close then. |
Fantasy Land is a specification for algebraic Javascript structures. Highland streams almost implement Monoid and Monad. What we'd need to change to be fully compatible:
flatMap
tochain
_.of
as a shortcut forλ x → _([x])
_.empty
as a shortcut forλ → _([])
ap
, to apply each of a stream of functions to each of a stream of values.What are people's opinions on this?