Created
January 22, 2016 06:32
-
-
Save xevix/d5afb6c1f336a9122b56 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
import shapeless.syntax.std.tuple._ | |
import shapeless._, syntax.singleton._ | |
object ShapelessMain { | |
def main(args: Array[String]): Unit = { | |
val l = 23 :: "foo" :: true :: HNil | |
l(1) | |
val t = (23, "foo", true) | |
t(1) | |
23.narrow | |
"foo".narrow | |
val (wTrue, wFalse) = (Witness(true), Witness(false)) | |
type True = wTrue.T | |
type False = wFalse.T | |
trait Select[B] { | |
type Out | |
} | |
implicit val selInt = new Select[True] { | |
type Out = Int | |
} | |
implicit val selString = new Select[False] { | |
type Out = String | |
} | |
def select[T](b: WitnessWith[Select])(t: b.Out) = t | |
select(true)(23) | |
// select(true)("foo") | |
// select(false)(23) | |
select(false)("foo") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment