Created
September 30, 2016 11:13
-
-
Save hardvain/f9e26c8b260265bb8e86a1e40855b396 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
val l = 1 :: "hello" :: true :: HNil | |
// l: shapeless.::[Int,shapeless.::[String,shapeless.::[Boolean,shapeless.HNil]]] = 1 :: hello :: true :: HNil | |
l.head | |
// res7: Int = 1 | |
l.tail | |
// res8: shapeless.::[String,shapeless.::[Boolean,shapeless.HNil]] = hello :: true :: HNil | |
l(1) | |
// res9: String = hello | |
l(2) | |
// res10: Boolean = true | |
l.length // Return's a type representation of a natural number | |
// res11: shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless._0]]] = Succ() | |
l.length.toInt // Type class ToInt[l.length] is implicitly computed at compile time. | |
// res12: Int = 3 | |
l.drop(3) | |
// res13: shapeless.HNil = HNil | |
l.drop(4) | |
// <console>:17: error: Implicit not found: shapeless.Ops.Drop[shapeless.::[Int,shapeless.::[String,shapeless.::[Boolean,shapeless.HNil]]], | |
// shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless._0]]]]]. | |
// You requested to drop an element at the position shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless._0]]]], | |
// but the HList shapeless.::[Int,shapeless.::[String,shapeless.::[Boolean,shapeless.HNil]]] is too short. | |
// l.drop(4) | |
// ^ | |
l.copy(head = true) | |
// res14: shapeless.::[Boolean,shapeless.::[String,shapeless.::[Double,shapeless.HNil]]] = true :: a :: 3.14 :: HNil | |
l.runtimeList | |
// res15: List[Any] = List(1, a, 3.14) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment