Created
April 11, 2014 16:11
-
-
Save xeno-by/10480949 to your computer and use it in GitHub Desktop.
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
18:09 ~/Projects/210x/sandbox (2.10.x)$ scala | |
Welcome to Scala version 2.10.5-20140326-123924-c74e1325ff (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_40). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> val tpe1 = typeOf[Some[Int]] | |
tpe1: reflect.runtime.universe.Type = scala.Some[Int] | |
scala> val tpe2a = typeOf[Option[_]] | |
tpe2a: reflect.runtime.universe.Type = scala.Option[_] | |
scala> tpe1 <:< tpe2a | |
res0: Boolean = true | |
scala> val tpe2b = typeOf[Option[_]].typeConstructor | |
tpe2b: reflect.runtime.universe.Type = scala.Option | |
scala> tpe1 <:< tpe2b | |
res1: Boolean = false | |
scala> tpe2b.normalize | |
res2: reflect.runtime.universe.Type = [+A <: <?>]scala.Option[A] | |
scala> val PolyType(tparams, raw) = res2 | |
tparams: List[reflect.runtime.universe.Symbol] = List(type A) | |
raw: reflect.runtime.universe.Type = scala.Option[A] | |
scala> val tpe2c = existentialAbstraction(tparams, raw) | |
tpe2c: reflect.runtime.universe.Type = scala.Option[Any] | |
scala> tpe1 <:< tpe2c | |
res3: Boolean = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment