Created
February 12, 2013 19:36
-
-
Save sritchie/4772683 to your computer and use it in GitHub Desktop.
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
import annotation.implicitNotFound | |
@implicitNotFound(msg = "This message can never appear!") | |
trait ~>[A, B] { self => | |
def apply(a: A): B | |
def invert(b: B): A = inverse.apply(b) | |
def inverse: B ~> A = new ~>[B,A] { | |
def apply(b: B) = self.invert(b) | |
override def invert(a: A) = self(a) | |
} | |
} | |
object ~> { | |
implicit def inverseOf[A, B](implicit forward: A ~> B): B ~> A = forward.inverse | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment