When does `modify` copy the vector? : <p>From <a href="https://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector.html#v:modify" rel="noreferrer">https://hackage.haskell.org/package/vector-0.12.0.1/docs/Data-Vector.html#v:modify</a></p>

<blockquote>
  <p>Apply a destructive operation to a vector. The operation will be performed in place if it is safe to do so and will modify a copy of the vector otherwise.</p>
</blockquote>

<p>This sounds like it can have drastically different performance characteristics depending on whether it is deemed "safe" to modify the vector in place. This motivates the questions...</p>

<p>When will the modify be performed in place, and when will the vector be copied? Is there some way to ensure, by use of the type-system for example, that it <em>will</em> be modified in place?</p>
