base-4.9.0.0: Basic libraries

Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Int

Contents

Description

Signed integer types

Synopsis

Signed integer types

data Int :: TYPE Lifted 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

Bounded Int 

Methods

minBound :: Int

maxBound :: Int

Enum Int 

Methods

succ :: 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]

Eq Int 

Methods

(==) :: Int -> Int -> Bool Source

(/=) :: Int -> Int -> Bool Source

Integral Int 

Methods

quot :: 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)

toInteger :: Int -> Integer

Data Int 

Methods

gfoldl :: (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

toConstr :: Int -> Constr

dataTypeOf :: Int -> DataType

dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int)

dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) 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

Num Int 

Methods

(+) :: Int -> Int -> Int

(-) :: Int -> Int -> Int

(*) :: Int -> Int -> Int

negate :: Int -> Int

abs :: Int -> Int

signum :: Int -> Int

fromInteger :: Integer -> Int

Ord Int 

Methods

compare :: Int -> Int -> Ordering Source

(<) :: 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

Read Int 
Real Int 

Methods

toRational :: Int -> Rational

Show Int 

Methods

showsPrec :: Int -> Int -> ShowS

show :: Int -> String

showList :: [Int] -> ShowS

Ix Int 

Methods

range :: (Int, Int) -> [Int]

index :: (Int, Int) -> Int -> Int

unsafeIndex :: (Int, Int) -> Int -> Int

inRange :: (Int, Int) -> Int -> Bool

rangeSize :: (Int, Int) -> Int

unsafeRangeSize :: (Int, Int) -> Int

FiniteBits Int 
Bits Int 

Methods

(.&.) :: Int -> Int -> Int

(.|.) :: Int -> Int -> Int

xor :: Int -> Int -> Int

complement :: Int -> Int

shift :: Int -> Int -> Int

rotate :: Int -> Int -> Int

zeroBits :: Int

bit :: Int -> Int

setBit :: Int -> Int -> Int

clearBit :: Int -> Int -> Int

complementBit :: Int -> Int -> Int

testBit :: Int -> Int -> Bool

bitSizeMaybe :: Int -> Maybe Int

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

Storable Int 

Methods

sizeOf :: Int -> Int

alignment :: Int -> Int

peekElemOff :: Ptr Int -> Int -> IO 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 ()

PrintfArg Int 
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) 

Methods

compare :: 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) 

Methods

showsPrec :: Int -> URec Int p -> ShowS

show :: URec Int p -> String

showList :: [URec Int p] -> ShowS

Generic (URec Int p) 

Associated Types

type Rep (URec Int p) :: * -> *

Methods

from :: URec Int p -> Rep (URec Int p) x

to :: Rep (URec Int p) x -> URec Int p

data URec Int = UInt {}

Used for marking occurrences of Int#

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

Bounded Int8 
Enum Int8 
Eq Int8 

Methods

(==) :: Int8 -> Int8 -> Bool Source

(/=) :: Int8 -> Int8 -> Bool Source

Integral Int8 

Methods

quot :: 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)

toInteger :: Int8 -> Integer

Data Int8 

Methods

gfoldl :: (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

toConstr :: Int8 -> Constr

dataTypeOf :: Int8 -> DataType

dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int8)

dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) 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

Num Int8 

Methods

(+) :: Int8 -> Int8 -> Int8

(-) :: Int8 -> Int8 -> Int8

(*) :: Int8 -> Int8 -> Int8

negate :: Int8 -> Int8

abs :: Int8 -> Int8

signum :: Int8 -> Int8

fromInteger :: Integer -> Int8

Ord Int8 
Read Int8 
Real Int8 

Methods

toRational :: Int8 -> Rational

Show Int8 

Methods

showsPrec :: Int -> Int8 -> ShowS

show :: Int8 -> String

showList :: [Int8] -> ShowS

Ix Int8 

Methods

range :: (Int8, Int8) -> [Int8]

index :: (Int8, Int8) -> Int8 -> Int

unsafeIndex :: (Int8, Int8) -> Int8 -> Int

inRange :: (Int8, Int8) -> Int8 -> Bool

rangeSize :: (Int8, Int8) -> Int

unsafeRangeSize :: (Int8, Int8) -> Int

FiniteBits Int8 
Bits Int8 
Storable Int8 

Methods

sizeOf :: Int8 -> Int

alignment :: Int8 -> Int

peekElemOff :: Ptr Int8 -> Int -> IO Int8

pokeElemOff :: Ptr Int8 -> Int -> Int8 -> IO ()

peekByteOff :: Ptr b -> Int -> IO Int8

pokeByteOff :: Ptr b -> Int -> Int8 -> IO ()

peek :: Ptr Int8 -> IO Int8

poke :: Ptr Int8 -> Int8 -> IO ()

PrintfArg Int8 

data Int16

16-bit signed integer type

Instances

Bounded Int16 
Enum Int16 
Eq Int16 

Methods

(==) :: Int16 -> Int16 -> Bool Source

(/=) :: Int16 -> Int16 -> Bool Source

Integral Int16 
Data Int16 

Methods

gfoldl :: (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

toConstr :: Int16 -> Constr

dataTypeOf :: Int16 -> DataType

dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int16)

dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) 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

Num Int16 
Ord Int16 
Read Int16 
Real Int16 
Show Int16 

Methods

showsPrec :: Int -> Int16 -> ShowS

show :: Int16 -> String

showList :: [Int16] -> ShowS

Ix Int16 
FiniteBits Int16 
Bits Int16 
Storable Int16 

Methods

sizeOf :: Int16 -> Int

alignment :: Int16 -> Int

peekElemOff :: Ptr Int16 -> Int -> IO Int16

pokeElemOff :: Ptr Int16 -> Int -> Int16 -> IO ()

peekByteOff :: Ptr b -> Int -> IO Int16

pokeByteOff :: Ptr b -> Int -> Int16 -> IO ()

peek :: Ptr Int16 -> IO Int16

poke :: Ptr Int16 -> Int16 -> IO ()

PrintfArg Int16 

data Int32

32-bit signed integer type

Instances

Bounded Int32 
Enum Int32 
Eq Int32 

Methods

(==) :: Int32 -> Int32 -> Bool Source

(/=) :: Int32 -> Int32 -> Bool Source

Integral Int32 
Data Int32 

Methods

gfoldl :: (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

toConstr :: Int32 -> Constr

dataTypeOf :: Int32 -> DataType

dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int32)

dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) 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

Num Int32 
Ord Int32 
Read Int32 
Real Int32 
Show Int32 

Methods

showsPrec :: Int -> Int32 -> ShowS

show :: Int32 -> String

showList :: [Int32] -> ShowS

Ix Int32 
FiniteBits Int32 
Bits Int32 
Storable Int32 

Methods

sizeOf :: Int32 -> Int

alignment :: Int32 -> Int

peekElemOff :: Ptr Int32 -> Int -> IO Int32

pokeElemOff :: Ptr Int32 -> Int -> Int32 -> IO ()

peekByteOff :: Ptr b -> Int -> IO Int32

pokeByteOff :: Ptr b -> Int -> Int32 -> IO ()

peek :: Ptr Int32 -> IO Int32

poke :: Ptr Int32 -> Int32 -> IO ()

PrintfArg Int32 

data Int64

64-bit signed integer type

Instances

Bounded Int64 
Enum Int64 
Eq Int64 

Methods

(==) :: Int64 -> Int64 -> Bool Source

(/=) :: Int64 -> Int64 -> Bool Source

Integral Int64 
Data Int64 

Methods

gfoldl :: (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

toConstr :: Int64 -> Constr

dataTypeOf :: Int64 -> DataType

dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int64)

dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) 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

Num Int64 
Ord Int64 
Read Int64 
Real Int64 
Show Int64 

Methods

showsPrec :: Int -> Int64 -> ShowS

show :: Int64 -> String

showList :: [Int64] -> ShowS

Ix Int64 
FiniteBits Int64 
Bits Int64 
Storable Int64 

Methods

sizeOf :: Int64 -> Int

alignment :: Int64 -> Int

peekElemOff :: Ptr Int64 -> Int -> IO Int64

pokeElemOff :: Ptr Int64 -> Int -> Int64 -> IO ()

peekByteOff :: Ptr b -> Int -> IO Int64

pokeByteOff :: Ptr b -> Int -> Int64 -> IO ()

peek :: Ptr Int64 -> IO Int64

poke :: Ptr Int64 -> Int64 -> IO ()

PrintfArg Int64 

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.