Created
December 7, 2016 19:08
-
-
Save danslapman/fb460ff71c28810b10a9b700e3d408cd to your computer and use it in GitHub Desktop.
Selectors
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
val book = | |
('author ->> "Benjamin Pierce") :: | |
('title ->> "Types and Programming Languages") :: | |
('id ->> 262162091) :: | |
('price ->> 44.11d) :: | |
HNil | |
def readBook[B <: HList](book:B)(implicit | |
author: Selector.Aux[B, Witness.`'author`.T, String], | |
title: Selector.Aux[B, Witness.`'title`.T, String], | |
price: Selector.Aux[B, Witness.`'price`.T, Double] | |
): Unit = { | |
println(s"${author(book)}: ${title(book)}, ${price(book)}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment