Created
March 27, 2015 00:50
-
-
Save xuwei-k/7115b330b4ee37d961d0 to your computer and use it in GitHub Desktop.
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
trait FlipFlapper[T] { | |
def doFlipFlap(x: T): T | |
} | |
object FlipFlapper { | |
def fromFunction[A](f: A => A): FlipFlapper[A] = | |
new FlipFlapper[A] { | |
def doFlipFlap(x: A) = f(x) | |
} | |
implicit val int = | |
fromFunction[Int](- _) | |
implicit val string = | |
fromFunction[String](_.reverse) | |
implicit def list[A] = | |
fromFunction[List[A]](_.reverse) | |
implicit val boolean = | |
fromFunction[Boolean](! _) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment