-
-
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
Unusual EqLaws definition #4514
Comments
It's a weird name. It doesn't seem to be anything about antisymmetry. It's more that any pure function that maps A to itself preserves Eq. Why would you expect that? I guess it is some argument about if two A values are eqv than any transformation of them into other As should preserve that equality. It's weird if you think a1 == a2 but then f(a1) != f(a2) by the same Eq. So, I think the law is sensible but where I comes from I don't recall. |
Thank you for your reply.
No. It's not obvious property and too strong restriction. For example, let's think about |
@hiroshi-cl I see what you mean. My math is a bit rusty, but I think you want an Equivalence relation: https://en.wikipedia.org/wiki/Equivalence_relation but what Eq is really about is an Equality: Eq is about "...asserting that the quantities have the same value." this text in Equivalence Relation describes:
I would say you want a new type class, like: trait Equivalence[A] {
def equiv(a: A, b: A): Boolean
} The problem with equivalence is you probably don't want any of them to be implicit. For the whole type class pattern to work you really want there to be one privileged instance for a given type. With an Equivalence relation, that's not really the case. How does that sound? |
I'm not convinced what you mean but introducing a new type class sounds a good idea. |
I found that EqLaws has an unusual definition:
cats/kernel-laws/shared/src/main/scala/cats/kernel/laws/EqLaws.scala
Lines 36 to 37 in d40b884
Equivalency that I know doesn't have antisymmetry law, that is typically included in order.
I wonder where is the source of this kind of equivalency definition.
The text was updated successfully, but these errors were encountered: