Last active
July 13, 2017 13:11
-
-
Save atamborrino/65cdb8638646dde6017fd6e32a7f550a to your computer and use it in GitHub Desktop.
Simple type safe equality on arbitrary case class with Cats + Kittens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.derived._, eq._, legacy._ | |
import cats.implicits._ | |
case class Foo(a: String, b: Int) | |
case class Bar(c: Boolean) | |
Foo("a", 0) === Foo("b", 0) // compile | |
Foo("a", 0) === Bar(true) // does not compile | |
Foo("a", 0) == Bar(true) // compile with warning | |
List("a") === List(1) // does not compile | |
List("a") == List(1) // compile without warning |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment