Hi,
I have the following:
union_types(x::Union) = union_types(x.a, x.b)
union_types(a::Union, b::Type) = (union_types(a)..., b)
union_types(a::Type, b::Type) = (a, b)
union_types(x::Type) = (x,)
# For completeness
union_types(a::Type, b::Union) = (a, union_types(b)...)
which is a way to get the types composing a Union as a Tuple. However, it is not type-stable:
Is it possible to get, or iterate over, the Types composed in a Union in a type-stable manner, without knowing beforehand how many types will be? The user provide us with a Union of types, so we cannot make assumptions on the total number of types beforehand.