| // uncomment variance annotations -> compiler error | |
| trait IdentityCompose[:=>[/* - */_, /* + */_]] { | |
| def identity[A]: A :=> A | |
| def compose[A, B, C](bc: B :=> C, ab: A :=> B): A :=> C | |
| } | |
| case class ToFrom[A, B](to: A => B, fr: B => A) | |
| object ToFrom { | |
| def ToFromIdentityCompose: IdentityCompose[ToFrom] = | |
| new IdentityCompose[ToFrom] { | |
| def identity[A]: A ToFrom A = | |
| ToFrom(a => a, a => a) | |
| def compose[A, B, C](bc: B ToFrom C, ab: A ToFrom B): A ToFrom C = | |
| ToFrom(bc.to compose ab.to, bc.fr andThen ab.fr) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment