Is your feature request related to a problem? Please describe.
The index typeclass has typeclass functions sub,zero,fromNat,toNat in order to be able to manipulate ranges of indices for accesses to the STArray. This is required to write an in-place quicksort that recurses down into sections of an array. This came about because STArrays are collections of STRefs, morally.
Describe the solution you'd like
To make that safer, one could adjust array STArrays to be specialized STRefs that form a region for which one could manipulate "raw nats" instead.
Describe alternatives you've considered
Adding yet another typeclass for array indices is another idea. This I think would only add unnecessary complexity, as you would need to add and subtract ranges in that regardless.
One concern is that natural number subtraction subtracts until it reaches 0, which might be unintuitive. Using Z might be more intuitive but then you have to reckon with what happens when you try to reference a negative address.
Is your feature request related to a problem? Please describe.
The index typeclass has typeclass functions
sub,zero,fromNat,toNatin order to be able to manipulate ranges of indices for accesses to theSTArray. This is required to write an in-place quicksort that recurses down into sections of an array. This came about because STArrays are collections of STRefs, morally.Describe the solution you'd like
To make that safer, one could adjust array STArrays to be specialized STRefs that form a region for which one could manipulate "raw nats" instead.
Describe alternatives you've considered
Adding yet another typeclass for array indices is another idea. This I think would only add unnecessary complexity, as you would need to add and subtract ranges in that regardless.
One concern is that natural number subtraction subtracts until it reaches 0, which might be unintuitive. Using
Zmight be more intuitive but then you have to reckon with what happens when you try to reference a negative address.