ScalazのEqualとScalaTest
My favorite #scala import is: import org.scalautils.TypeCheckedTripleEquals._
2013-11-13 07:34:57@tobym @bvenners I think you meant to say: import scalaz._,Scalaz._ :)
2013-11-13 09:15:16@tobym @bvenners import scalaz._ That’s like, a zillion fewer characters. Just sayin’. :-)
2013-11-13 13:30:23@djspiewak @tobym Typing characters builds character! Plus you can create an import object, like OurScalaUtils on: http://t.co/epbizhlZiq
2013-11-13 18:13:50@djspiewak @tobym Also, is it true you need define Equal[T] instance for any new type T you create to use Scalaz's === with T?
2013-11-13 18:18:32@bvenners @djspiewak @tobym yes, but I believe you can derive them now for many types http://t.co/C0rH5OI1eO
2013-11-13 18:35:30@jteigen @djspiewak @tobym Ah. But for case class Person(name: String) you'd still have to say implicit val eqp = TypeClass[Equal, Person]?
2013-11-13 19:08:48@bvenners @djspiewak @tobym haven't tried this myself, but it looks like import Equal.auto._ should be enough
2013-11-13 19:11:31@jteigen @djspiewak @tobym Interesting. What version of scalaz is that? It doesn't seem to work in 7.0.4, unless I'm missing an import.
2013-11-14 00:33:43@bvenners @djspiewak @tobym don't know. Check with @larsr_h he is the magician behind this stuff
2013-11-14 02:57:52@bvenners @djspiewak @tobym Yes, that's the point. You don't want equality to be available on arbitrary function types.
2013-11-14 03:37:11@bvenners @jteigen @djspiewak @tobym It requires shapeless-contrib. Will post an example when I'm back home.
2013-11-14 03:37:38@larsr_h Thanks, I'd like to try it out. Does auto cause the type class instance to be redefined anew inline each time it is needed?
2013-11-14 04:20:56@larsr_h @djspiewak @tobym Equality is already available on arbitrary function types, because given functions f and g, you can say f == g.
2013-11-14 04:30:51@larsr_h @djspiewak @tobym f == g is not very useful, so people don't do it much. What specific problems can you give that arise from it?
2013-11-14 04:32:37@bvenners @larsr_h @tobym map function on Set arises directly from bad equality.
2013-11-14 04:36:57@djspiewak @larsr_h @tobym Daniel, can you give a specific example? I'm not sure what you are referring to.
2013-11-14 04:49:06@bvenners @djspiewak @larsr_h @tobym it's reference equality and not extensional equality (where domains and codomains are checked instead)
2013-11-14 04:54:02@bvenners Right. We (= scalaz) don't want that, and we especially don't want a custom `===` to provide it. @djspiewak
2013-11-14 04:57:01@bvenners Here's a minimal example. The wildcard import of `shapeless.contrib.scalaz` gives you "automatic" mode. http://t.co/qw6YKqzZGO
2013-11-14 05:01:37@bvenners Yes, it calls the macro every time an implicit of that type is summoned. In that sense, it behaves just like other implicits.
2013-11-14 05:02:10@bvenners ... and here's an example for "manual" mode. http://t.co/JmPwuXPLwJ
2013-11-14 05:07:26@larsr_h Thanks. Unfortunately can't see it from behind this firewall. Will try it tonight from the hotel. Looks pretty interesting.
2013-11-14 05:07:42@puffnfresh @djspiewak @larsr_h @tobym I see, so how (and how often) do you define Equal instances for extensionally equal functions?
2013-11-14 05:18:30