Created
August 1, 2014 14:15
-
-
Save MasseGuillaume/9c0c79a2468af211724b to your computer and use it in GitHub Desktop.
Serialize type class
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
object TC { | |
trait Ser[In, Out] { | |
def ser(in: In): Out | |
} | |
implicit object StringString extends Ser[String, String] { | |
def ser(a: String) = a | |
} | |
} | |
object A extends App{ | |
import TC._ | |
def doSer[In, Out](a: In)(implicit ev: Ser[In, Out]): Out = ev.ser(a) | |
doSer("test") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment