Skip to content

Instantly share code, notes, and snippets.

@arschles
Created June 20, 2012 20:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arschles/2962156 to your computer and use it in GitHub Desktop.
Save arschles/2962156 to your computer and use it in GitHub Desktop.
How to use === in scalaz
//declare the data structure and the Equal instance
import scalaz._
import Scalaz._
case class MyThing(thing1: String, thing2: String)
object MyThing {
implicit def MyThingEqual = new Equal[MyThing] {
override def equal(t1: MyThing, t2: MyThing) = (t1.thing1 === t2.thing1) && (t1.thing2 === t2.thing2)
}
}
//use it
import scalaz._
import Scalaz._
import MyThing._
val t1 = MyThing("abc", "def")
val t2 = MyThing("abc", "def")
t1 === t2 //should return true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment