Last active
August 29, 2015 14:04
-
-
Save wheaties/e54bd081b2cb88b5e4b7 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
| trait Projection[P <: Poly]{ | |
| def apply[A, B](a: A, b: B)(implicit law:Law[P, A, B]): law.Out = law(a, b) | |
| } | |
| //Witnessing that P can handle AxB -> O, AxO, BxO | |
| //i.e. P is a projection onto a line | |
| trait Law[P <: Poly, A, B]{ | |
| type Out | |
| def apply(a: A, b: B): Out | |
| } | |
| object Law{ | |
| def apply[P <: Poly, A, B](implicit law: Law[P, A, B]) = law | |
| implicit def mk[P <: Poly, A, B, O](implicit ev: Case2.Aux[P, A, B, O], rq: Case2[P, A, O], rq2: Case2[P, B, O]) = | |
| new Law[P, A, B]{ | |
| type Out = ev.Result | |
| def apply(a: A, b: B) = ev(a, b) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment