How to hack into type generation using UnionAlls?

julia> abstract type Atype{Q} end

julia> Atype{Int}
Atype{Int64}

However I want Atype{Int} to produce Union{Atype{Int64}, Atype{Number}, Atype{Signed}}

So is there way that I can programmatically intervene in the generation of a type?
Thanks

Atype{<:Number}

?

1 Like

nice :slight_smile: But I want to go from Int → all :slight_smile: this was a specific example.

Core.apply_type is called whenever a UnionAll is given parameters to be specialized. However we are not allowed to add a method to apply_type function since it is a builtin. Is there a way to intercept apply_type?

No that’s not possible.

What do you want? If you just want a short syntax to generate types, use a function. If you want dispatch to work on it then no you are not allowed to do that.

1 Like