Skip to content

Instantly share code, notes, and snippets.

@kevinwright
Created October 21, 2014 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinwright/d3fc87b65c4cf520af80 to your computer and use it in GitHub Desktop.
Save kevinwright/d3fc87b65c4cf520af80 to your computer and use it in GitHub Desktop.
LabelledGeneric Oddness
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