(Sorry didn’t see your next post - it does make sense to want that connected I guess - but not sure that generalises in multiple dispatch. If you have multiple methods, it may not be the same relationship)
It’s a reasonable question, but yeah, julia’s type system is not equipped to deal with this sort of thing. Type inference in julia is heavily focused on concrete types, because every single function call has fully unconstrained potential for ad-hoc polymorphism.
Yes, in the example you gave, you could reasonably expect that the compiler should be able to predict that for any T you put in, a Vector{T} should come out, but it quickly falls apart as soon as you look at anything more complicated.
In general, the output types of a specific function call are going to depend precisely on the input types.
Haskell can avoid this because all functions have either parametric polymorphism, or polymorphism via type-classes which are both much much more rigid and constrained than julia’s approach with totally free-form multiple dispatch, and even then the Haskell compiler will sometimes need you to provide a type signature when it can’t figure out a parametric signature for a function.
Julia’s dynamic typing and type inference make generic functions more flexible than those in statically typed languages where you declare the return type given the parameters first, and I think you can’t infer something like the latter in most cases. Here’s a simple example where the return type depends on a generic function call, rather than the 1-element array literal in the OP:
foo(x::T) where T = bar(x)[]
bar(::Int) = String
bar(::String) = Float64
bar(::Float64) = rand(Bool, Int8, Int16, Int32, Int64, Int128)
Best you can say is foo(::T) has a return type Vector{bar(x)}, which isn’t the static analysis we want because it 1) is not an expression with T, and 2) depends on a runtime value. The bar(::Float64) method introduces type-instability to foo(::Float64), so the compiler infers Vector. If we must infer by method signature instead of call signature, that’s the best we can do.