Skip to content

Note mutability of array and address access primops

Ben Orchard requested to merge wip/raehik/primop-array-mutability-docs into master

Without an understanding of immutable vs. mutable memory, the index primop family have a potentially non-intuitive type signature:

indexOffAddr :: Addr# -> Int# -> a
readOffAddr  :: Addr# -> Int# -> State# d -> (# State# d, a #)

indexOffAddr# might seem like a free generality improvement, which it certainly is not!

This change adds a brief note on mutability expectations for most index/read/write access primops. Pure documentation changes, nothing else.

Fixes #24521 (closed) (also see for a bit more detail).

Merge request reports