Skip to content

Instantly share code, notes, and snippets.

@sir-wabbit
Last active October 17, 2017 08:06
Show Gist options
  • Select an option

  • Save sir-wabbit/dedd7187be6490fb0976256ab67baaa2 to your computer and use it in GitHub Desktop.

Select an option

Save sir-wabbit/dedd7187be6490fb0976256ab67baaa2 to your computer and use it in GitHub Desktop.
type | [+A, +B] = Union.Type[A, B]
object Union {
trait Tag extends Any
type Base
type Type[+A, +B] <: Base with Tag
implicit def first[A]: A <:< Type[A, Nothing] =
implicitly[A <:< A].asInstanceOf[A <:< Type[A, Nothing]]
implicit def second[B]: B <:< Type[Nothing, B] =
implicitly[B <:< B].asInstanceOf[B <:< Type[Nothing, B]]
}
object A
object B
object C
type X = A.type | B.type | C.type
type Y = A.type with B.type with C.type
implicitly[Y <:< X]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment