Pass view to function

Try:

struct Bar{V <: AbstractVector{foo}}
  y::V 
end

which will let you create a Bar for any kind of vector of foo (including a regular Vector{foo} or a view into such a vector, etc.).