zio / zio-prelude

A lightweight, distinctly Scala take on functional abstractions, with tight ZIO integration
https://zio.dev/zio-prelude
Apache License 2.0
447 stars 115 forks source link

Rethink Equality for contravariant types (not only) because of Dotty #273

Open sideeffffect opened 3 years ago

sideeffffect commented 3 years ago

@adamgfraser https://github.com/zio/zio-prelude/pull/246#discussion_r487353697 https://github.com/lampepfl/dotty/issues/9778#issuecomment-691390362

I think that is right. Equality for contravariant types is tricky in general. If the input type A can be enumerated then you can say that two F[A] values are equal if they produce the same outputs for all inputs. If they can't be enumerated you could at least try to test a subset of the values. But either way you need a notion of equality for whatever you are converting the A values into, not the A values. So I think this is a case where we too quickly took logic from the covariant case to the contravariant one. Thanks for the good thought!

adamgfraser commented 3 years ago

I will work on this.