Given the following class:
scala> class Foo(x: Int) { def getX = x }
defined class Foo
I created an implicit Equal[Foo]
to be able to use ===
.
scala> implicit val FooEq: Equal[Foo] = Equal.equal(_.getX == _.getX)
FooEq: scalaz.Equal[Foo] = scalaz.Equal$$anon$7@6a246ad
It works.
scala> new Foo(10) === new Foo(10)
res2: Boolean = true
scala> new Foo(10) === new Foo(4545)
res3: Boolean = false
But, I'm confused by how the the FooEq
gets created.
What's going on in Equal.equal(_.getX == _.getX)
? I'm not sure how that statement returns an Equal[Foo]
.