base-4.9.1.0: Basic libraries

Data.Int

Contents

Description

Signed integer types

Synopsis

# Signed integer types

data Int :: * Source #

A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]. The exact range for a given implementation can be determined by using minBound and maxBound from the Bounded class.

Instances

 # Methods # Methodssucc :: Int -> Int #pred :: Int -> Int #toEnum :: Int -> Int #fromEnum :: Int -> Int #enumFrom :: Int -> [Int] #enumFromThen :: Int -> Int -> [Int] #enumFromTo :: Int -> Int -> [Int] #enumFromThenTo :: Int -> Int -> Int -> [Int] # Methods(==) :: Int -> Int -> Bool Source #(/=) :: Int -> Int -> Bool Source # # Methodsquot :: Int -> Int -> Int #rem :: Int -> Int -> Int #div :: Int -> Int -> Int #mod :: Int -> Int -> Int #quotRem :: Int -> Int -> (Int, Int) #divMod :: Int -> Int -> (Int, Int) # # Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int -> c Int #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int #dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Int) #dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int) #gmapT :: (forall b. Data b => b -> b) -> Int -> Int #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r #gmapQ :: (forall d. Data d => d -> u) -> Int -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Int -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int -> m Int #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int # # Methods(+) :: Int -> Int -> Int #(-) :: Int -> Int -> Int #(*) :: Int -> Int -> Int #negate :: Int -> Int #abs :: Int -> Int #signum :: Int -> Int # Methods(<) :: Int -> Int -> Bool Source #(<=) :: Int -> Int -> Bool Source #(>) :: Int -> Int -> Bool Source #(>=) :: Int -> Int -> Bool Source #max :: Int -> Int -> Int Source #min :: Int -> Int -> Int Source # # Methods # Methods # MethodsshowsPrec :: Int -> Int -> ShowS #show :: Int -> String #showList :: [Int] -> ShowS # # Methodsrange :: (Int, Int) -> [Int] #index :: (Int, Int) -> Int -> Int #unsafeIndex :: (Int, Int) -> Int -> IntinRange :: (Int, Int) -> Int -> Bool #rangeSize :: (Int, Int) -> Int #unsafeRangeSize :: (Int, Int) -> Int # Methods # Methods(.&.) :: Int -> Int -> Int #(.|.) :: Int -> Int -> Int #xor :: Int -> Int -> Int #shift :: Int -> Int -> Int #rotate :: Int -> Int -> Int #bit :: Int -> Int #setBit :: Int -> Int -> Int #clearBit :: Int -> Int -> Int #complementBit :: Int -> Int -> Int #testBit :: Int -> Int -> Bool #bitSize :: Int -> Int #isSigned :: Int -> Bool #shiftL :: Int -> Int -> Int #unsafeShiftL :: Int -> Int -> Int #shiftR :: Int -> Int -> Int #unsafeShiftR :: Int -> Int -> Int #rotateL :: Int -> Int -> Int #rotateR :: Int -> Int -> Int #popCount :: Int -> Int # # MethodssizeOf :: Int -> Int #alignment :: Int -> Int #pokeElemOff :: Ptr Int -> Int -> Int -> IO () #peekByteOff :: Ptr b -> Int -> IO Int #pokeByteOff :: Ptr b -> Int -> Int -> IO () #peek :: Ptr Int -> IO Int #poke :: Ptr Int -> Int -> IO () # # Methods # Methodsfmap :: (a -> b) -> URec Int a -> URec Int b #(<\$) :: a -> URec Int b -> URec Int a # # Methodsfold :: Monoid m => URec Int m -> m #foldMap :: Monoid m => (a -> m) -> URec Int a -> m #foldr :: (a -> b -> b) -> b -> URec Int a -> b #foldr' :: (a -> b -> b) -> b -> URec Int a -> b #foldl :: (b -> a -> b) -> b -> URec Int a -> b #foldl' :: (b -> a -> b) -> b -> URec Int a -> b #foldr1 :: (a -> a -> a) -> URec Int a -> a #foldl1 :: (a -> a -> a) -> URec Int a -> a #toList :: URec Int a -> [a] #null :: URec Int a -> Bool #length :: URec Int a -> Int #elem :: Eq a => a -> URec Int a -> Bool #maximum :: Ord a => URec Int a -> a #minimum :: Ord a => URec Int a -> a #sum :: Num a => URec Int a -> a #product :: Num a => URec Int a -> a # # Methodstraverse :: Applicative f => (a -> f b) -> URec Int a -> f (URec Int b) #sequenceA :: Applicative f => URec Int (f a) -> f (URec Int a) #mapM :: Monad m => (a -> m b) -> URec Int a -> m (URec Int b) #sequence :: Monad m => URec Int (m a) -> m (URec Int a) # # Associated Typestype Rep1 (URec Int :: * -> *) :: * -> * # Methodsfrom1 :: URec Int a -> Rep1 (URec Int) a #to1 :: Rep1 (URec Int) a -> URec Int a # Eq (URec Int p) # Methods(==) :: URec Int p -> URec Int p -> Bool Source #(/=) :: URec Int p -> URec Int p -> Bool Source # Ord (URec Int p) # Methodscompare :: URec Int p -> URec Int p -> Ordering Source #(<) :: URec Int p -> URec Int p -> Bool Source #(<=) :: URec Int p -> URec Int p -> Bool Source #(>) :: URec Int p -> URec Int p -> Bool Source #(>=) :: URec Int p -> URec Int p -> Bool Source #max :: URec Int p -> URec Int p -> URec Int p Source #min :: URec Int p -> URec Int p -> URec Int p Source # Show (URec Int p) # MethodsshowsPrec :: Int -> URec Int p -> ShowS #show :: URec Int p -> String #showList :: [URec Int p] -> ShowS # # Associated Typestype Rep (URec Int p) :: * -> * # Methodsfrom :: URec Int p -> Rep (URec Int p) x #to :: Rep (URec Int p) x -> URec Int p # data URec Int # Used for marking occurrences of Int# data URec Int = UInt {uInt# :: Int#} type Rep1 (URec Int) # type Rep1 (URec Int) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UInt" PrefixI True) (S1 (MetaSel (Just Symbol "uInt#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UInt)) type Rep (URec Int p) # type Rep (URec Int p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UInt" PrefixI True) (S1 (MetaSel (Just Symbol "uInt#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UInt))

data Int8 #

8-bit signed integer type

Instances

 # Methods # Methodssucc :: Int8 -> Int8 #pred :: Int8 -> Int8 #toEnum :: Int -> Int8 #fromEnum :: Int8 -> Int #enumFrom :: Int8 -> [Int8] #enumFromThen :: Int8 -> Int8 -> [Int8] #enumFromTo :: Int8 -> Int8 -> [Int8] #enumFromThenTo :: Int8 -> Int8 -> Int8 -> [Int8] # # Methods(==) :: Int8 -> Int8 -> Bool Source #(/=) :: Int8 -> Int8 -> Bool Source # # Methodsquot :: Int8 -> Int8 -> Int8 #rem :: Int8 -> Int8 -> Int8 #div :: Int8 -> Int8 -> Int8 #mod :: Int8 -> Int8 -> Int8 #quotRem :: Int8 -> Int8 -> (Int8, Int8) #divMod :: Int8 -> Int8 -> (Int8, Int8) # # Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int8 -> c Int8 #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int8 #dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Int8) #dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int8) #gmapT :: (forall b. Data b => b -> b) -> Int8 -> Int8 #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int8 -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int8 -> r #gmapQ :: (forall d. Data d => d -> u) -> Int8 -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Int8 -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 # # Methods(+) :: Int8 -> Int8 -> Int8 #(-) :: Int8 -> Int8 -> Int8 #(*) :: Int8 -> Int8 -> Int8 #negate :: Int8 -> Int8 #abs :: Int8 -> Int8 #signum :: Int8 -> Int8 # # Methods(<) :: Int8 -> Int8 -> Bool Source #(<=) :: Int8 -> Int8 -> Bool Source #(>) :: Int8 -> Int8 -> Bool Source #(>=) :: Int8 -> Int8 -> Bool Source #max :: Int8 -> Int8 -> Int8 Source #min :: Int8 -> Int8 -> Int8 Source # # Methods # Methods # MethodsshowsPrec :: Int -> Int8 -> ShowS #show :: Int8 -> String #showList :: [Int8] -> ShowS # # Methodsrange :: (Int8, Int8) -> [Int8] #index :: (Int8, Int8) -> Int8 -> Int #unsafeIndex :: (Int8, Int8) -> Int8 -> IntinRange :: (Int8, Int8) -> Int8 -> Bool #rangeSize :: (Int8, Int8) -> Int #unsafeRangeSize :: (Int8, Int8) -> Int # Methods # Methods(.&.) :: Int8 -> Int8 -> Int8 #(.|.) :: Int8 -> Int8 -> Int8 #xor :: Int8 -> Int8 -> Int8 #shift :: Int8 -> Int -> Int8 #rotate :: Int8 -> Int -> Int8 #bit :: Int -> Int8 #setBit :: Int8 -> Int -> Int8 #clearBit :: Int8 -> Int -> Int8 #testBit :: Int8 -> Int -> Bool #bitSize :: Int8 -> Int #shiftL :: Int8 -> Int -> Int8 #unsafeShiftL :: Int8 -> Int -> Int8 #shiftR :: Int8 -> Int -> Int8 #unsafeShiftR :: Int8 -> Int -> Int8 #rotateL :: Int8 -> Int -> Int8 #rotateR :: Int8 -> Int -> Int8 #popCount :: Int8 -> Int # # MethodssizeOf :: Int8 -> Int #pokeElemOff :: Ptr Int8 -> Int -> Int8 -> IO () #peekByteOff :: Ptr b -> Int -> IO Int8 #pokeByteOff :: Ptr b -> Int -> Int8 -> IO () #poke :: Ptr Int8 -> Int8 -> IO () # # Methods

data Int16 #

16-bit signed integer type

Instances

 # Methods # Methodssucc :: Int16 -> Int16 #pred :: Int16 -> Int16 #toEnum :: Int -> Int16 #enumFrom :: Int16 -> [Int16] #enumFromThen :: Int16 -> Int16 -> [Int16] #enumFromTo :: Int16 -> Int16 -> [Int16] #enumFromThenTo :: Int16 -> Int16 -> Int16 -> [Int16] # # Methods # Methodsquot :: Int16 -> Int16 -> Int16 #rem :: Int16 -> Int16 -> Int16 #div :: Int16 -> Int16 -> Int16 #mod :: Int16 -> Int16 -> Int16 #quotRem :: Int16 -> Int16 -> (Int16, Int16) #divMod :: Int16 -> Int16 -> (Int16, Int16) # # Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int16 -> c Int16 #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int16 #dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Int16) #dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int16) #gmapT :: (forall b. Data b => b -> b) -> Int16 -> Int16 #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int16 -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int16 -> r #gmapQ :: (forall d. Data d => d -> u) -> Int16 -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Int16 -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 # # Methods(+) :: Int16 -> Int16 -> Int16 #(-) :: Int16 -> Int16 -> Int16 #(*) :: Int16 -> Int16 -> Int16 #abs :: Int16 -> Int16 # # Methods(<) :: Int16 -> Int16 -> Bool Source #(>) :: Int16 -> Int16 -> Bool Source # # Methods # Methods # MethodsshowsPrec :: Int -> Int16 -> ShowS #show :: Int16 -> String #showList :: [Int16] -> ShowS # # Methodsrange :: (Int16, Int16) -> [Int16] #index :: (Int16, Int16) -> Int16 -> Int #unsafeIndex :: (Int16, Int16) -> Int16 -> IntinRange :: (Int16, Int16) -> Int16 -> Bool #rangeSize :: (Int16, Int16) -> Int #unsafeRangeSize :: (Int16, Int16) -> Int # Methods # Methods(.&.) :: Int16 -> Int16 -> Int16 #(.|.) :: Int16 -> Int16 -> Int16 #xor :: Int16 -> Int16 -> Int16 #shift :: Int16 -> Int -> Int16 #rotate :: Int16 -> Int -> Int16 #bit :: Int -> Int16 #setBit :: Int16 -> Int -> Int16 #clearBit :: Int16 -> Int -> Int16 #testBit :: Int16 -> Int -> Bool #bitSize :: Int16 -> Int #shiftL :: Int16 -> Int -> Int16 #shiftR :: Int16 -> Int -> Int16 #rotateL :: Int16 -> Int -> Int16 #rotateR :: Int16 -> Int -> Int16 # # MethodssizeOf :: Int16 -> Int #pokeElemOff :: Ptr Int16 -> Int -> Int16 -> IO () #peekByteOff :: Ptr b -> Int -> IO Int16 #pokeByteOff :: Ptr b -> Int -> Int16 -> IO () #poke :: Ptr Int16 -> Int16 -> IO () # # Methods

data Int32 #

32-bit signed integer type

Instances

 # Methods # Methodssucc :: Int32 -> Int32 #pred :: Int32 -> Int32 #toEnum :: Int -> Int32 #enumFrom :: Int32 -> [Int32] #enumFromThen :: Int32 -> Int32 -> [Int32] #enumFromTo :: Int32 -> Int32 -> [Int32] #enumFromThenTo :: Int32 -> Int32 -> Int32 -> [Int32] # # Methods # Methodsquot :: Int32 -> Int32 -> Int32 #rem :: Int32 -> Int32 -> Int32 #div :: Int32 -> Int32 -> Int32 #mod :: Int32 -> Int32 -> Int32 #quotRem :: Int32 -> Int32 -> (Int32, Int32) #divMod :: Int32 -> Int32 -> (Int32, Int32) # # Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int32 -> c Int32 #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int32 #dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Int32) #dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int32) #gmapT :: (forall b. Data b => b -> b) -> Int32 -> Int32 #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int32 -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int32 -> r #gmapQ :: (forall d. Data d => d -> u) -> Int32 -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Int32 -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 # # Methods(+) :: Int32 -> Int32 -> Int32 #(-) :: Int32 -> Int32 -> Int32 #(*) :: Int32 -> Int32 -> Int32 #abs :: Int32 -> Int32 # # Methods(<) :: Int32 -> Int32 -> Bool Source #(>) :: Int32 -> Int32 -> Bool Source # # Methods # Methods # MethodsshowsPrec :: Int -> Int32 -> ShowS #show :: Int32 -> String #showList :: [Int32] -> ShowS # # Methodsrange :: (Int32, Int32) -> [Int32] #index :: (Int32, Int32) -> Int32 -> Int #unsafeIndex :: (Int32, Int32) -> Int32 -> IntinRange :: (Int32, Int32) -> Int32 -> Bool #rangeSize :: (Int32, Int32) -> Int #unsafeRangeSize :: (Int32, Int32) -> Int # Methods # Methods(.&.) :: Int32 -> Int32 -> Int32 #(.|.) :: Int32 -> Int32 -> Int32 #xor :: Int32 -> Int32 -> Int32 #shift :: Int32 -> Int -> Int32 #rotate :: Int32 -> Int -> Int32 #bit :: Int -> Int32 #setBit :: Int32 -> Int -> Int32 #clearBit :: Int32 -> Int -> Int32 #testBit :: Int32 -> Int -> Bool #bitSize :: Int32 -> Int #shiftL :: Int32 -> Int -> Int32 #shiftR :: Int32 -> Int -> Int32 #rotateL :: Int32 -> Int -> Int32 #rotateR :: Int32 -> Int -> Int32 # # MethodssizeOf :: Int32 -> Int #pokeElemOff :: Ptr Int32 -> Int -> Int32 -> IO () #peekByteOff :: Ptr b -> Int -> IO Int32 #pokeByteOff :: Ptr b -> Int -> Int32 -> IO () #poke :: Ptr Int32 -> Int32 -> IO () # # Methods

data Int64 #

64-bit signed integer type

Instances

 # Methods # Methodssucc :: Int64 -> Int64 #pred :: Int64 -> Int64 #toEnum :: Int -> Int64 #enumFrom :: Int64 -> [Int64] #enumFromThen :: Int64 -> Int64 -> [Int64] #enumFromTo :: Int64 -> Int64 -> [Int64] #enumFromThenTo :: Int64 -> Int64 -> Int64 -> [Int64] # # Methods # Methodsquot :: Int64 -> Int64 -> Int64 #rem :: Int64 -> Int64 -> Int64 #div :: Int64 -> Int64 -> Int64 #mod :: Int64 -> Int64 -> Int64 #quotRem :: Int64 -> Int64 -> (Int64, Int64) #divMod :: Int64 -> Int64 -> (Int64, Int64) # # Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int64 -> c Int64 #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int64 #dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Int64) #dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int64) #gmapT :: (forall b. Data b => b -> b) -> Int64 -> Int64 #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r #gmapQ :: (forall d. Data d => d -> u) -> Int64 -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Int64 -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 # # Methods(+) :: Int64 -> Int64 -> Int64 #(-) :: Int64 -> Int64 -> Int64 #(*) :: Int64 -> Int64 -> Int64 #abs :: Int64 -> Int64 # # Methods(<) :: Int64 -> Int64 -> Bool Source #(>) :: Int64 -> Int64 -> Bool Source # # Methods # Methods # MethodsshowsPrec :: Int -> Int64 -> ShowS #show :: Int64 -> String #showList :: [Int64] -> ShowS # # Methodsrange :: (Int64, Int64) -> [Int64] #index :: (Int64, Int64) -> Int64 -> Int #unsafeIndex :: (Int64, Int64) -> Int64 -> IntinRange :: (Int64, Int64) -> Int64 -> Bool #rangeSize :: (Int64, Int64) -> Int #unsafeRangeSize :: (Int64, Int64) -> Int # Methods # Methods(.&.) :: Int64 -> Int64 -> Int64 #(.|.) :: Int64 -> Int64 -> Int64 #xor :: Int64 -> Int64 -> Int64 #shift :: Int64 -> Int -> Int64 #rotate :: Int64 -> Int -> Int64 #bit :: Int -> Int64 #setBit :: Int64 -> Int -> Int64 #clearBit :: Int64 -> Int -> Int64 #testBit :: Int64 -> Int -> Bool #bitSize :: Int64 -> Int #shiftL :: Int64 -> Int -> Int64 #shiftR :: Int64 -> Int -> Int64 #rotateL :: Int64 -> Int -> Int64 #rotateR :: Int64 -> Int -> Int64 # # MethodssizeOf :: Int64 -> Int #pokeElemOff :: Ptr Int64 -> Int -> Int64 -> IO () #peekByteOff :: Ptr b -> Int -> IO Int64 #pokeByteOff :: Ptr b -> Int -> Int64 -> IO () #poke :: Ptr Int64 -> Int64 -> IO () # # Methods

# Notes

• All arithmetic is performed modulo 2^n, where n is the number of bits in the type.
• For coercing between any two integer types, use fromIntegral, which is specialized for all the common cases so should be fast enough. Coercing word types (see Data.Word) to and from integer types preserves representation, not sign.
• The rules that hold for Enum instances over a bounded type such as Int (see the section of the Haskell report dealing with arithmetic sequences) also hold for the Enum instances over the various Int types defined here.
• Right and left shifts by amounts greater than or equal to the width of the type result in either zero or -1, depending on the sign of the value being shifted. This is contrary to the behaviour in C, which is undefined; a common interpretation is to truncate the shift count to the width of the type, for example 1 << 32 == 1 in some C implementations.