Scala has the compound (i.e. conjunction) type by employing `with`, but it does not have a union (i.e. disjunction) type.
I hope I have successfully demonstrated how to simulate a nearly first-class union type:
And the negation of the disjunction:
I have filed today two bug reports that hinder use of that simulated union type.
Beyond that, I am pondering if Scala is going to lose significant competitive ground w.r.t. to Ceylon if it doesn't add a completely first-class union type asap. And go beyond Ceylon by adding some way to extend the disjunction (e.g. for heterogeneous types) as I demonstrated at link above for negation.
Afaics it is necessary for supporting heterogeneous collections type-safely without resorting to the (probably unbearable for novices, and more "Scala is difficult to read" accusations) complexity of the experimental metascala.
I have been thinking that first-class intersection types are very important, both for the [reasons Ceylon has them], and because instead of [subsuming] to `Any` which means unboxing with a `match` on expected types can generate a runtime error, the unboxing of a ([heterogeneous collection] containing a) disjunction can be type checked. Unions are more straightforward than the [complexity of using] the experimental [HList] of [metascala] for heterogeneous collections.
P.S. There is a duplicate syntax-highlighted version buried nearer to the bottom of the following stackoverflow answer:
P.S.S. Consider reading the Ceylon language design FAQ, as it appears to me to be significant substance in their effort, although I am not yet clear on what corner cases may be lurking in their attempts to simplify and make code more amenable to the mainsteam.