# Check if a type is a "concretization" of some UnionAll

**URL:** <https://discourse.julialang.org/t/check-if-a-type-is-a-concretization-of-some-unionall/58974>\
**Category:** General Usage\
**Created:** [April 10, 2021, 10:16am UTC](https://discourse.julialang.org/t/check-if-a-type-is-a-concretization-of-some-unionall/58974 "2021-04-10T10:16:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tisztamo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tisztamo/32/16200_2.png) [@tisztamo](https://discourse.julialang.org/u/tisztamo)\
**Post date:** [April 10, 2021, 10:16am UTC](https://discourse.julialang.org/t/check-if-a-type-is-a-concretization-of-some-unionall/58974/1 "2021-04-10T10:16:33Z")

</div>

Having a UnionAll and another type I would like to check if the other was constructed by filling the parameters of the UnionAll:

```julia
struct A{T} end
const C1 = A{Int}

using Test
@test concretizationof(C1, A) == true
@test concretizationof(C1, Number) == false
@test concretizationof(A, A) == false

```

A rudimentary implementation:

```julia
concretizationof(c, a) = isconcretetype(c) && typeof(a) == UnionAll && c.name == a.body.name

```

Is there a better alternative? Better means e.g. without using implementation details, and not throwing for `(Vector{Int}, Array) `.

---

<div class="post-metadata">

**Author:** ![chris-b1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chris-b1/32/14165_2.png) [@chris-b1](https://discourse.julialang.org/u/chris-b1)\
**Post date:** [April 10, 2021, 1:21pm UTC](https://discourse.julialang.org/t/check-if-a-type-is-a-concretization-of-some-unionall/58974/2 "2021-04-10T13:21:15Z")

</div>

How about this

```julia
concretizationof(c, a) = isconcretetype(c) && typeof(a) == UnionAll && c <: a

julia> concretizationof(C1, Number)
false

julia> concretizationof(C1, A)
true

julia> concretizationof(A, A)
false

julia> concretizationof(Vector{Int}, Array)
true

```

---

<div class="post-metadata">

**Author:** ![tisztamo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tisztamo/32/16200_2.png) [@tisztamo](https://discourse.julialang.org/u/tisztamo)\
**Post date:** [April 10, 2021, 1:48pm UTC](https://discourse.julialang.org/t/check-if-a-type-is-a-concretization-of-some-unionall/58974/3 "2021-04-10T13:48:26Z")

</div>

Thanks, it seems that it was a silly question. Knowing that `A{Int} <: A{Number}` is `false` helped me to avoid the trivial solution. Sorry for the noise!
