Array interface refactoring
Bulat Ziganshin
bulat.ziganshin at gmail.com
Wed Feb 22 16:02:10 EST 2006
Hello Ben,
Wednesday, February 22, 2006, 9:47:19 PM, you wrote:
BRG> While we're on the topic, I have a couple of problems with the current array
BRG> system that cut deeper than the naming:
BRG> * The function for getting the bounds of an MArray is pure, so the
BRG> interface can't accommodate resizable arrays.
i think that it is because such arrays can be implemented more
efficiently. then you can implement dynamic arrays on top of MArray
interface (although i'm not sure that this will be efficient. GHC's
classes efficiency is black magic :)
BRG> * unsafeAt, unsafeRead and unsafeWrite take 0-based indices, and the
BRG> bounds checking and conversion is handled externally, based on the
BRG> bounds you return. This means the interfaces can't support array
BRG> windowing, at least in the multidimensional case. I'd be happy with
BRG> windowing for one-dimensional arrays only, but there's no way to
BRG> restrict your array type to one-dimensional index types.
for one-dimensional arrays it's easy to implement. i agree with you,
though, that we can move more operations to the class interface
--
Best regards,
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Haskell-prime
mailing list