Equality for signed zeros
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 5.5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
In a comment on travisbrown/circe#187 @non argues that this behavior is wrong:
scala> import cats.std.double._, cats.syntax.eq._
import cats.std.double._
import cats.syntax.eq._
scala> 0.0 === -0.0
res0: Boolean = false
And that Cats (and Algebra) should follow Scalaz and Java (but not java.lang.Double.compare) in considering them the same.
As @copumpkin points out here, making them equal means we'd lose substitutability.
I don't have a strong opinion either way (for the Double instances, at least—I do for circe's JSON number representation).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Double equality instance exposed by cats.std.double._ and the syntax from cats.syntax.eq._, then read the linked discussion about Scalaz, Java, and substitutability. Resolve the intended semantics for signed zeros and verify the chosen behavior with focused equality tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100