Skip to content

Instantly share code, notes, and snippets.

@ukitaka
Created May 9, 2017 09:56
Show Gist options
  • Save ukitaka/cdfbdc15e52be4cb1f3e2aeb9d336fbb to your computer and use it in GitHub Desktop.
Save ukitaka/cdfbdc15e52be4cb1f3e2aeb9d336fbb to your computer and use it in GitHub Desktop.
Union.scala
sealed trait Union[A, B]
case class Left[A, B](a: A) extends Union[A, B]
case class Right[A, B](b: B) extends Union[A, B]
type |[A, B] = Union[A, B]
implicit def liftLeft[A, B](a: A) = Left[A, B](a)
implicit def liftRight[A, B](b: B) = Right[A, B](b)
var intString: Int | String = 1
intString = "hello"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment