Last active
March 28, 2017 00:22
-
-
Save sir-wabbit/56028633ef73faeec0f5d3e7e3a14746 to your computer and use it in GitHub Desktop.
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
| def coerce[U, V](u: U): V = { | |
| trait F { type R } | |
| trait X extends F { type R = U } | |
| trait Y extends F { type R = V } | |
| final case class T[A <: F](value: A#R) | |
| val a: T[X with Y] = new T[Y with X](u) | |
| a.value | |
| } | |
| println(coerce[String, Int]("hello")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment