koka icon indicating copy to clipboard operation
koka copied to clipboard

Array programming

Open patrick-nicodemus opened this issue 8 months ago • 20 comments

It explains in the README that a goal for Koka is to support array programming better in the future, and I wanted to ask what that might look like, and what is currently possible.

  1. I want to map a function f: 'a -> 'a along a vector, and have this update in place. Is this: currently achievable, an eventual design goal, probably never going to happen, etc.
  2. I want to sort a vector of floating point numbers in place: is this ever going to happen?
  3. I want to sort a vector of floating point numbers, not necessarily in place but by an algorithm that does not involve converting it into a list, sorting the list, and then converting the list to an array, because this seems to involve much more pointer chasing than a simple ordinary array sort and is probably much slower because of cache locality issues (although I would be very interested to hear if I'm wrong about this)

A related question I have is that, by reading your group's papers, it seems that you can use effects to control stateful computation in the same way that Haskell does with the state monad and runST.

The vectors defined in the standard library are immutable. It is not clear to me whether Koka gives the programmer a way to use scoped effects to do stateful array computations, is there anything there? The documentation for the modify function talks about in-place updates for vectors but I unfortunately did not really understand that bit.

patrick-nicodemus avatar Jun 02 '24 01:06 patrick-nicodemus