Reference: https://docs.julialang.org/en/v1/manual/types/index.html
Relationship between super/sub types:
Any >: Number >: Real >: Integer >: Signed >: Int === Int64 >: Function >: getfield(Main, Symbol(”##1##2”)) >: typeof(f) >: AbstractString >: String >: AbstractArray >: DenseArray >: Array >: AbstractArray{Any,1} >: DenseArray{Any,1} >: Array{Any, 1} >: Ref === Ref{} >: Ptr === Ptr{} >: Ptr{Cvoid} >: Ref{Cvoid} >: Ptr{Cvoid} >: Expr >: Symbol >: Tuple >: Tuple{} >: Tuple{Any} >: Tuple{Numbr} >: ... # `Tuple` is covariant >: Tuple{Any, Any} >: Tuple{Any, Any, Any} >: ... >: Vararg === Vararg{} >: Vararg{Int} >: Vararg{Int, 3} >: NamedTuple === NamedTuple{} >: NamedTuple{()} >: NamedTuple{(), Tuple{}} >: Type === Type{} === (Type{T} where T) == Type{<:Any} >: Type{T} === supertype(DataType) === supertype(UnionAll) >: DataType >: UnionAll >: Union # empty union >: Union{A, B} where A where B >: Union >: Union{Int, String} >: Union{Int, Int} === Int >: Union{} === Base.Bottom # of type `Core.TypeofBottom`
UnionAll expresses the "iterated union" of types, e.g. A{B,C} is equivalent to A{B}{C}, is type of:
Type Vararg Vararg{Any} NamedTuple NamedTuple{()} Array Array{Any} DenseArray DenseArray{Any} AbstractArray AbstractArray{Any} Ptr Ref Union{A, B} where A where B C # struct C{T} end C{<:Any} C{T} where T<:Any
DataType has properties: "explicitly declared", "named", "explicitly declared supertypes", "(optional) parameterized" is type of:
Int Integer Real Number Any String AbstractString Tuple Tuple{} Vararg{Any, 0} NamedTuple{(), Tuple{}} Array{Any, 1} DenseArray{Any, 1} AbstractArray{Any, 1} Ptr{Cvoid} Ref{Cvoid} Expr Symbol getfield(Main, Symbol("##1##2") # function () end typeof(f) # function f() end Function DataType UnionAll Union Type{T} # supertype(DataType) ... it is not UnionAll !! Union{Any} # Any Union{A} where A # Any C # struct C end C{Any} # struct C{T} end
There are some types neither DataType nor UnionAll but still a Type:
julia> Union{Int, String} isa DataType false julia> Union{Int, String} isa Type true julia> Union{Int, String} isa Union true julia> julia> Union{} isa DataType false julia> Union{} isa Type true julia> Union{} isa Union false julia> Union{} isa Core.TypeofBottom true