Shift `STArray`'s to be indexed by nats instead of typeclass indices
- Dominant language
- C++
- Stars
- 166
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
**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.
Contributor guide
Research direction
Locate STArray and the index typeclass, then inspect how in-place quicksort uses range operations and recursive section accesses. Define the desired indexing boundary and verify that STArray accesses and quicksort no longer require typeclass-provided index arithmetic while handling natural-number subtraction as described.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100