HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-internal-9.1003.0Haskell2010

GHC.Internal.Integer

Compatibility module for pre ghc-bignum code.

  • 1 type
  • 42 values
datadata Integer
#

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.

Instances11Enum, Eq, Integral, Data, Num, Ord, …
  • Enum IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Eq IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Integral IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Data IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Ord IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Read IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Ix IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Bits IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits

Construct Integers

2 declarations

Conversion to other integral types

2 declarations

Helpers for RealFloat type-class operations

3 declarations

Arithmetic operations

12 declarations
valueplusInteger :: Integer -> Integer -> Integer
#

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

Example
Example1 expression
plusInteger 3 25
Example1 expression
(+) 3 25

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

Example
Example1 expression
minusInteger 3 21
Example1 expression
(-) 3 21

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

Example
Example1 expression
timesInteger 3 26
Example1 expression
(*) 3 26

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

Example
Example1 expression
negateInteger (-6)6
Example1 expression
negate (-6)6
valueabsInteger :: Integer -> Integer
#

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

Example
Example1 expression
absInteger (-6)6
Example1 expression
abs (-6)6

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

Example
Example1 expression
signumInteger 51
Example1 expression
signum 51
valuedivModInteger :: Integer -> Integer -> (# Integer, Integer #)
#

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

(div x y, mod x y)
Example
Example1 expression
divModInteger 10 2(5,0)
Example1 expression
divMod 10 2(5,0)
valuedivInteger :: Integer -> Integer -> Integer
#

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

Example
Example1 expression
10 `divInteger` 25
Example1 expression
10 `div` 2
valuemodInteger :: Integer -> Integer -> Integer
#

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

((x `div` y) * y) + (x `mod` y) == x
Example
Example1 expression
7 `modInteger` 31
Example1 expression
7 `mod` 31
valuequotRemInteger :: Integer -> Integer -> (# Integer, Integer #)
#

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

(quot x y, mod x y)
Example
Example1 expression
quotRemInteger 10 2(5,0)
Example1 expression
quotRem 10 2(5,0)
valuequotInteger :: Integer -> Integer -> Integer
#

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

Example
Example1 expression
quotInteger 10 25
Example1 expression
quot 10 25
valueremInteger :: Integer -> Integer -> Integer
#

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
Example1 expression
remInteger 3 21
Example1 expression
rem 3 21

Comparison predicates

7 declarations
valueeqInteger :: Integer -> Integer -> Bool
#

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

Example
Example1 expression
6 `eqInteger` 6True
Example1 expression
6 == 6True
valueneqInteger :: Integer -> Integer -> Bool
#

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

Example
Example1 expression
6 `neqInteger` 7True
Example1 expression
6 /= 7True
valueleInteger :: Integer -> Integer -> Bool
#

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

Example
Example1 expression
3 `leInteger` 5True
Example1 expression
3 <= 5True
valuegtInteger :: Integer -> Integer -> Bool
#

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

Example
Example1 expression
5 `gtInteger` 3True
Example1 expression
5 > 3True
valueltInteger :: Integer -> Integer -> Bool
#

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

Example
Example1 expression
3 `ltInteger` 5True
Example1 expression
3 < 5True
valuegeInteger :: Integer -> Integer -> Bool
#

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

Example
Example1 expression
5 `geInteger` 3True
Example1 expression
5 >= 3True

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
Example1 expression
compareInteger 2 10LT
Example1 expression
compare 2 10LT

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

Bit-operations

9 declarations

Hashing

1 declaration