Created
November 7, 2012 11:16
-
-
Save larsrh/4030916 to your computer and use it in GitHub Desktop.
Compiler failure in 2.10.x
This file contains 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
sealed trait GenericList[+M[_]] { | |
final def :^:[A, N[X] >: M[X]](elem: N[A]): GenericCons[N, A, this.type] = | |
GenericCons[N, A, this.type](elem, this) | |
} | |
case class GenericCons[M[_], H, +T <: GenericList[M]]( | |
head: M[H], | |
tail: T | |
) extends GenericList[M] { | |
} | |
case class GenericNil[M[_]]() extends GenericList[M] { | |
} | |
object TypelevelUsage extends App { | |
val klist = None :^: Option(3) :^: Some("foo") :^: GenericNil[Nothing] | |
// fails | |
klist match { | |
case GenericCons(optionInt1, GenericCons(optionInt2, GenericCons(someString, _))) => | |
} | |
// fails, but with another message | |
/*klist match { | |
case GenericCons(optionInt1, GenericCons(optionInt2, _)) => | |
}*/ | |
// succeeds | |
klist match { | |
case GenericCons(optionInt1, _) => | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment