-
Notifications
You must be signed in to change notification settings - Fork 371
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
In Monad & Functor laws, what does "equals" mean? #4
Comments
Yes. This is tricky. |
Importing discussion with @Twisol about equality and the event loop. My understanding of what has been said:
My suggestion is to work out a notion of equality for promises that allows the laws to hold regardless of synchrony, and to order side effects with the usual concurrency control mechanisms. The notion of equality must not forbid such mechanisms from working - waiting on a mutex before delivering a value should be equivalent to delivering it immediately. The implication for Fantasy Land is simply that equality should be defined by the monad/functor/values in question, and that side effects remain up to the programmer to sort out. |
Just to clarify, you advocate pushing the issue of side-effects downstream to the individual monad implementations? |
Exactly. |
Okay. I don't really have a problem with that, but I would hate to see a monad implementation that didn't adequately address it somehow. |
I agree with the concern. In the case of promises + concurrency side effects the two are clearly intimately related so worth discussion in the docs for any implementation of promises. But I would expect most monad implementations to pass the buck downstream to users, especially data-oriented monads such as But I want to emphasize that this issue is a necessary discussion in all cases, even the very simple ones, because |
That's fair. I think we should have a section of the spec on things that must be addressed somehow downstream, even if we don't prescribe a particular approach. These things seem to come up because of the imperative domain, and they can't be naively ignored. |
This is one half JS joke and one half math joke.
But even so, I'm only half joking. Maybe it would be good to spell it out, since you probably mean a kind of extensional equality that Javascript is not powerful enough to express.
The text was updated successfully, but these errors were encountered: