Wasm.Array
- Package
- purescript-wasm-base
- Repository
- purs-wasm/purescript-wasm-base
The first-order array primitives the higher-order array combinators are built on.
The foreign imports resolve to intrinsics on the wasm backend
(Intrinsics.qualifiedIntrinsic — Wasm.Array.*), so they need no .wat; the
accompanying Wasm/Array.js provides them for stock purs / purs-backend-es, so a
wasm-base-using project also compiles and runs on the JS backends. On wasm the JS
foreigns are ignored.
#unsafeIndex Source
unsafeIndex :: forall a. Array a -> Int -> aThe element at index i, unchecked (no bounds test — out of range traps). On wasm:
the ArrayIndex intrinsic (array.get; the element is already an eqref, no box).
#unsafeSet Source
unsafeSet :: forall a. Array a -> Int -> a -> Array aWrite v at index i, mutating the array in place, and return that same array, so a
builder loop threads it — keeping the write live (not dead-code-eliminated) and ordered by
the data dependency, without needing an effect. Unchecked (out of range traps). On wasm:
the ArraySet intrinsic (array.set, then yields the array).