Created
September 13, 2013 13:48
-
-
Save jonifreeman/6550962 to your computer and use it in GitHub Desktop.
Records with objects as keys
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
// Test3.scala | |
import shapeless._ | |
import syntax.singleton._ | |
object Test3 { | |
val r = | |
(k01 ->> 1) :: (k02 ->> 1) :: (k03 ->> 1) :: (k04 ->> 1) :: (k05 ->> 1) :: | |
(k06 ->> 1) :: (k07 ->> 1) :: (k08 ->> 1) :: (k09 ->> 1) :: (k10 ->> 1) :: | |
(k11 ->> 1) :: (k12 ->> 1) :: (k13 ->> 1) :: (k14 ->> 1) :: (k15 ->> 1) :: | |
(k16 ->> 1) :: (k17 ->> 1) :: (k18 ->> 1) :: (k19 ->> 1) :: (k20 ->> 1) :: | |
(k21 ->> 1) :: (k22 ->> 1) :: (k23 ->> 1) :: (k24 ->> 1) :: (k25 ->> 1) :: | |
(k26 ->> 1) :: (k27 ->> 1) :: (k28 ->> 1) :: (k29 ->> 1) :: (k30 ->> 1) :: | |
(k31 ->> 1) :: (k32 ->> 1) :: (k33 ->> 1) :: (k34 ->> 1) :: (k35 ->> 1) :: HNil | |
// r get k01 // 1s | |
// r get k02 // 2s | |
// r get k03 // 4s | |
// r get k04 // 5s | |
// r get k05 // 6s | |
// r get k10 // 9s | |
// r get k20 // 12s | |
// This loops over every field: | |
// jsonless.json4s.toJSON(r) // 5s | |
// Cost of selecting with HList.select function: | |
// r.select[record.FieldType[k02.type, Int]] // 21s | |
// r.select[record.FieldType[k20.type, Int]] // 14s | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment