# Sharpen Tuple Element Types

**URL:** https://discourse.julialang.org/t/sharpen-tuple-element-types/107179
**Category:** General Usage
**Created:** [December 5, 2023, 5:14pm UTC](https://discourse.julialang.org/t/sharpen-tuple-element-types/107179 "2023-12-05T17:14:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![willtebbutt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/willtebbutt/32/6790_2.png) [@willtebbutt](https://discourse.julialang.org/u/willtebbutt)
#### Post date: [December 5, 2023, 5:14pm UTC](https://discourse.julialang.org/t/sharpen-tuple-element-types/107179/1 "2023-12-05T17:14:53Z")

</div>

```julia
struct Foo end

typeof((Foo, ))

```

yields

```julia
Tuple{DataType}

```

rather than something more precise like

```julia
Tuple{Type{Foo}}

```

This is causing me some type-instability problems.

Question: is there a way to produce a `Tuple` whose type includes `Type{Foo}` rather than `Type{DataType}`?

n.b. I’ve tried `convert(Tuple{Type{Foo}}, (Foo, ))` but can’t seem to get it to work.

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [December 5, 2023, 5:39pm UTC](https://discourse.julialang.org/t/sharpen-tuple-element-types/107179/2 "2023-12-05T17:39:49Z")

</div>

You can make such a tuple type with:

```julia
julia> weirdtypeof(t::Tuple) = Tuple{(tel isa Type ? Type{tel} : typeof(tel) for tel in t)...}
weirdtypeof (generic function with 1 method)

julia> weirdtypeof((Foo, 1, Int, 7.8im))
Tuple{Type{Foo}, Int64, Type{Int64}, ComplexF64}

```

but it won’t be the type of the tuple:

```julia
julia> (Foo, ) isa Tuple{Type{Foo}}
false

julia> (Foo, ) isa Tuple{DataType}
true

```

Types are instances of `DataType`, `Union`, `UnionAll`, etc, not singleton instances, so `Tuple{DataType}` is the only right answer there. That’s usually good because it is wasteful to compile for each type when they share structure, but `Type{T}` exists for dispatch because sometimes it is beneficial to get around.
