I got hit by typelevel/cats#3762 when doing some work on ContT
and I realized that I’m a bit confused by the anti-symmetry law
def antiSymmetryEq(x: A, y: A, f: A => A): IsEq[Boolean] =
(!E.eqv(x, y) || E.eqv(f(x), f(y))) <-> true
It seems to me that it need not hold in general. I commented in the ticket but if anyone can un-confuse me, I would appreciate it! :joy:
f
is well-defined (x == y => f x == f y
) wrt Eq
? And in fact the test fails precisely because the functions created by the Cogen
instance are not well-defined - they take FiniteDuration
s that are equivalent (eg 51 days and 1224 hours) and map them to different values by pattern-matching on the time unit. Which is a perfectly reasonable scala function but not well-defined wrt Eq
Cogen
instance you can define for FiniteDuration
. But there is some history here that I didn’t quite get to the bottom of - the instance was removed in typelevel/cats#3470 and then that was reverted but I didn’t have time to dive into why
[warn] In the last 8 seconds, 7.465 (95.3%) were spent in GC. [Heap: 0.97GB free of 4.44GB, max 4.44GB] Consider increasing the JVM heap using `-Xmx` or try a different collector, e.g. `-XX:+UseG1GC`, for better performance.
[warn] In the last 6 seconds, 5.089 (95.0%) were spent in GC. [Heap: 0.93GB free of 4.44GB, max 4.44GB] Consider increasing the JVM heap using `-Xmx` or try a different collector, e.g. `-XX:+UseG1GC`, for better performance.
[warn] In the last 7 seconds, 6.254 (90.0%) were spent in GC. [Heap: 0.93GB free of 4.44GB, max 4.44GB] Consider increasing the JVM heap using `-Xmx` or try a different collector, e.g. `-XX:+UseG1GC`, for better performance.
traverse_
vs foreach
question is now decided on favour of the former.compose
to Representable
. If anyone wants to look at it, that would be much appreciated! :) And speaking of Representable
instances, another obvious one would be for Product (https://hackage.haskell.org/package/base-4.10.1.0/docs/Data-Functor-Product.html#t:Product) I don’t think this type exists in Cats. Would there be interest in me adding it?
Product
does exist as Tuple2K
so I added a representable instance for it as well - typelevel/cats#3832