module Word (
	module Data.Word

        -- SUP: deprecated in the new FFI, subsumed by fromIntegral
	, intToWord8      -- :: Int     -> Word8
	, intToWord16     -- :: Int     -> Word16
	, intToWord32     -- :: Int     -> Word32
	, intToWord64     -- :: Int     -> Word64

	, integerToWord8  -- :: Integer -> Word8
	, integerToWord16 -- :: Integer -> Word16
	, integerToWord32 -- :: Integer -> Word32
	, integerToWord64 -- :: Integer -> Word64

	, word8ToInt      -- :: Word8   -> Int
        , word8ToInteger  -- :: Word8   -> Integer
	, word8ToWord16   -- :: Word8   -> Word16
	, word8ToWord32   -- :: Word8   -> Word32
	, word8ToWord64   -- :: Word8   -> Word64

	, word16ToInt     -- :: Word16  -> Int
        , word16ToInteger -- :: Word16  -> Integer
	, word16ToWord8   -- :: Word16  -> Word8
	, word16ToWord32  -- :: Word16  -> Word32
	, word16ToWord64  -- :: Word16  -> Word64

	, word32ToInt     -- :: Word32  -> Int
        , word32ToInteger -- :: Word32  -> Integer
	, word32ToWord8   -- :: Word32  -> Word8
	, word32ToWord16  -- :: Word32  -> Word16
	, word32ToWord64  -- :: Word32  -> Word64

	, word64ToInt     -- :: Word64  -> Int
        , word64ToInteger -- :: Word64  -> Integer
	, word64ToWord8   -- :: Word64  -> Word8
	, word64ToWord16  -- :: Word64  -> Word16
	, word64ToWord32  -- :: Word64  -> Word32

	-- NB! GHC SPECIFIC:
 	, wordToWord8     -- :: Word    -> Word8
	, wordToWord16    -- :: Word    -> Word16
	, wordToWord32    -- :: Word    -> Word32
	, wordToWord64    -- :: Word    -> Word64

	, word8ToWord     -- :: Word8   -> Word
	, word16ToWord    -- :: Word16  -> Word
	, word32ToWord    -- :: Word32  -> Word
	, word64ToWord    -- :: Word64  -> Word

	-- The "official" place to get these from is Addr.
        -- SUP: deprecated in the new FFI, subsumed by the Storable class
	, indexWord8OffAddr
	, indexWord16OffAddr
	, indexWord32OffAddr
	, indexWord64OffAddr
	
	, readWord8OffAddr
	, readWord16OffAddr
	, readWord32OffAddr
	, readWord64OffAddr
	
	, writeWord8OffAddr
	, writeWord16OffAddr
	, writeWord32OffAddr
	, writeWord64OffAddr
	
        -- SUP: deprecated in the new FFI, subsumed by the Storable class
	, sizeofWord8
	, sizeofWord16
	, sizeofWord32
	, sizeofWord64
  ) where

import Data.Word
import Addr

{-# DEPRECATED intToWord8      "use fromIntegral instead" #-}
{-# DEPRECATED intToWord16     "use fromIntegral instead" #-}
{-# DEPRECATED intToWord32     "use fromIntegral instead" #-}
{-# DEPRECATED intToWord64     "use fromIntegral instead" #-}

{-# DEPRECATED integerToWord8  "use fromIntegral instead" #-}
{-# DEPRECATED integerToWord16 "use fromIntegral instead" #-}
{-# DEPRECATED integerToWord32 "use fromIntegral instead" #-}
{-# DEPRECATED integerToWord64 "use fromIntegral instead" #-}

{-# DEPRECATED word8ToInt      "use fromIntegral instead" #-}
{-# DEPRECATED word8ToInteger  "use fromIntegral instead" #-}
{-# DEPRECATED word8ToWord16   "use fromIntegral instead" #-}
{-# DEPRECATED word8ToWord32   "use fromIntegral instead" #-}
{-# DEPRECATED word8ToWord64   "use fromIntegral instead" #-}

{-# DEPRECATED word16ToInt     "use fromIntegral instead" #-}
{-# DEPRECATED word16ToInteger "use fromIntegral instead" #-}
{-# DEPRECATED word16ToWord8   "use fromIntegral instead" #-}
{-# DEPRECATED word16ToWord32  "use fromIntegral instead" #-}
{-# DEPRECATED word16ToWord64  "use fromIntegral instead" #-}

{-# DEPRECATED word32ToInt     "use fromIntegral instead" #-}
{-# DEPRECATED word32ToInteger "use fromIntegral instead" #-}
{-# DEPRECATED word32ToWord8   "use fromIntegral instead" #-}
{-# DEPRECATED word32ToWord16  "use fromIntegral instead" #-}
{-# DEPRECATED word32ToWord64  "use fromIntegral instead" #-}

{-# DEPRECATED word64ToInt     "use fromIntegral instead" #-}
{-# DEPRECATED word64ToInteger "use fromIntegral instead" #-}
{-# DEPRECATED word64ToWord8   "use fromIntegral instead" #-}
{-# DEPRECATED word64ToWord16  "use fromIntegral instead" #-}
{-# DEPRECATED word64ToWord32  "use fromIntegral instead" #-}

{-# DEPRECATED wordToWord8     "use fromIntegral instead" #-}
{-# DEPRECATED wordToWord16    "use fromIntegral instead" #-}
{-# DEPRECATED wordToWord32    "use fromIntegral instead" #-}
{-# DEPRECATED wordToWord64    "use fromIntegral instead" #-}

{-# DEPRECATED word8ToWord     "use fromIntegral instead" #-}
{-# DEPRECATED word16ToWord    "use fromIntegral instead" #-}
{-# DEPRECATED word32ToWord    "use fromIntegral instead" #-}
{-# DEPRECATED word64ToWord    "use fromIntegral instead" #-}

intToWord8      :: Int     -> Word8
intToWord16     :: Int     -> Word16
intToWord32     :: Int     -> Word32
intToWord64     :: Int     -> Word64

integerToWord8  :: Integer -> Word8
integerToWord16 :: Integer -> Word16
integerToWord32 :: Integer -> Word32
integerToWord64 :: Integer -> Word64

word8ToInt      :: Word8   -> Int
word8ToInteger  :: Word8   -> Integer
word8ToWord16   :: Word8   -> Word16
word8ToWord32   :: Word8   -> Word32
word8ToWord64   :: Word8   -> Word64

word16ToInt     :: Word16  -> Int
word16ToInteger :: Word16  -> Integer
word16ToWord8   :: Word16  -> Word8
word16ToWord32  :: Word16  -> Word32
word16ToWord64  :: Word16  -> Word64

word32ToInt     :: Word32  -> Int
word32ToInteger :: Word32  -> Integer
word32ToWord8   :: Word32  -> Word8
word32ToWord16  :: Word32  -> Word16
word32ToWord64  :: Word32  -> Word64

word64ToInt     :: Word64  -> Int
word64ToInteger :: Word64  -> Integer
word64ToWord8   :: Word64  -> Word8
word64ToWord16  :: Word64  -> Word16
word64ToWord32  :: Word64  -> Word32

wordToWord8     :: Word    -> Word8
wordToWord16    :: Word    -> Word16
wordToWord32    :: Word    -> Word32
wordToWord64    :: Word    -> Word64

word8ToWord     :: Word8   -> Word
word16ToWord    :: Word16  -> Word
word32ToWord    :: Word32  -> Word
word64ToWord    :: Word64  -> Word

intToWord8      = fromIntegral
intToWord16     = fromIntegral
intToWord32     = fromIntegral
intToWord64     = fromIntegral

integerToWord8  = fromIntegral
integerToWord16 = fromIntegral
integerToWord32 = fromIntegral
integerToWord64 = fromIntegral

word8ToInt      = fromIntegral
word8ToInteger  = fromIntegral
word8ToWord16   = fromIntegral
word8ToWord32   = fromIntegral
word8ToWord64   = fromIntegral

word16ToInt     = fromIntegral
word16ToInteger = fromIntegral
word16ToWord8   = fromIntegral
word16ToWord32  = fromIntegral
word16ToWord64  = fromIntegral

word32ToInt     = fromIntegral
word32ToInteger = fromIntegral
word32ToWord8   = fromIntegral
word32ToWord16  = fromIntegral
word32ToWord64  = fromIntegral

word64ToInt     = fromIntegral
word64ToInteger = fromIntegral
word64ToWord8   = fromIntegral
word64ToWord16  = fromIntegral
word64ToWord32  = fromIntegral

wordToWord8     = fromIntegral
wordToWord16    = fromIntegral
wordToWord32    = fromIntegral
wordToWord64    = fromIntegral

word8ToWord     = fromIntegral
word16ToWord    = fromIntegral
word32ToWord    = fromIntegral
word64ToWord    = fromIntegral

{-# DEPRECATED sizeofWord8 "use Storable.sizeOf instead" #-}
sizeofWord8 :: Word32
sizeofWord8 = 1

{-# DEPRECATED sizeofWord16 "use Storable.sizeOf instead" #-}
sizeofWord16 :: Word32
sizeofWord16 = 2

{-# DEPRECATED sizeofWord32 "use Storable.sizeOf instead" #-}
sizeofWord32 :: Word32
sizeofWord32 = 4

{-# DEPRECATED sizeofWord64 "use Storable.sizeOf instead" #-}
sizeofWord64 :: Word32
sizeofWord64 = 8
