
I don't really understand what castIOUArray does or how to use it. In fact it seems a little strange to me. Here's why..
The fact that it's type is.. castIOUArray :: IOUArray ix a -> IO (IOUArray ix b) and not simply.. castIOUArray :: IOUArray ix a -> IOUArray ix b seems like strong indication that it actually does something (it's not just dummy id like function used to change types).
But whatever it does must depend on the particular instantiation of a and b? But this is not an overloaded function and the types a and b are not known at compile time, so it's hard to see what it could sensibly do.
Can anybody explain this to me?
Currently the implementation is just a coercion, so there isn't really any need for it to be in the IO monad. However, strictly speaking it should really alter the bounds of the array, since otherwise one can access outside the bounds by coercing to a larger type. Otherwise we should really call the operation "unsafeCastIOUArray". I think we should keep it in the IO monad but document the fact that the bounds don't get altered as an implementation bug. Cheers, Simon