-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 identity hash to alleycats #3944
Conversation
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.
Just saw this, nice addition and clean-up on my PR! I don't think anything is supposed to go in the .jvm
folder. The correct way to handle this is to change the build to a full cross with a proper jvm
folder. Is System.identityHash
not available on Scala.js and/or Native?
Also in your clean up efforts you removed ReferentialEqTests
, I'm surprised the test suite passed (must be chance?) since it actually doesn't satisfy all the Eq
laws.
|
||
import cats.Hash | ||
|
||
class SystemIdentityHash[A <: AnyRef] extends ReferentialEq[A] with Hash[A] { |
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.
Maybe just me, but perhaps make it a trait so that it can be mixed with other instances?
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 mind either way. I'll modify the change
alleycats-tests/shared/src/test/scala/alleycats/tests/ReferentialEqSuite.scala
Show resolved
Hide resolved
I checked and |
alleycats-tests/shared/src/test/scala/alleycats/tests/AlleycatsSuite.scala
Outdated
Show resolved
Hide resolved
34fdf93
to
c3e35de
Compare
c3e35de
to
3ebe12c
Compare
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.
Thanks for addressing all the PR comments, nice work! ✅ but please add a quick scaladoc to SystemIdentityHash
.
2b89e76
to
f54101c
Compare
The thing that I haven't implemented but could be potential optimisation is: merge both ReferentialEq and SystemIdentityHash into one alleycats definition since they are very closely related. |
I think it's fine to have them as separate traits, more modular :) As it was pointed out in the original PR #3925 (comment) using typeclasses isn't particularly performant anyway! |
This is a follow-up PR based on the discussion in #3925
To compliment ReferentialEq I've added SystemIdentityHash to JVM alleycats.