Created
October 21, 2014 10:55
-
-
Save kevinwright/d3fc87b65c4cf520af80 to your computer and use it in GitHub Desktop.
LabelledGeneric Oddness
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._ | |
case class Wibble(x: Int, y: String) | |
val wib = Wibble(42, "towel") | |
def recOf[T](obj: T)(implicit gen: LabelledGeneric[T]) = gen.to(obj) | |
recOf(wib) // works beautifully | |
class ClassyRecOf[T](implicit gen: LabelledGeneric[T]) { | |
def doIt(obj: T) = gen.to(obj) | |
} | |
new ClassyRecOf[Wibble].doIt(wib) // returns gen.Repr = 42 :: towel :: HNil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment