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

**URL:** https://discourse.julialang.org/t/detecting-tuple-type-some-type/82406
**Category:** General Usage
**Tags:** type, parametric-types
**Created:** [June 8, 2022, 6:35am UTC](https://discourse.julialang.org/t/detecting-tuple-type-some-type/82406 "2022-06-08T06:35:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tictaccat](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@tictaccat](https://discourse.julialang.org/u/tictaccat)
#### Post date: [June 8, 2022, 6:35am UTC](https://discourse.julialang.org/t/detecting-tuple-type-some-type/82406/1 "2022-06-08T06:35:35Z")

</div>

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
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?

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [June 8, 2022, 6:49am UTC](https://discourse.julialang.org/t/detecting-tuple-type-some-type/82406/2 "2022-06-08T06:49:33Z")

</div>

You can do

```julia
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.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [June 8, 2022, 6:52am UTC](https://discourse.julialang.org/t/detecting-tuple-type-some-type/82406/4 "2022-06-08T06:52:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [June 8, 2022, 7:32am UTC](https://discourse.julialang.org/t/detecting-tuple-type-some-type/82406/5 "2022-06-08T07:32:39Z")

</div>

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

```julia
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

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

```
