What does castIOUArray do?

Simon Marlow simonmar@microsoft.com
Tue, 7 Jan 2003 13:17:49 -0000


> 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..
>=20
> 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).
>=20
> But whatever it does must depend on the particular=20
> instantiation of a and b?=20
> But this is not an overloaded function and the types a and b=20
> are not known at
> compile time, so it's hard to see what it could sensibly do.
>=20
> 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