Skip to content

Instantly share code, notes, and snippets.

@valdo404
Created March 16, 2022 16:38
Show Gist options
  • Save valdo404/a073b9d122c62ce8eb3265bd0513e923 to your computer and use it in GitHub Desktop.
Save valdo404/a073b9d122c62ce8eb3265bd0513e923 to your computer and use it in GitHub Desktop.
import shapeless._
import shapeless.record._
import shapeless.labelled._
import shapeless.syntax.singleton._
type BookRecord = FieldType[Witness.`"author"`.T, String] ::
FieldType[Witness.`"title"`.T, String] ::
FieldType[Witness.`"id"`.T, Double] ::
FieldType[Witness.`"price"`.T, Double] ::
HNil
val book: BookRecord = ("author" ->> "test") ::
("title" ->> "test2") ::
("id" ->> 1.0) ::
("price" ->> 2.0) ::
HNil
println(book("author"))
println(book("title"))
println(book("id"))
println(book("price"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment