# Detecting `Tuple{Type{some type}}`

I’d like to check if a variabe is of the form `Tuple{Type{Complex}}` or `Tuple{Type{Float64}}` or anything else where the inner-most thing is a type. Here are a couple of my failed attempts:

``````julia> Tuple{Type{Complex}} isa Tuple{Type{<:Type}}
false

julia> Tuple{Type{Complex}} isa Tuple{<:Type{<:Type}}
false

julia> Tuple{Type{Complex}} <: Tuple{Type{<:Type}}
false

julia> Tuple{Type{Complex}} <: Tuple{<:Type{<:Type}}
false

julia> Tuple{Type{Complex}} isa Type{Tuple{Type{<:Type}}}
false

julia> Tuple{Type{Complex}} isa Type{<:Tuple{Type{T}}} where T<:Type
false

julia> Tuple{Type{Complex}} isa Type{<:Tuple{<:Type{T}}} where T<:Type
false

julia> Tuple{Type{Complex}} isa Type{Tuple{<:Type{T}}} where T<:Type
false

julia> Tuple{Type{Complex}} isa Type{<:Tuple{<:Type{T}}} where T<:Type{Type}
false
``````

How can I actually do this? i.e. what should I put after the `isa` or `<:` to get these (as well as anything with `Float64` or any other type instead of `Complex`) to be true?

You can do

``````julia> Tuple{Type{Complex}} <: Tuple{Type{T}} where {T}
true

# as @torrance says, the T is not needed above:
julia> Tuple{Type{Complex}} <: Tuple{Type}
true

julia> Tuple{Type{Float64}} <: Tuple{Type{<:Number}}
true
``````

etc.

The latter will work for subtypes of `Number`, while the former takes all sorts of types.

1 Like

I don’t think it’s a problem to have two simulposts.

There are many ways to do that. For example (not tested)

``````function fooC(x::Tuple{Type{T}}) where {T <: Complex}
return "Complex!"
end

function fooC(x::Tuple{Type{T}}) where {T <: Real}
return "Real!"
end
``````

or if x is your variable

``````typeof(x).types[1]
``````