Is your feature request related to a problem? Please describe.
I'm developing a matrix library, where matrices are represented by Pinned or Ptr of elements. I would like to implement some operations that iterate over a sub-matrix, and call an external lib via FFI to mutate it in place. (Think row echelon reduction from high school!).
This is my specific use case, but it is quite a general problem, where you want to be able to operate on a smaller part of a large byte structure. The only workaround now is copying that substructure, calling the FFI and finally stitching all the results together manually.
Describe the solution you'd like
Ideally, I would like to slice Pinned arrays and also do pointer arithmetic.
The reason is that in my program I use internally the representations Pinned IO, Pinned (Scope s), Ptr depending on the implementation.
Describe alternatives you've considered
I understand the reason for ByteArray.Raw is that the slice operation is ineffective. So perhaps implementing this is prohibitively expensive.
An alternative might be to have new FFI.Type primitives offsetPinnedByteArray : Nat -> FFI.Type and one for pointer. Though this feels clunky.
Finally, I suppose just having Ptr arithmetic would be enough, though clunky, as I'd have to change old my function specs to use pointers, and manage these resources manually.
Additional context
My library is here: https://share.unison-lang.org/@ljoublanc/blas/code/releases/0.1.2/latest/types/cblas/dense/BLAS
Is your feature request related to a problem? Please describe.
I'm developing a matrix library, where matrices are represented by
PinnedorPtrof elements. I would like to implement some operations that iterate over a sub-matrix, and call an external lib via FFI to mutate it in place. (Think row echelon reduction from high school!).This is my specific use case, but it is quite a general problem, where you want to be able to operate on a smaller part of a large byte structure. The only workaround now is copying that substructure, calling the FFI and finally stitching all the results together manually.
Describe the solution you'd like
Ideally, I would like to slice Pinned arrays and also do pointer arithmetic.
The reason is that in my program I use internally the representations
Pinned IO, Pinned (Scope s), Ptrdepending on the implementation.Describe alternatives you've considered
I understand the reason for
ByteArray.Rawis that thesliceoperation is ineffective. So perhaps implementing this is prohibitively expensive.An alternative might be to have new FFI.Type primitives
offsetPinnedByteArray : Nat -> FFI.Typeand one for pointer. Though this feels clunky.Finally, I suppose just having
Ptrarithmetic would be enough, though clunky, as I'd have to change old my function specs to use pointers, and manage these resources manually.Additional context
My library is here: https://share.unison-lang.org/@ljoublanc/blas/code/releases/0.1.2/latest/types/cblas/dense/BLAS