For some reason the following fails to work
object NtExtTest {
implicit class NaturalTransformExt[M[_], N[_]](val self: NaturalTransformation[M,N]) extends AnyVal {
def test(b:Boolean) = b
}
}
when I call the method test on a natural transform. Intellij recognises it as an extension function, but the compile gives value test is not a member of cats.~> . The same happens when using the scalaz NaturalTransformation. Is there something I can do to help the compile recognise the extension?
Scala version is 2.11.8
An example which fails:
import NtExtTest._
class NtTest[B] extends NaturalTransformation[Either[B,?], Xor[B,?]] {
def apply[A](fa: Either[B, A]): Xor[B, A] = {
fa match {
case Left(l) => Xor.left(l)
case Right(r) => Xor.right(r)
}
}
}
val test = new NtTest[String]
test.test(false)
(above uses kind projector plugin, but equally fails with type lambdas, or single param higher kinded types)
Probably relates to SI-8286
I.e. it is not related to
NaturalTransformation. It does not work in simple case as well:If the goal to extend
NtTest, probablyNatTransExt1would be best choice if one would like to stay as generic as possible.NatTransExt2is ok, if extension really specific toNtTest.