-
-
Save fedesilva/36e39e21f2b63309efb48ae7560f14db to your computer and use it in GitHub Desktop.
Type Level OneOf
This file contains 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 OneOf[Obj, Items] | |
object OneOf extends LowPriorityOneOf{ | |
implicit def apply[Obj, Items](implicit oneOf: OneOf[Obj, Items]) = oneOf | |
implicit def left[L, R, Obj <: L] = new OneOf[Obj, L | R]{} | |
} | |
protected trait LowPriorityOneOf extends LowPriorityOneOf1{ | |
implicit def right[L, R, Obj <: R] = new OneOf[Obj, L | R]{} | |
} | |
protected trait LowPriorityOneOf1{ | |
implicit def recur[L, R, Obj](implicit oneOf: OneOf[Obj, R]) = new OneOf[Obj, L | R]{} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment