I’m still trying to understand how generic type dependencies work in Julia. As a follow-up to my question here, I would like to have a dyadic function f(a, b) with the following conditions:

a should be a vector-like of tuples (matrix-like of number, String)

b should be of a type that subtypes.

For the type of a, per the above question, I’ve settled on AbstractVector{Tuple{M, String}} where M <: AbstractMatrix{<:Number}. This is necessary, because otherwise passing an actual Matrix to the function won’t work. However, this makes the actual element type for the matrix “inaccessible” to specify the type of b.

In the end I found out that a possible solution is to use a nested where specification:

f(a::AbstractVector{Tuple{M, String}}, b::S) where {M <:AbstractMatrix{T}, S<:T} where T <: Number = @show (M, S)

This solution works fine in this trivial case, but in practice, when type T is not going to be used, it will result in the following warning:

WARNING: method definition for f at cde.jl:67 declares type variable T but does not use it.

which I would like to avoid.

Is there a better approach to apply this kind of constraints that I’m missing?