Type signature for nested `AbstractArray`



I would like a method foo(x) to be called when x is a U{V{T,N}, where

  1. U <: AbstractVector,
  2. S <: AbstractArray{T,N}

and I can’t figure out how. Thought that since

Array{Int,2} <: AbstractArray{Int,2}`

I would have

Vector{Array{Int,2}} <: AbstractVector{AbstractArray{Int,2}} 

but that does not hold. The syntax

foo{T,N,S <: AbstractArray, U <: AbstractVector}(v::U{S{T,N}}) = :called

does not work. Using 0.5.0.


U is a type variable, not a data type, so it can’t be parameterized. In v0.6, you’ll be able to express triangular dispatch, but not in v0.5. But that’s not actually what you want either. The following does what you asked:

foo{S <: AbstractArray}(v::AbstractVector{S}) = :called