Union Types - Good or Bad?

That someone was me.
And this is great because I can explain what I was thinking when I asked that.
It wasn’t a complaint about unions at all, but a specific question in the context of Jeff’s talk mentioning contradictions and issues in the type system.

The particular case that is easy to remove is along the lines of

foo(x::Union{A, B}) = ...

One can replace that with

for T in (:A, :B)
   @eval foo(X::$T) = ...
end

Infact it is common to do this change over to remove ambiguities.

Not everything can be made ok. No more Vector{Union{Missing, Float64}}.
And it’s breaking so it wasn’t actually a suggestion.
But I was curious as to if removing unions would fix the things that break or are contradictory in the type system that Jeff mentioned during the talk
Since several seemed to involve unions.

9 Likes