-
Notifications
You must be signed in to change notification settings - Fork 90
NaN shouldn't compare EQ to itself #91
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
Conversation
I saw a bit of the conversation about this on IRC yesterday. Making this change makes Either fix is wrong for different reasons, but I'm not sure which is worse. |
Why is this the case? Is it something about relying on these laws to ensure that sorting is stable? (Anyhow, another thing that I haven't mentioned: due to the current implementation, NaN is EQ not only to itself, but to every other Number) |
Haha, wow, it's really broken now then. I don't know how best to proceed here. Maybe we should just say the behaviour of |
In Haskell, I think merging this PR will give us that same behaviour in PureScript (I haven't tested, but I think we do have the second part currently because of inlining). Can we add tests here for this? |
Oh, I missed the github notification of the last message
@hdgarrood Sure, but there are no Purescript tests in this repository I presume that, since this is a base library, we wouldn't use I guess I could change main :: AlmostEff
main = do
mainImpl show
otherTests
otherTests unit = if (assertSomething) then unit else (throw "errormsg")
assertSomething = compare (0.0/0.0) (0.0/0.0) /= EQ Or maybe could we add |
I don't think we should depend on any other libraries in our tests, even if we do find some way to avoid the circular dependency issue, as any other libraries will (rightly) assume that I think what you proposed with adding tests to test/Main.purs would work, or alternatively do the same as what the existing tests here do, namely, write the tests in JavaScript. |
Added the tests |
@@ -45,3 +45,8 @@ exports.mainImpl = function(showNumber) { | |||
}; | |||
}; | |||
|
|||
exports.throwErr = function(msg){ |
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.
Sorry to be a pain, but can we keep the style consistent with the rest of the file here please? I'm referring to having a space between function(arg)
and the opening curly brace, and using semicolons at the end of lines (even if they're not strictly necessary).
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.
done
Aside from my (very minor) comment, this all looks great to me, thank you! |
@paf31 any comments on this one before merging? |
@paf31 bump! I'll make the 2.0 release once this is merged. |
I'm fine with this change, although I'd rather not admit |
In a perfect world, I agree, but it's impractical to do so if we use JS's |
I'm not sure if this makes sense to be merged, but since the fix was trivial, here it is