Skip to content

Shift STArray's to be indexed by nats instead of typeclass indices #127

Description

@hypnoticOxbow

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions