4.18. Int

This interface provides a collection of sized, signed integers. The types supported are as follows:

type number of bits
Int8 8
Int16 16
Int32 32
Int64 64

For each type I above, we provide the following instances.

data I            -- Signed Ints
instance Eq       I
instance Ord      I
instance Show     I
instance Read     I
instance Bounded  I
instance Num      I
instance Real     I
instance Integral I
instance Enum     I
instance Ix       I
instance Bits     I

4.18.1. Notes

4.18.2. Deprecated Functions

The following functions are deprecated in the new FFI. Do not use the following functions if you are interested in portability. Most of these functions are here for legacy reasons and may just vanish one day. You have been warned.

The Int module also exports the overloaded operations for converting to and from Haskell Ints. However, for coercing between various integer types, better use fromIntegral, which is specialized for all the common cases so should be fast enough.

toInt   :: (Integral a) => a -> Int
fromInt :: (Num a) => Int -> a

Portability note: both Hugs98 and all releases of GHC prior to ghc-4.05 also exports these two via the Prelude. So, to have code that uses toInt and fromInt be maximally portable, make sure you add an import on Int (even if the version of Hugs or GHC you're currently using may not export these two from there.)