On 3/7/17 1:16 PM, Sean McLaughlin wrote:
On Thursday, March 24, 2016 at 10:52:33 AM UTC-7, Shing Hing Man wrote:
Hi,
I am using ScalaZ 7.1.3.
I am trying to write a simple test case for Scalaz === with ScalaTest.
import org.scalactic.TripleEquals.{convertToEqualizer => _}
import scalaz.Scalaz._
import scalaz._
import org.scalatest.{Matchers, WordSpec}
class TypeClasses2Test extends WordSpec with Matchers{
"Strings" should {
"be equals" in{
"Hello" === "olleH".reverse should be (true)
}
}
}
Error:(19, 8) type mismatch;
found : String("Hello")
required: ?{def ===(x$1: ? >: String): ?}
Note that implicit conversions are not applicable because they are
ambiguous:
both method ToEqualOps in trait ToEqualOps of type [F](v:
F)(implicit F0: scalaz.Equal[F])scalaz.syntax.EqualOps[F]
and method convertToEqualizer in trait TripleEquals of type
[T](left: T)TypeClasses2Test.this.Equalizer[T]
are possible conversion functions from String("Hello") to ?{def
===(x$1: ? >: String): ?}
"Hello" === "olleH".reverse should be (true)
^
There is another implicit conversion for === from
org.scalactic.TripleEquals.convertToEqualizer, which I tried to
exclude.
But
import org.scalactic.TripleEquals.{convertToEqualizer => _}
does not seem to work.
It doesn't work because the actual conversion being applied is
this.convertToEqualizer, not the globally-accessible one. Try this
goofiness instead, in your class body:
override def convertToEqualizer[T](left: T): Equalizer[T] =
super.convertToEqualizer(left)
Nonsense like this? Just another day living in the cake.
--
Stephen Compall
--
You received this message because you are subscribed to the Google Groups
"scalaz" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/scalaz.
For more options, visit https://groups.google.com/d/optout.