Safe Haskell | None |
---|---|
Language | Haskell2010 |
Compatibility layer for numeric primops.
GHC 9.2 standardized unboxed numeric primops. Prior, it was quite asymmetric.
Many primop functions used the native unboxed numerics Word#
and Int#
even
if a sized unboxed numeric was in the name, e.g. indexWord8OffAddr#
returning
Word#
pre-9.2. All boxed machine integers only stored Word#
internally!
We target GHC 9.2's better handling. In order to maintain compatibility with older GHCs, we define missing primops and wrap ones that changed type. Usually, we can write a few wrappers so that 9.2 uses sized unboxed numerics everywhere, and pre-9.2 uses native unboxed numerics everywhere. Sometimes we really want to work with sized unboxed numerics on both, in which case we have to do more involved primop wrapping.
The general pattern is as follows:
- A ticked primop means it's sized on >=9.2, native on <9.2
- A double-ticked primop means it's sized on all
- An unticked primop should mean the same as a ticked primop (no guarantees)
Also see: https://gitlab.haskell.org/ghc/ghc/-/wikis/Unboxed-Numerics
Documentation
byteSwap16'# :: Word16'# -> Word16'# Source #
byteSwap32'# :: Word32'# -> Word32'# Source #
wordToWord8''# :: Word# -> Word8# Source #
word8ToWord''# :: Word8# -> Word# Source #
word16ToInt16# :: Word16'# -> Int# Source #
word32ToInt32# :: Word32'# -> Int# Source #