Skip to content

Instantly share code, notes, and snippets.

@wheaties
Last active February 22, 2016 14:09
Show Gist options
  • Select an option

  • Save wheaties/d5daacb9305c8f6533ec to your computer and use it in GitHub Desktop.

Select an option

Save wheaties/d5daacb9305c8f6533ec to your computer and use it in GitHub Desktop.
Single level merge
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{
type Aux[L, R, O] = Merge[L, R]{ type Out = O }
implicit def none[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