Tuple type don't inherit as expected

question

#1

just did some experimentations with Tuple types. Take the following example

d = Dict{Int, Int}
d_unionall = Type{T} where T <: Dict
u = Union{String, Int}
u_unionall = Type{T} where T>:String
isa(d, d_unionall)  # true
isa(u, u_unionall)  # true

then the respective Tuple combination of both does not work

isa((d, u), Tuple{d_unionall, u_unionall})  # false :-( 

EDIT: subtyping works like expected

Tuple{Type{d}, Type{u}} <: Tuple{d_unionall, u_unionall}  # true :-)

anyone an idea what is going on here?


#3
julia> isa((Int,), Tuple{Type{Int}})
false
julia> isa.((Int,), (Type{Int},))
(true,)

#4

The issue you are facing is the same as

julia> (Float64, ) isa Tuple{Type{<:AbstractFloat}}
false

I don’t think you can use Type except in the outermost position.

You can use a Tuple type and form the Union outside, eg

julia> Tuple{Float64, Int} isa (Type{Tuple{T,S}} where {T <: AbstractFloat, S <: Integer})
true

#5

thanks a lot!

just misunderstood how isa works obviously


#6

still there is confusion on my side.

Why is the following not working?

julia> (Int, String) :: Tuple{Type{Int}, Type{String}}
ERROR: TypeError: in typeassert, expected Tuple{Type{Int64},Type{String}}, got Tuple{DataType,DataTy
pe}