Parameterising types with multiple parameters

  1. (Simplified) It doesn’t work because P could already match a concrete type. For example, P could be Array{Float64,1}, so P{T} is not valid.
  2. Use
    struct MyType{T <: AbstractFloat, P <: AbstractArray{T}}
        x::T
        data::P
    end
    
    instead.

Note also that in your original example, data::Array{T} is not a concrete type (the second type parameter is missing), so this would slow down your code.