-
-
Notifications
You must be signed in to change notification settings - Fork 84
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 Future.bichain #411
Add Future.bichain #411
Conversation
Codecov Report
@@ Coverage Diff @@
## master #411 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 45 46 +1
Lines 1957 1976 +19
=====================================
+ Hits 1957 1976 +19
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far. Things missing:
- Documentation
- TS Types
- associativity and identity for bichain
- all algebraic properties for the left branch of bichain
I don't know to which algebraic properties for the left branch of bichain you're referring to. I was also thinking of adding a |
test/prop/0.algebra.js
Outdated
property('bichain left identity', _x, _fm, function (x, f){ | ||
return eq(bichain(f)(reject)(reject(x)))(f(x)); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the wrong interpretation of "left identity". I don't think it means "identity on the left branch", but rather it exists because for Monad, you can't test identity in a single equation. This also explains your confusion:
I don't know to which algebraic properties for the left branch of bichain you're referring to.
Once you have changed left identity to apply to the right branch, you need separate tests for testing left and right identity on the left branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially what we're testing is that chain (resolve)
is the identity function for m
. So what you should be testing is that bichain (reject) (resolve)
is the identity function for m
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the chain
equations, this property is verified in two steps:
left | chain (f) (resolve (x)) = f (x)
right | chain (resolve) (m) = m
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for bichain it should probably look like:
left | bichain (f) (g) (reject (x)) = f (x)
left | bichain (f) (g) (resolve (x)) = g (x)
right | bichain (reject) (resolve) (m) = m
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand now the difference between right and left identity. I always thought it was related to the branches. In any case, from your comments I have changed the code and hopefully it is right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the naming of the assertions either. Maybe the idea was something like: "identity as asserted from the left side" and "identity as asserted from the right side". Maybe we can get @puffnfresh to recall how he got to the naming, and whether our interpretation of it is right.
I think of the two assertions as:
- "given that
chain (f) (resolve (x))
is the equivalent off (x)
"; (left identity) - "
chain (resolve) (m)
should be the equivalent ofm
". (right identity)
But I might be wrong. The code looks good to me now, but let's wait a bit and see if Brian will respond :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we merge it. It's the best we could do ;)
We can always fix it later if we become wiser.
Close #332