haskell / haskell/primitive

Bounds checking in array functions

Open
#212 14 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
123
Forks
60
PR merge metrics
No merged PRs in 30d

Description

We discovered today that array functions do not do bounds checking, which was surprising to us. The expectation was that unless the function is prefixed with "unsafe" it's supposed to do bounds checking.

After discovering this I checked the haddocks, but there's literally no mention to bounds checking in any of the array modules or at the top level. At the very least we should mention in bold letters that the array modules do not do bounds checking, and are completely unsafe.

For long-time primitive users and maintainers this is probably obvious, but it's far from being obvious from a user's point of view.

I realize that it's hard to change this behavior now, so perhaps we should just update the documentation. Ideally it'd be great to have `writeArray` that does bounds checking, and `unsafeWriteArray` that omits it though.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.