Created
June 20, 2012 20:54
-
-
Save arschles/2962156 to your computer and use it in GitHub Desktop.
How to use === in scalaz
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
//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