Created
August 12, 2016 08:24
-
-
Save labra/c3cbf6b392be76053bfd6f6ed338a501 to your computer and use it in GitHub Desktop.
A question about how to use abstract types and typeclasses
This file contains hidden or 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
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