When to use iarray instead of array?

The intention is that people should rather use Iarray.t, and iarray is a built-in type that is more an implementation detail that may disappear from the interface. (In fact, we should rewrite this API to expose 'a Iarray.t rather than 'a iarray).

The intention of immutable arrays is mostly to have better APIs: documenting that functions do not modify their arguments for instance.

So it’s up to you and to how you think your API should be used. If it’s convenient for your users to be able to modify the result of a function, maybe you should use a mutable array.

Note that Dynarray.unsafe_to_iarray exists, i.e., turning a mutable (and dynamically-sized) array to an iarray without a copy (under some conditions).

Since Iarray.t is in the stdlib, I think it would make sense to suggest to the alcotest maintainers to add Alcotest.iarray.