Skip to content

Instantly share code, notes, and snippets.

@retronym
Created February 22, 2010 08:47
Show Gist options
  • Select an option

  • Save retronym/310936 to your computer and use it in GitHub Desktop.

Select an option

Save retronym/310936 to your computer and use it in GitHub Desktop.
A limitation of Scala 2.8's type constructor inference that could be solved by Higher Order Unification
object test {
trait Bar[M[_]]
def baz[M[_] : Bar, A](m: M[A]) = 0
implicit object ListBar extends Bar[List]
baz(List(1))
type EitherIntX[X] = Either[Int, X]
implicit object EitherIntXBar extends Bar[EitherIntX]
val e: Either[Int, String] = Left(1)
//baz(e)
//<console>:19: error: type mismatch;
// found : Either[Int,String]
// required: ?M[ ?A ]
//Note that implicit conversions are not applicable because they are ambiguous:
// both method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A]
// and method any2Ensuring in object Predef of type [A](x: A)Ensuring[A]
// are possible conversion functions from Either[Int,String] to ?M[ ?A ]
// baz(e)
// ^
baz[EitherIntX, String](e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment