Recover full printing of `UnionAll` type

As discussed in this thread, printing of UnionAll types changed in Julia 1.7, as demonstrated here:

1.6

julia> struct Foo{A,B} end

julia> Foo{Int}
Foo{Int64, B} where B

1.7

julia> struct Foo{A,B} end

julia> Foo{Int}
Foo{Int64}

Is there a way to recover the full UnionAll printing for Foo{Int}? Something like printunionall(Foo{Int})? (Obviously that doesn’t work, but you get the idea.)

1 Like

Base.unwrap_unionall seems to achieve something close to that:

struct Foo{A,B,C} end

Foo{Int} |> Base.unwrap_unionall
# will produce: Foo{Int64, B, C}

Foo{Int,String} |> Base.unwrap_unionall
# will produce: Foo{Int64, String, C}
1 Like