{-# LANGUAGE CPP #-}
{-# LANGUAGE MagicHash #-}
module Basement.HeadHackageUtils where

import GHC.Exts

#if MIN_VERSION_base(4,16,0)
int8ToIntCompat# :: Int8# -> Int#
int8ToIntCompat# = int8ToInt#

int16ToIntCompat# :: Int16# -> Int#
int16ToIntCompat# = int16ToInt#

int32ToIntCompat# :: Int32# -> Int#
int32ToIntCompat# = int32ToInt#

word8ToWordCompat# :: Word8# -> Word#
word8ToWordCompat# = word8ToWord#

word16ToWordCompat# :: Word16# -> Word#
word16ToWordCompat# = word16ToWord#

word32ToWordCompat# :: Word32# -> Word#
word32ToWordCompat# = word32ToWord#

intToInt8Compat# :: Int# -> Int8#
intToInt8Compat# = intToInt8#

intToInt16Compat# :: Int# -> Int16#
intToInt16Compat# = intToInt16#

intToInt32Compat# :: Int# -> Int32#
intToInt32Compat# = intToInt32#

wordToWord8Compat# :: Word# -> Word8#
wordToWord8Compat# = wordToWord8#

wordToWord16Compat# :: Word# -> Word16#
wordToWord16Compat# = wordToWord16#

wordToWord32Compat# :: Word# -> Word32#
wordToWord32Compat# = wordToWord32#

--

narrow8IntCompat# :: Int# -> Int8#
narrow8IntCompat# = intToInt8#

narrow16IntCompat# :: Int# -> Int16#
narrow16IntCompat# = intToInt16#

narrow32IntCompat# :: Int# -> Int32#
narrow32IntCompat# = intToInt32#

narrow8WordCompat# :: Word# -> Word8#
narrow8WordCompat# = wordToWord8#

narrow16WordCompat# :: Word# -> Word16#
narrow16WordCompat# = wordToWord16#

narrow32WordCompat# :: Word# -> Word32#
narrow32WordCompat# = wordToWord32#
#else
-- No-ops
int8ToIntCompat# :: Int# -> Int#
int8ToIntCompat# :: Int# -> Int#
int8ToIntCompat# Int#
x = Int#
x

int16ToIntCompat# :: Int# -> Int#
int16ToIntCompat# :: Int# -> Int#
int16ToIntCompat# Int#
x = Int#
x

int32ToIntCompat# :: Int# -> Int#
int32ToIntCompat# :: Int# -> Int#
int32ToIntCompat# Int#
x = Int#
x

word8ToWordCompat# :: Word# -> Word#
word8ToWordCompat# :: Word# -> Word#
word8ToWordCompat# Word#
x = Word#
x

word16ToWordCompat# :: Word# -> Word#
word16ToWordCompat# :: Word# -> Word#
word16ToWordCompat# Word#
x = Word#
x

word32ToWordCompat# :: Word# -> Word#
word32ToWordCompat# :: Word# -> Word#
word32ToWordCompat# Word#
x = Word#
x

intToInt8Compat# :: Int# -> Int#
intToInt8Compat# :: Int# -> Int#
intToInt8Compat# Int#
x = Int#
x

intToInt16Compat# :: Int# -> Int#
intToInt16Compat# :: Int# -> Int#
intToInt16Compat# Int#
x = Int#
x

intToInt32Compat# :: Int# -> Int#
intToInt32Compat# :: Int# -> Int#
intToInt32Compat# Int#
x = Int#
x

wordToWord8Compat# :: Word# -> Word#
wordToWord8Compat# :: Word# -> Word#
wordToWord8Compat# Word#
x = Word#
x

wordToWord16Compat# :: Word# -> Word#
wordToWord16Compat# :: Word# -> Word#
wordToWord16Compat# Word#
x = Word#
x

wordToWord32Compat# :: Word# -> Word#
wordToWord32Compat# :: Word# -> Word#
wordToWord32Compat# Word#
x = Word#
x

-- Actual narrowing
narrow8IntCompat# :: Int# -> Int#
narrow8IntCompat# :: Int# -> Int#
narrow8IntCompat# = Int# -> Int#
narrow8Int#

narrow16IntCompat# :: Int# -> Int#
narrow16IntCompat# :: Int# -> Int#
narrow16IntCompat# = Int# -> Int#
narrow16Int#

narrow32IntCompat# :: Int# -> Int#
narrow32IntCompat# :: Int# -> Int#
narrow32IntCompat# = Int# -> Int#
narrow32Int#

narrow8WordCompat# :: Word# -> Word#
narrow8WordCompat# :: Word# -> Word#
narrow8WordCompat# = Word# -> Word#
narrow8Word#

narrow16WordCompat# :: Word# -> Word#
narrow16WordCompat# :: Word# -> Word#
narrow16WordCompat# = Word# -> Word#
narrow16Word#

narrow32WordCompat# :: Word# -> Word#
narrow32WordCompat# :: Word# -> Word#
narrow32WordCompat# = Word# -> Word#
narrow32Word#
#endif