Ticket #3895 (new feature request)
"Fix" pervasive-but-unnecessary signedness in GHC.Prim
| Reported by: | pumpkin | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 7.6.2 |
| Component: | Compiler | Version: | |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
I'm talking about the array primitives in particular:
writeFloatArray# :: MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
Conceptually, a Word# makes more sense as the index for all the array functions. I'm not even sure what the semantics are if the Int# is negative... is it checked? The three scenarios I can think of are:
Negativity is checked, and you get an exception. Negativity is unchecked, and you get to write to memory that comes before your array. Negativity is ignored, and the back-end treats the Int# like a Word# already.
I think the switch would be worthwhile in all of those cases, and could be hidden in higher-level APIs that still use Int for indexes with a simple int2Word#. Eventually we might even migrate to Word-based APIs at that level?
