Skip to content

Instantly share code, notes, and snippets.

@labra
Created August 12, 2016 08:24
Show Gist options
  • Save labra/c3cbf6b392be76053bfd6f6ed338a501 to your computer and use it in GitHub Desktop.
Save labra/c3cbf6b392be76053bfd6f6ed338a501 to your computer and use it in GitHub Desktop.
A question about how to use abstract types and typeclasses
package examples
import cats._
import cats.data._
import cats.implicits._
import cats.syntax.show._
class UsingShow1 {
type Value <: Show[Value]
def showValues(vs: List[Value]): String =
???
// Doesn't work
// vs.map(implicitly[Show[Value]].show(_)).mkString
}
class UsingShow2[Value: Show] {
def showValues(vs: List[Value]): String =
vs.map(implicitly[Show[Value]].show(_)).mkString
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment