Scala: "Parameter type in structural refinement may not refer to an abstract type defined outside th
Posted
by raichoo
on Stack Overflow
See other posts from Stack Overflow
or by raichoo
Published on 2010-04-21T19:04:30Z
Indexed on
2010/04/21
19:13 UTC
Read the original article
Hit count: 238
Hi, I'm having a problem with scala generics. While the first function I defined here seems to be perfectly ok, the compiler complains about the second definition with:
error: Parameter type in structural refinement may not refer to an abstract type defined outside that refinement
def >>[B](a: C[B])(implicit m: Monad[C]): C[B] = {
^
What am I doing wrong here?
trait Lifter[C[_]] {
implicit def liftToMonad[A](c: C[A]) = new {
def >>=[B](f: A => C[B])(implicit m: Monad[C]): C[B] = {
m >>= (c, f)
}
def >>[B](a: C[B])(implicit m: Monad[C]): C[B] = {
m >> a
}
}
}
IMPORTANT: This is NOT a question about Monads, it's a question about scala polymorphism in general.
Regards, raichoo
© Stack Overflow or respective owner