base-4.22.0.0: Core data structures and operations
Safe HaskellNone
LanguageHaskell2010

GHC.Integer

Description

Compatibility module for pre-ghc-bignum code.

Synopsis

Documentation

data Integer Source #

Arbitrary precision integers. In contrast with fixed-size integral types such as Int, the Integer type represents the entire infinite range of integers.

Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.

If the value is small (i.e., fits into an Int), the IS constructor is used. Otherwise IP and IN constructors are used to store a BigNat representing the positive or the negative value magnitude, respectively.

Invariant: IP and IN are used iff the value does not fit in IS.

Instances

Instances details
PrintfArg Integer Source #

Since: base-2.1

Instance details

Defined in Text.Printf

Bits Integer Source #

Since: base-2.1

Instance details

Defined in GHC.Internal.Bits

Methods

(.&.) :: Integer -> Integer -> Integer Source #

(.|.) :: Integer -> Integer -> Integer Source #

xor :: Integer -> Integer -> Integer Source #

complement :: Integer -> Integer Source #

shift :: Integer -> Int -> Integer Source #

rotate :: Integer -> Int -> Integer Source #

zeroBits :: Integer Source #

bit :: Int -> Integer Source #

setBit :: Integer -> Int -> Integer Source #

clearBit :: Integer -> Int -> Integer Source #

complementBit :: Integer -> Int -> Integer Source #

testBit :: Integer -> Int -> Bool Source #

bitSizeMaybe :: Integer -> Maybe Int Source #

bitSize :: Integer -> Int Source #

isSigned :: Integer -> Bool Source #

shiftL :: Integer -> Int -> Integer Source #

unsafeShiftL :: Integer -> Int -> Integer Source #

shiftR :: Integer -> Int -> Integer Source #

unsafeShiftR :: Integer -> Int -> Integer Source #

rotateL :: Integer -> Int -> Integer Source #

rotateR :: Integer -> Int -> Integer Source #

popCount :: Integer -> Int Source #

Eq Integer Source # 
Instance details

Defined in GHC.Internal.Bignum.Integer

Methods

(==) :: Integer -> Integer -> Bool Source #

(/=) :: Integer -> Integer -> Bool Source #

Ord Integer Source # 
Instance details

Defined in GHC.Internal.Bignum.Integer

Methods

compare :: Integer -> Integer -> Ordering Source #

(<) :: Integer -> Integer -> Bool Source #

(<=) :: Integer -> Integer -> Bool Source #

(>) :: Integer -> Integer -> Bool Source #

(>=) :: Integer -> Integer -> Bool Source #

max :: Integer -> Integer -> Integer Source #

min :: Integer -> Integer -> Integer Source #

Data Integer Source #

Since: base-4.0.0.0

Instance details

Defined in GHC.Internal.Data.Data

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Integer -> c Integer Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Integer Source #

toConstr :: Integer -> Constr Source #

dataTypeOf :: Integer -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Integer) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Integer) Source #

gmapT :: (forall b. Data b => b -> b) -> Integer -> Integer Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Integer -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Integer -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Integer -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Integer -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source #

Enum Integer Source #

Since: base-2.1

Instance details

Defined in GHC.Internal.Enum

Methods

succ :: Integer -> Integer Source #

pred :: Integer -> Integer Source #

toEnum :: Int -> Integer Source #

fromEnum :: Integer -> Int Source #

enumFrom :: Integer -> [Integer] Source #

enumFromThen :: Integer -> Integer -> [Integer] Source #

enumFromTo :: Integer -> Integer -> [Integer] Source #

enumFromThenTo :: Integer -> Integer -> Integer -> [Integer] Source #

Ix Integer Source #

Since: base-2.1

Instance details

Defined in GHC.Internal.Ix

Methods

range :: (Integer, Integer) -> [Integer] Source #

index :: (Integer, Integer) -> Integer -> Int Source #

unsafeIndex :: (Integer, Integer) -> Integer -> Int Source #

inRange :: (Integer, Integer) -> Integer -> Bool Source #

rangeSize :: (Integer, Integer) -> Int Source #

unsafeRangeSize :: (Integer, Integer) -> Int Source #

Num Integer Source #

Since: base-2.1

Instance details

Defined in GHC.Internal.Num

Methods

(+) :: Integer -> Integer -> Integer Source #

(-) :: Integer -> Integer -> Integer Source #

(*) :: Integer -> Integer -> Integer Source #

negate :: Integer -> Integer Source #

abs :: Integer -> Integer Source #

signum :: Integer -> Integer Source #

fromInteger :: Integer -> Integer Source #

Read Integer Source #

Since: base-2.1

Instance details

Defined in GHC.Internal.Read

Methods

readsPrec :: Int -> ReadS Integer Source #

readList :: ReadS [Integer] Source #

readPrec :: ReadPrec Integer Source #

readListPrec :: ReadPrec [Integer] Source #

Integral Integer Source #

Since: base-2.0.1

Instance details

Defined in GHC.Internal.Real

Methods

quot :: Integer -> Integer -> Integer Source #

rem :: Integer -> Integer -> Integer Source #

div :: Integer -> Integer -> Integer Source #

mod :: Integer -> Integer -> Integer Source #

quotRem :: Integer -> Integer -> (Integer, Integer) Source #

divMod :: Integer -> Integer -> (Integer, Integer) Source #

toInteger :: Integer -> Integer Source #

Real Integer Source #

Since: base-2.0.1

Instance details

Defined in GHC.Internal.Real

Methods

toRational :: Integer -> Rational Source #

Show Integer Source #

Since: base-2.1

Instance details

Defined in GHC.Internal.Show

Methods

showsPrec :: Int -> Integer -> ShowS Source #

show :: Integer -> String Source #

showList :: [Integer] -> ShowS Source #

Lift Integer Source # 
Instance details

Defined in GHC.Internal.TH.Lift

Methods

lift :: Quote m => Integer -> m Exp Source #

liftTyped :: forall (m :: Type -> Type). Quote m => Integer -> Code m Integer Source #

Construct Integers

smallInteger :: Int# -> Integer Source #

Conversion to other integral types

integerToInt :: Integer -> Int# Source #

Helpers for RealFloat type-class operations

Arithmetic operations

plusInteger :: Integer -> Integer -> Integer Source #

Used to implement (+) for the Num typeclass. This gives the sum of two integers.

Example

Expand
>>> plusInteger 3 2
5
>>> (+) 3 2
5

minusInteger :: Integer -> Integer -> Integer Source #

Used to implement (-) for the Num typeclass. This gives the difference of two integers.

Example

Expand
>>> minusInteger 3 2
1
>>> (-) 3 2
1

timesInteger :: Integer -> Integer -> Integer Source #

Used to implement (*) for the Num typeclass. This gives the product of two integers.

Example

Expand
>>> timesInteger 3 2
6
>>> (*) 3 2
6

negateInteger :: Integer -> Integer Source #

Used to implement negate for the Num typeclass. This changes the sign of whatever integer is passed into it.

Example

Expand
>>> negateInteger (-6)
6
>>> negate (-6)
6

absInteger :: Integer -> Integer Source #

Used to implement abs for the Num typeclass. This gives the absolute value of whatever integer is passed into it.

Example

Expand
>>> absInteger (-6)
6
>>> abs (-6)
6

signumInteger :: Integer -> Integer Source #

Used to implement signum for the Num typeclass. This gives 1 for a positive integer, and -1 for a negative integer.

Example

Expand
>>> signumInteger 5
1
>>> signum 5
1

divModInteger :: Integer -> Integer -> (# Integer, Integer #) Source #

Used to implement divMod for the Integral typeclass. This gives a tuple equivalent to

(div x y, mod x y)

Example

Expand
>>> divModInteger 10 2
(5,0)
>>> divMod 10 2
(5,0)

divInteger :: Integer -> Integer -> Integer Source #

Used to implement div for the Integral typeclass. This performs integer division on its two parameters, truncated towards negative infinity.

Example

Expand
>>> 10 `divInteger` 2
5
>>> 10 `div` 2

modInteger :: Integer -> Integer -> Integer Source #

Used to implement mod for the Integral typeclass. This performs the modulo operation, satisfying

((x `div` y) * y) + (x `mod` y) == x

Example

Expand
>>> 7 `modInteger` 3
1
>>> 7 `mod` 3
1

quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) Source #

Used to implement quotRem for the Integral typeclass. This gives a tuple equivalent to

(quot x y, mod x y)

Example

Expand
>>> quotRemInteger 10 2
(5,0)
>>> quotRem 10 2
(5,0)

quotInteger :: Integer -> Integer -> Integer Source #

Used to implement quot for the Integral typeclass. This performs integer division on its two parameters, truncated towards zero.

Example

Expand
>>> quotInteger 10 2
5
>>> quot 10 2
5

remInteger :: Integer -> Integer -> Integer Source #

Used to implement rem for the Integral typeclass. This gives the remainder after integer division of its two parameters, satisfying

((x `quot` y) * y) + (x `rem` y) == x

Example

Expand
>>> remInteger 3 2
1
>>> rem 3 2
1

Comparison predicates

eqInteger :: Integer -> Integer -> Bool Source #

Used to implement (==) for the Eq typeclass. Outputs True if two integers are equal to each other.

Example

Expand
>>> 6 `eqInteger` 6
True
>>> 6 == 6
True

neqInteger :: Integer -> Integer -> Bool Source #

Used to implement (/=) for the Eq typeclass. Outputs True if two integers are not equal to each other.

Example

Expand
>>> 6 `neqInteger` 7
True
>>> 6 /= 7
True

leInteger :: Integer -> Integer -> Bool Source #

Used to implement (<=) for the Ord typeclass. Outputs True if the first argument is less than or equal to the second.

Example

Expand
>>> 3 `leInteger` 5
True
>>> 3 <= 5
True

gtInteger :: Integer -> Integer -> Bool Source #

Used to implement (>) for the Ord typeclass. Outputs True if the first argument is greater than the second.

Example

Expand
>>> 5 `gtInteger` 3
True
>>> 5 > 3
True

ltInteger :: Integer -> Integer -> Bool Source #

Used to implement (<) for the Ord typeclass. Outputs True if the first argument is less than the second.

Example

Expand
>>> 3 `ltInteger` 5
True
>>> 3 < 5
True

geInteger :: Integer -> Integer -> Bool Source #

Used to implement (>=) for the Ord typeclass. Outputs True if the first argument is greater than or equal to the second.

Example

Expand
>>> 5 `geInteger` 3
True
>>> 5 >= 3
True

compareInteger :: Integer -> Integer -> Ordering Source #

Used to implement compare for the Integral typeclass. This takes two integers, and outputs whether the first is less than, equal to, or greater than the second.

Example

Expand
>>> compareInteger 2 10
LT
>>> compare 2 10
LT

Int#-boolean valued versions of comparison predicates

These operations return 0# and 1# instead of False and True respectively. See PrimBool wiki-page for more details

eqInteger# :: Integer -> Integer -> Int# Source #

neqInteger# :: Integer -> Integer -> Int# Source #

leInteger# :: Integer -> Integer -> Int# Source #

gtInteger# :: Integer -> Integer -> Int# Source #

ltInteger# :: Integer -> Integer -> Int# Source #

geInteger# :: Integer -> Integer -> Int# Source #

Bit-operations

testBitInteger :: Integer -> Int# -> Bool Source #

bitInteger :: Int# -> Integer Source #

Hashing

hashInteger :: Integer -> Int# Source #