The client will have its own spec, and when it uses the array, you need to prove that it does so in a way that its own spec is fulfilled.
You need to know the entire semantics of the interaction. You need to know what the array represents for the client, and that may depend on the client of the client.
But with multiple dispatch you are constantly tempted to pretend that correctness just depends on the type, because that's what you dispatch on. So that's the problem.
In general, I like types for organising things. I don't like them for correctness.
PS: Edited the above a few times to make my point more clearly.
So you cannot loop over a subset of the indices? That seems restrictive.
I don't think the Array indexing issue can be dealt with by (just) improving its interface specification. I think the proper fix for this is beyond what can reasonably be done in any language that doesn't come with a notion of correctness and proof.
See: https://github.com/google-research/dex-lang/pull/969 and https://github.com/google-research/dex-lang/blob/5cbbdc50ce0... for examples