The constructor of MVector is exposed:
data MVector s a = MVector !Int !Int !(MutableArray s a)
This seems pretty odd, because the two Ints are the offset into the underlying MutableArray that the MVector starts, and the length of the MVector. both of which are used for bounds checking before deferring to readArray of a MutableArray via basicUnsafeRead.
So I'm confused. Firstly, can changing those fields not lead to segfaults? And secondly, doesn't changing those fields have no real purpose, since there are better ways of obtaining the ends one wants via the safe API (or even the unsafe one, with functions explicitly named as "unsafe" if one really wants the performance)?
Or have I missed something, and there is a good reason for exposing those fields?
The constructor of
MVectoris exposed:This seems pretty odd, because the two
Ints are the offset into the underlyingMutableArraythat theMVectorstarts, and the length of theMVector. both of which are used for bounds checking before deferring toreadArrayof aMutableArrayviabasicUnsafeRead.So I'm confused. Firstly, can changing those fields not lead to segfaults? And secondly, doesn't changing those fields have no real purpose, since there are better ways of obtaining the ends one wants via the safe API (or even the unsafe one, with functions explicitly named as "
unsafe" if one really wants the performance)?Or have I missed something, and there is a good reason for exposing those fields?