Copyright | (c) The University of Glasgow 1994-2002 |
---|---|
License | see libraries/base/LICENSE |
Maintainer | ghc-devs@haskell.org |
Stability | internal |
Portability | non-portable (GHC Extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- class Num a where
- subtract :: Num a => a -> a -> a
- quotRemInteger :: Integer -> Integer -> (# Integer, Integer #)
- data Integer
- = IS Int#
- | IP ByteArray#
- | IN ByteArray#
- integerToInt :: Integer -> Int
- integerToWord :: Integer -> Word
- integerLog2# :: Integer -> Word#
- integerLogBase# :: Integer -> Integer -> Word#
- integerAbs :: Integer -> Integer
- integerAdd :: Integer -> Integer -> Integer
- integerAnd :: Integer -> Integer -> Integer
- integerBit :: Word -> Integer
- integerBit# :: Word# -> Integer
- integerCheck :: Integer -> Bool
- integerCheck# :: Integer -> Bool#
- integerCompare :: Integer -> Integer -> Ordering
- integerComplement :: Integer -> Integer
- integerDecodeDouble# :: Double# -> (# Integer, Int# #)
- integerDiv :: Integer -> Integer -> Integer
- integerDivMod :: Integer -> Integer -> (Integer, Integer)
- integerDivMod# :: Integer -> Integer -> (# Integer, Integer #)
- integerEncodeDouble :: Integer -> Int -> Double
- integerEncodeDouble# :: Integer -> Int# -> Double#
- integerEncodeFloat# :: Integer -> Int# -> Float#
- integerEq :: Integer -> Integer -> Bool
- integerEq# :: Integer -> Integer -> Bool#
- integerFromAddr :: Word# -> Addr# -> Bool# -> IO Integer
- integerFromAddr# :: Word# -> Addr# -> Bool# -> State# s -> (# State# s, Integer #)
- integerFromBigNat# :: BigNat# -> Integer
- integerFromBigNatNeg# :: BigNat# -> Integer
- integerFromBigNatSign# :: Int# -> BigNat# -> Integer
- integerFromByteArray :: Word# -> ByteArray# -> Word# -> Bool# -> Integer
- integerFromByteArray# :: Word# -> ByteArray# -> Word# -> Bool# -> State# s -> (# State# s, Integer #)
- integerFromInt :: Int -> Integer
- integerFromInt# :: Int# -> Integer
- integerFromInt64# :: Int64# -> Integer
- integerFromNatural :: Natural -> Integer
- integerFromWord :: Word -> Integer
- integerFromWord# :: Word# -> Integer
- integerFromWord64# :: Word64# -> Integer
- integerFromWordList :: Bool -> [Word] -> Integer
- integerFromWordNeg# :: Word# -> Integer
- integerFromWordSign# :: Int# -> Word# -> Integer
- integerGcd :: Integer -> Integer -> Integer
- integerGcde :: Integer -> Integer -> (Integer, Integer, Integer)
- integerGcde# :: Integer -> Integer -> (# Integer, Integer, Integer #)
- integerGe :: Integer -> Integer -> Bool
- integerGe# :: Integer -> Integer -> Bool#
- integerGt :: Integer -> Integer -> Bool
- integerGt# :: Integer -> Integer -> Bool#
- integerIsNegative :: Integer -> Bool
- integerIsNegative# :: Integer -> Bool#
- integerIsOne :: Integer -> Bool
- integerIsPowerOf2# :: Integer -> (# (# #) | Word# #)
- integerIsZero :: Integer -> Bool
- integerLcm :: Integer -> Integer -> Integer
- integerLe :: Integer -> Integer -> Bool
- integerLe# :: Integer -> Integer -> Bool#
- integerLog2 :: Integer -> Word
- integerLogBase :: Integer -> Integer -> Word
- integerLogBaseWord :: Word -> Integer -> Word
- integerLogBaseWord# :: Word# -> Integer -> Word#
- integerLt :: Integer -> Integer -> Bool
- integerLt# :: Integer -> Integer -> Bool#
- integerMod :: Integer -> Integer -> Integer
- integerMul :: Integer -> Integer -> Integer
- integerNe :: Integer -> Integer -> Bool
- integerNe# :: Integer -> Integer -> Bool#
- integerNegate :: Integer -> Integer
- integerOne :: Integer
- integerOr :: Integer -> Integer -> Integer
- integerPopCount# :: Integer -> Int#
- integerPowMod# :: Integer -> Integer -> Natural -> (# Natural | () #)
- integerQuot :: Integer -> Integer -> Integer
- integerQuotRem :: Integer -> Integer -> (Integer, Integer)
- integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #)
- integerRecipMod# :: Integer -> Natural -> (# Natural | () #)
- integerRem :: Integer -> Integer -> Integer
- integerShiftL :: Integer -> Word -> Integer
- integerShiftL# :: Integer -> Word# -> Integer
- integerShiftR :: Integer -> Word -> Integer
- integerShiftR# :: Integer -> Word# -> Integer
- integerSignum :: Integer -> Integer
- integerSignum# :: Integer -> Int#
- integerSizeInBase# :: Word# -> Integer -> Word#
- integerSqr :: Integer -> Integer
- integerSub :: Integer -> Integer -> Integer
- integerTestBit :: Integer -> Word -> Bool
- integerTestBit# :: Integer -> Word# -> Bool#
- integerToAddr :: Integer -> Addr# -> Bool# -> IO Word
- integerToAddr# :: Integer -> Addr# -> Bool# -> State# s -> (# State# s, Word# #)
- integerToBigNatClamp# :: Integer -> BigNat#
- integerToBigNatSign# :: Integer -> (# Int#, BigNat# #)
- integerToInt# :: Integer -> Int#
- integerToInt64# :: Integer -> Int64#
- integerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Bool# -> IO Word
- integerToMutableByteArray# :: Integer -> MutableByteArray# s -> Word# -> Bool# -> State# s -> (# State# s, Word# #)
- integerToNatural :: Integer -> Natural
- integerToNaturalClamp :: Integer -> Natural
- integerToNaturalThrow :: Integer -> Natural
- integerToWord# :: Integer -> Word#
- integerToWord64# :: Integer -> Word64#
- integerXor :: Integer -> Integer -> Integer
- integerZero :: Integer
- data Natural
- = NS Word#
- | NB ByteArray#
- naturalToWord :: Natural -> Word
- naturalAdd :: Natural -> Natural -> Natural
- naturalAnd :: Natural -> Natural -> Natural
- naturalAndNot :: Natural -> Natural -> Natural
- naturalBit :: Word -> Natural
- naturalBit# :: Word# -> Natural
- naturalCheck :: Natural -> Bool
- naturalCheck# :: Natural -> Bool#
- naturalClearBit :: Natural -> Word -> Natural
- naturalClearBit# :: Natural -> Word# -> Natural
- naturalCompare :: Natural -> Natural -> Ordering
- naturalComplementBit :: Natural -> Word -> Natural
- naturalComplementBit# :: Natural -> Word# -> Natural
- naturalEncodeDouble# :: Natural -> Int# -> Double#
- naturalEncodeFloat# :: Natural -> Int# -> Float#
- naturalEq :: Natural -> Natural -> Bool
- naturalEq# :: Natural -> Natural -> Bool#
- naturalFromAddr :: Word# -> Addr# -> Bool# -> IO Natural
- naturalFromAddr# :: Word# -> Addr# -> Bool# -> State# s -> (# State# s, Natural #)
- naturalFromBigNat# :: BigNat# -> Natural
- naturalFromByteArray# :: Word# -> ByteArray# -> Word# -> Bool# -> State# s -> (# State# s, Natural #)
- naturalFromWord :: Word -> Natural
- naturalFromWord# :: Word# -> Natural
- naturalFromWord2# :: Word# -> Word# -> Natural
- naturalFromWordList :: [Word] -> Natural
- naturalGcd :: Natural -> Natural -> Natural
- naturalGe :: Natural -> Natural -> Bool
- naturalGe# :: Natural -> Natural -> Bool#
- naturalGt :: Natural -> Natural -> Bool
- naturalGt# :: Natural -> Natural -> Bool#
- naturalIsOne :: Natural -> Bool
- naturalIsPowerOf2# :: Natural -> (# (# #) | Word# #)
- naturalIsZero :: Natural -> Bool
- naturalLcm :: Natural -> Natural -> Natural
- naturalLe :: Natural -> Natural -> Bool
- naturalLe# :: Natural -> Natural -> Bool#
- naturalLog2 :: Natural -> Word
- naturalLog2# :: Natural -> Word#
- naturalLogBase :: Natural -> Natural -> Word
- naturalLogBase# :: Natural -> Natural -> Word#
- naturalLogBaseWord :: Word -> Natural -> Word
- naturalLogBaseWord# :: Word# -> Natural -> Word#
- naturalLt :: Natural -> Natural -> Bool
- naturalLt# :: Natural -> Natural -> Bool#
- naturalMul :: Natural -> Natural -> Natural
- naturalNe :: Natural -> Natural -> Bool
- naturalNe# :: Natural -> Natural -> Bool#
- naturalNegate :: Natural -> Natural
- naturalOne :: Natural
- naturalOr :: Natural -> Natural -> Natural
- naturalPopCount :: Natural -> Word
- naturalPopCount# :: Natural -> Word#
- naturalPowMod :: Natural -> Natural -> Natural -> Natural
- naturalQuot :: Natural -> Natural -> Natural
- naturalQuotRem :: Natural -> Natural -> (Natural, Natural)
- naturalQuotRem# :: Natural -> Natural -> (# Natural, Natural #)
- naturalRem :: Natural -> Natural -> Natural
- naturalSetBit :: Natural -> Word -> Natural
- naturalSetBit# :: Natural -> Word# -> Natural
- naturalShiftL :: Natural -> Word -> Natural
- naturalShiftL# :: Natural -> Word# -> Natural
- naturalShiftR :: Natural -> Word -> Natural
- naturalShiftR# :: Natural -> Word# -> Natural
- naturalSignum :: Natural -> Natural
- naturalSizeInBase# :: Word# -> Natural -> Word#
- naturalSqr :: Natural -> Natural
- naturalSub :: Natural -> Natural -> (# (# #) | Natural #)
- naturalSubThrow :: Natural -> Natural -> Natural
- naturalSubUnsafe :: Natural -> Natural -> Natural
- naturalTestBit :: Natural -> Word -> Bool
- naturalTestBit# :: Natural -> Word# -> Bool#
- naturalToAddr :: Natural -> Addr# -> Bool# -> IO Word
- naturalToAddr# :: Natural -> Addr# -> Bool# -> State# s -> (# State# s, Word# #)
- naturalToBigNat# :: Natural -> BigNat#
- naturalToMutableByteArray# :: Natural -> MutableByteArray# s -> Word# -> Bool# -> State# s -> (# State# s, Word# #)
- naturalToWord# :: Natural -> Word#
- naturalToWordClamp :: Natural -> Word
- naturalToWordClamp# :: Natural -> Word#
- naturalToWordMaybe# :: Natural -> (# (# #) | Word# #)
- naturalXor :: Natural -> Natural -> Natural
- naturalZero :: Natural
Documentation
Basic numeric class.
The Haskell Report defines no laws for Num
. However, (
and +
)(
are
customarily expected to define a ring and have the following properties:*
)
- Associativity of
(
+
) (x + y) + z
=x + (y + z)
- Commutativity of
(
+
) x + y
=y + x
is the additive identityfromInteger
0x + fromInteger 0
=x
negate
gives the additive inversex + negate x
=fromInteger 0
- Associativity of
(
*
) (x * y) * z
=x * (y * z)
is the multiplicative identityfromInteger
1x * fromInteger 1
=x
andfromInteger 1 * x
=x
- Distributivity of
(
with respect to*
)(
+
) a * (b + c)
=(a * b) + (a * c)
and(b + c) * a
=(b * a) + (c * a)
- Coherence with
toInteger
- if the type also implements
Integral
, thenfromInteger
is a left inverse fortoInteger
, i.e.fromInteger (toInteger i) == i
Note that it isn't customarily expected that a type instance of both Num
and Ord
implement an ordered ring. Indeed, in base
only Integer
and
Rational
do.
(+) :: a -> a -> a infixl 6 Source #
(-) :: a -> a -> a infixl 6 Source #
(*) :: a -> a -> a infixl 7 Source #
Unary negation.
Absolute value.
Sign of a number.
The functions abs
and signum
should satisfy the law:
abs x * signum x == x
For real numbers, the signum
is either -1
(negative), 0
(zero)
or 1
(positive).
fromInteger :: Integer -> a Source #
Conversion from an Integer
.
An integer literal represents the application of the function
fromInteger
to the appropriate value of type Integer
,
so such literals have type (
.Num
a) => a
Instances
Instances
integerToInt :: Integer -> Int #
integerToWord :: Integer -> Word #
integerLog2# :: Integer -> Word# #
integerLogBase# :: Integer -> Integer -> Word# #
integerAbs :: Integer -> Integer #
integerAdd :: Integer -> Integer -> Integer #
integerAnd :: Integer -> Integer -> Integer #
integerBit :: Word -> Integer #
integerBit# :: Word# -> Integer #
integerCheck :: Integer -> Bool #
integerCheck# :: Integer -> Bool# #
integerCompare :: Integer -> Integer -> Ordering #
integerComplement :: Integer -> Integer #
integerDecodeDouble# :: Double# -> (# Integer, Int# #) #
integerDiv :: Integer -> Integer -> Integer #
integerEncodeDouble :: Integer -> Int -> Double #
integerEncodeDouble# :: Integer -> Int# -> Double# #
integerEncodeFloat# :: Integer -> Int# -> Float# #
integerEq# :: Integer -> Integer -> Bool# #
integerFromBigNat# :: BigNat# -> Integer #
integerFromBigNatNeg# :: BigNat# -> Integer #
integerFromBigNatSign# :: Int# -> BigNat# -> Integer #
integerFromByteArray :: Word# -> ByteArray# -> Word# -> Bool# -> Integer #
integerFromByteArray# :: Word# -> ByteArray# -> Word# -> Bool# -> State# s -> (# State# s, Integer #) #
integerFromInt :: Int -> Integer #
integerFromInt# :: Int# -> Integer #
integerFromInt64# :: Int64# -> Integer #
integerFromNatural :: Natural -> Integer #
integerFromWord :: Word -> Integer #
integerFromWord# :: Word# -> Integer #
integerFromWord64# :: Word64# -> Integer #
integerFromWordList :: Bool -> [Word] -> Integer #
integerFromWordNeg# :: Word# -> Integer #
integerFromWordSign# :: Int# -> Word# -> Integer #
integerGcd :: Integer -> Integer -> Integer #
integerGe# :: Integer -> Integer -> Bool# #
integerGt# :: Integer -> Integer -> Bool# #
integerIsNegative :: Integer -> Bool #
integerIsNegative# :: Integer -> Bool# #
integerIsOne :: Integer -> Bool #
integerIsPowerOf2# :: Integer -> (# (# #) | Word# #) #
integerIsZero :: Integer -> Bool #
integerLcm :: Integer -> Integer -> Integer #
integerLe# :: Integer -> Integer -> Bool# #
integerLog2 :: Integer -> Word #
integerLogBase :: Integer -> Integer -> Word #
integerLogBaseWord :: Word -> Integer -> Word #
integerLogBaseWord# :: Word# -> Integer -> Word# #
integerLt# :: Integer -> Integer -> Bool# #
integerMod :: Integer -> Integer -> Integer #
integerMul :: Integer -> Integer -> Integer #
integerNe# :: Integer -> Integer -> Bool# #
integerNegate :: Integer -> Integer #
integerOne :: Integer #
integerPopCount# :: Integer -> Int# #
integerQuot :: Integer -> Integer -> Integer #
integerRecipMod# :: Integer -> Natural -> (# Natural | () #) #
integerRem :: Integer -> Integer -> Integer #
integerShiftL :: Integer -> Word -> Integer #
integerShiftL# :: Integer -> Word# -> Integer #
integerShiftR :: Integer -> Word -> Integer #
integerShiftR# :: Integer -> Word# -> Integer #
integerSignum :: Integer -> Integer #
integerSignum# :: Integer -> Int# #
integerSizeInBase# :: Word# -> Integer -> Word# #
integerSqr :: Integer -> Integer #
integerSub :: Integer -> Integer -> Integer #
integerTestBit :: Integer -> Word -> Bool #
integerTestBit# :: Integer -> Word# -> Bool# #
integerToBigNatClamp# :: Integer -> BigNat# #
integerToBigNatSign# :: Integer -> (# Int#, BigNat# #) #
integerToInt# :: Integer -> Int# #
integerToInt64# :: Integer -> Int64# #
integerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Bool# -> IO Word #
integerToMutableByteArray# :: Integer -> MutableByteArray# s -> Word# -> Bool# -> State# s -> (# State# s, Word# #) #
integerToNatural :: Integer -> Natural #
integerToNaturalClamp :: Integer -> Natural #
integerToNaturalThrow :: Integer -> Natural #
integerToWord# :: Integer -> Word# #
integerToWord64# :: Integer -> Word64# #
integerXor :: Integer -> Integer -> Integer #
integerZero :: Integer #
Instances
naturalToWord :: Natural -> Word #
naturalAdd :: Natural -> Natural -> Natural #
naturalAnd :: Natural -> Natural -> Natural #
naturalAndNot :: Natural -> Natural -> Natural #
naturalBit :: Word -> Natural #
naturalBit# :: Word# -> Natural #
naturalCheck :: Natural -> Bool #
naturalCheck# :: Natural -> Bool# #
naturalClearBit :: Natural -> Word -> Natural #
naturalClearBit# :: Natural -> Word# -> Natural #
naturalCompare :: Natural -> Natural -> Ordering #
naturalComplementBit :: Natural -> Word -> Natural #
naturalComplementBit# :: Natural -> Word# -> Natural #
naturalEncodeDouble# :: Natural -> Int# -> Double# #
naturalEncodeFloat# :: Natural -> Int# -> Float# #
naturalEq# :: Natural -> Natural -> Bool# #
naturalFromBigNat# :: BigNat# -> Natural #
naturalFromByteArray# :: Word# -> ByteArray# -> Word# -> Bool# -> State# s -> (# State# s, Natural #) #
naturalFromWord :: Word -> Natural #
naturalFromWord# :: Word# -> Natural #
naturalFromWord2# :: Word# -> Word# -> Natural #
naturalFromWordList :: [Word] -> Natural #
naturalGcd :: Natural -> Natural -> Natural #
naturalGe# :: Natural -> Natural -> Bool# #
naturalGt# :: Natural -> Natural -> Bool# #
naturalIsOne :: Natural -> Bool #
naturalIsPowerOf2# :: Natural -> (# (# #) | Word# #) #
naturalIsZero :: Natural -> Bool #
naturalLcm :: Natural -> Natural -> Natural #
naturalLe# :: Natural -> Natural -> Bool# #
naturalLog2 :: Natural -> Word #
naturalLog2# :: Natural -> Word# #
naturalLogBase :: Natural -> Natural -> Word #
naturalLogBase# :: Natural -> Natural -> Word# #
naturalLogBaseWord :: Word -> Natural -> Word #
naturalLogBaseWord# :: Word# -> Natural -> Word# #
naturalLt# :: Natural -> Natural -> Bool# #
naturalMul :: Natural -> Natural -> Natural #
naturalNe# :: Natural -> Natural -> Bool# #
naturalNegate :: Natural -> Natural #
naturalOne :: Natural #
naturalPopCount :: Natural -> Word #
naturalPopCount# :: Natural -> Word# #
naturalQuot :: Natural -> Natural -> Natural #
naturalRem :: Natural -> Natural -> Natural #
naturalSetBit :: Natural -> Word -> Natural #
naturalSetBit# :: Natural -> Word# -> Natural #
naturalShiftL :: Natural -> Word -> Natural #
naturalShiftL# :: Natural -> Word# -> Natural #
naturalShiftR :: Natural -> Word -> Natural #
naturalShiftR# :: Natural -> Word# -> Natural #
naturalSignum :: Natural -> Natural #
naturalSizeInBase# :: Word# -> Natural -> Word# #
naturalSqr :: Natural -> Natural #
naturalSub :: Natural -> Natural -> (# (# #) | Natural #) #
naturalSubThrow :: Natural -> Natural -> Natural #
naturalSubUnsafe :: Natural -> Natural -> Natural #
naturalTestBit :: Natural -> Word -> Bool #
naturalTestBit# :: Natural -> Word# -> Bool# #
naturalToBigNat# :: Natural -> BigNat# #
naturalToMutableByteArray# :: Natural -> MutableByteArray# s -> Word# -> Bool# -> State# s -> (# State# s, Word# #) #
naturalToWord# :: Natural -> Word# #
naturalToWordClamp :: Natural -> Word #
naturalToWordClamp# :: Natural -> Word# #
naturalToWordMaybe# :: Natural -> (# (# #) | Word# #) #
naturalXor :: Natural -> Natural -> Natural #
naturalZero :: Natural #