Last active
February 22, 2016 14:09
-
-
Save wheaties/01ff72d3fb8e9ea355c8 to your computer and use it in GitHub Desktop.
Unique merges
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 Merge[LSet, RSet]{ | |
| type Out | |
| } | |
| object Merge extends LowPriorityMerge{ | |
| implicit def left[L, R]: Aux[L, L|R, L|R] = new Merge[L, L|R]{ type Out = L|R } | |
| implicit def right[L, R]: Aux[R, L|R, L|R] = new Merge[R, L|R]{ type Out = L|R } | |
| } | |
| trait LowPriorityMerge extends LowPriorityMerge1{ | |
| implicit def search[S, L, R](implicit m: Merge[S, R]): Aux[S, L|R, L|m.Out] = | |
| new Merge[S, L|R] { type Out = L|m.Out } | |
| } | |
| trait LowPriorityMerge1{ | |
| type Aux[L, R, O] = Merge[L, R]{ type Out = O } | |
| implicit def one[S]: Aux[S, S, S] = new Merge[S, S]{ type Out = S } | |
| implicit def distinct[S, T]: Aux[S, T, S|T] = new Merge[S, T]{ type Out = S|T } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment