Skip to content

Instantly share code, notes, and snippets.

@atamborrino
Last active July 13, 2017 13:11
Show Gist options
  • Save atamborrino/65cdb8638646dde6017fd6e32a7f550a to your computer and use it in GitHub Desktop.
Save atamborrino/65cdb8638646dde6017fd6e32a7f550a to your computer and use it in GitHub Desktop.
Simple type safe equality on arbitrary case class with Cats + Kittens
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