There's now a number of issues open for thoughts about how to make the printing of types more readable. Here's another notion: it would be nice if printing could replace Unions with appropriate typealiases. For example:
julia> methods(permutedims)
#2 methods for generic function "permutedims":
permutedims(B::Union{Base.ReshapedArray{T<:Any,N<:Any,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N<:Any}}},DenseArray{T<:Any,N<:Any},SubArray{T<:Any,N<:Any,A<:Union{Base.ReshapedArray{T<:Any,N<:Any,A<:DenseArray,MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N<:Any}}},DenseArray},I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex,Colon,Int64,Range{Int64}},N<:Any}},L<:Any}}, perm) at multidimensional.jl:959
permutedims{T,N}(A::AbstractArray{T,N}, perm) at permuteddimsarray.jl:47
But the first method is actually defined as permutedims(B::StridedArray, perm) which is rather simpler to read.
This is easy to point out, but actually implementing it seems likely to be hard starting from the jl_uniontype_t itself. Unless Union types get modified to record whether they come from a typealias.
The printing code could search for globals === to a particular union type. We could potentially have an ObjectIdDict mapping unions to their "names". Not sure if that's necessary, but it could even be part of the lowering of typealias, giving that syntax a bit of extra value over const assignment.
Showing names for instantiations of these unions is of course harder, but after #8974 it will at least be possible to brute-force search globals for supertypes of a given union type.
I was worried that brute-force search would be too inefficient, but maybe we wouldn't typically have that many typealiases. https://github.com/JuliaMath/FixedPointNumbers.jl/pull/51 exports a few hundred typealiases, but none of those are Unions.
Duplicate of #14946?
Yup.
Most helpful comment
The printing code could search for globals === to a particular union type. We could potentially have an ObjectIdDict mapping unions to their "names". Not sure if that's necessary, but it could even be part of the lowering of
typealias, giving that syntax a bit of extra value over const assignment.Showing names for instantiations of these unions is of course harder, but after #8974 it will at least be possible to brute-force search globals for supertypes of a given union type.