Created
March 26, 2014 06:47
-
-
Save kamekoopa/9777938 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 DocchiGaDaiji[A, B] { | |
def docchi(a: A, b: B): Either[A, B] | |
} | |
object WatashiToShigoto { | |
case class Watashi | |
case class Shigoto | |
implicit object WatashiToShigotoDocchigaDaiji extends DocchiGaDaiji[Watashi, Shigoto]{ | |
override def docchi(a: Watashi, b: Shigoto): Either[Watashi, Shigoto] = { | |
Right(b) | |
} | |
} | |
} | |
object Main { | |
import WatashiToShigoto._ | |
def main(args: String*): Either[Watashi, Shigoto] = { | |
docchi(Watashi(), Shigoto()) | |
} | |
def docchi[A, B](a: A, b: B)(implicit ev: DocchiGaDaiji[A, B]): Either[A, B] = { | |
ev.docchi(a, b) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment