Skip to content

Better primops for indexing into bytearray of sub-machine-sized words

Motivation

GHC 8.8 ships with Word8#, Word16#, Word32#, and Word64#. Hooray. They aren't used in the definition of their lifted counterparts yet, but that's fine. The primitives for indexing into ByteArray#s that contain sub-machine-sized words still have misleading types though. For example, indexWord8Array# :: ByteArray# -> Int# -> Word# when the result should really be Word8#.

Proposal

There are two options. One is to change the types of the existing primops. This would break stuff. The alternative is to add new primops (indexTypedWord8Array#?) that uses the new primitive type in its type signature. I'm happy to make this change or addition. I just need to know if there's a plan to go down a particular path.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information