Created
June 9, 2014 21:26
-
-
Save milessabin/6da04d3ef340171ca2ca to your computer and use it in GitHub Desktop.
Type safe record selection syntax for shapeless records.
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
scala> import shapeless._, record._, syntax.singleton._ | |
import shapeless._ | |
import record._ | |
import syntax.singleton._ | |
scala> val mary = ('name ->> "Mary" :: 'age ->> 23 :: HNil).record | |
mary: shapeless.syntax.DynamicRecordOps[shapeless.::[String with shapeless.record.KeyTag[Symbol with shapeless.tag.Tagged[String("name")],String],shapeless.::[Int with shapeless.record.KeyTag[Symbol with shapeless.tag.Tagged[String("age")],Int],shapeless.HNil]]] = DynamicRecordOps(Mary :: 23 :: HNil) | |
scala> mary.name | |
res2: String = Mary | |
scala> mary.age | |
res3: Int = 23 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment