Created
January 8, 2016 14:20
-
-
Save xevix/0bb6dcac184e8f5d6659 to your computer and use it in GitHub Desktop.
Coproduct Scala Worksheet Fail
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
// From Shapeless `coproduct.scala` | |
sealed trait Animal | |
case class Cat(name: String, livesLeft: Int) extends Animal | |
case class Dog(name: String, bonesBuried: Int) extends Animal | |
case class Koala(name: String, leavesEaten: Int) extends Animal | |
case class Sloth(name: String, daysToClimbDownFromCurrentTree: Int) extends Animal | |
val garfield = Cat("Garfield", 9) | |
val odie = Dog("Odie", 3) | |
val koala = Koala("foo", 10) | |
val sloth = Sloth("bar", 2) | |
// NOTE: This line fails in worksheet, as it can't find the implicit based on the `Animal` type, but works from console | |
val genAnimal = Generic[Animal] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment