Last active
August 29, 2015 13:57
-
-
Save davidpeklak/9421853 to your computer and use it in GitHub Desktop.
OrType
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 Type { | |
class |:|[A, B] | |
implicit def orTypeA[A, B](implicit a: A): |:|[A, B] = new |:|[A, B] | |
implicit def orTypeB[A, B](implicit b: B): |:|[A, B] = new |:|[A, B] | |
type \:/[T, U] = {type λ[X] = (X <:< T) |:| (X <:< U)} | |
object Test { | |
case class One(x: Int) | |
case class Two(x: Int) | |
case class Three(x: Int) | |
case class Wrap[A: (One \:/ Two)#λ](a: A) | |
val w1 = Wrap(One(1)) | |
val w2 = Wrap(Two(2)) | |
// does not compile | |
val w3 = Wrap(Three(3)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment