Created
May 4, 2018 10:44
-
-
Save fogfish/aef674ce09af47aef384b567c450a3fd to your computer and use it in GitHub Desktop.
Use Poly1 to Map HList
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
import shapeless._ | |
object size extends Poly1 { | |
implicit def default[T] = at[T](t => (t, 1)) | |
implicit def caseInt = at[Int](x => (x, x)) | |
implicit def caseString = at[String](s => (s, s.length)) | |
} | |
val hl = "one" :: 2 :: "three" :: HNil | |
hl.map(size) | |
hl.map(size).toList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment