Created
February 22, 2010 08:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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