base-4.18.1.0: Basic libraries

Copyright | (c) The University of Glasgow 1994-2002
License | see libraries/base/LICENSE
Maintainer | cvs-ghc@haskell.org
Stability | internal
Portability | non-portable (GHC Extensions)
Safe Haskell | Trustworthy
Language | Haskell2010

GHC.Num

Description

The `Num` class and the `Integer` type.

Synopsis

- class Num a where
  - (+), (-), (*) :: a -> a -> a
  - negate :: a -> a
  - abs :: a -> a
  - signum :: a -> a
  - fromInteger :: Integer -> a
- quotRemInteger :: Integer -> Integer -> (# Integer, Integer #)
- subtract :: Num a => a -> a -> a
- module GHC.Num.Integer
- module GHC.Num.Natural
- module GHC.Natural
- module GHC.Integer

# Documentation

class Num a where Source #

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`
``fromInteger` 0` is the additive identity
  `x + fromInteger 0` = `x`
`negate` gives the additive inverse
  `x + negate x` = `fromInteger 0`
Associativity of `(`*`)`
  `(x * y) * z` = `x * (y * z)`
``fromInteger` 1` is the multiplicative identity
  `x * fromInteger 1` = `x` and `fromInteger 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`, then `fromInteger` is a left inverse for `toInteger`, 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.

Minimal complete definition

(+), (*), abs, signum, fromInteger, (negate | (-))

Methods

(+) :: a -> a -> a infixl 6 Source #

(-) :: a -> a -> a infixl 6 Source #

(*) :: a -> a -> a infixl 7 Source #

negate :: a -> a Source #

Unary negation.

abs :: a -> a Source #

Absolute value.

signum :: a -> a Source #

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 details

Num CBool Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CBool -> CBool -> CBool Source # (-) :: CBool -> CBool -> CBool Source # (*) :: CBool -> CBool -> CBool Source # negate :: CBool -> CBool Source # abs :: CBool -> CBool Source # signum :: CBool -> CBool Source # fromInteger :: Integer -> CBool Source #
Num CChar Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CChar -> CChar -> CChar Source # (-) :: CChar -> CChar -> CChar Source # (*) :: CChar -> CChar -> CChar Source # negate :: CChar -> CChar Source # abs :: CChar -> CChar Source # signum :: CChar -> CChar Source # fromInteger :: Integer -> CChar Source #
Num CClock Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CClock -> CClock -> CClock Source # (-) :: CClock -> CClock -> CClock Source # (*) :: CClock -> CClock -> CClock Source # negate :: CClock -> CClock Source # abs :: CClock -> CClock Source # signum :: CClock -> CClock Source # fromInteger :: Integer -> CClock Source #
Num CDouble Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CDouble -> CDouble -> CDouble Source # (-) :: CDouble -> CDouble -> CDouble Source # (*) :: CDouble -> CDouble -> CDouble Source # negate :: CDouble -> CDouble Source # abs :: CDouble -> CDouble Source # signum :: CDouble -> CDouble Source # fromInteger :: Integer -> CDouble Source #
Num CFloat Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CFloat -> CFloat -> CFloat Source # (-) :: CFloat -> CFloat -> CFloat Source # (*) :: CFloat -> CFloat -> CFloat Source # negate :: CFloat -> CFloat Source # abs :: CFloat -> CFloat Source # signum :: CFloat -> CFloat Source # fromInteger :: Integer -> CFloat Source #
Num CInt Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CInt -> CInt -> CInt Source # (-) :: CInt -> CInt -> CInt Source # (*) :: CInt -> CInt -> CInt Source # negate :: CInt -> CInt Source # abs :: CInt -> CInt Source # signum :: CInt -> CInt Source # fromInteger :: Integer -> CInt Source #
Num CIntMax Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CIntMax -> CIntMax -> CIntMax Source # (-) :: CIntMax -> CIntMax -> CIntMax Source # (*) :: CIntMax -> CIntMax -> CIntMax Source # negate :: CIntMax -> CIntMax Source # abs :: CIntMax -> CIntMax Source # signum :: CIntMax -> CIntMax Source # fromInteger :: Integer -> CIntMax Source #
Num CIntPtr Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CIntPtr -> CIntPtr -> CIntPtr Source # (-) :: CIntPtr -> CIntPtr -> CIntPtr Source # (*) :: CIntPtr -> CIntPtr -> CIntPtr Source # negate :: CIntPtr -> CIntPtr Source # abs :: CIntPtr -> CIntPtr Source # signum :: CIntPtr -> CIntPtr Source # fromInteger :: Integer -> CIntPtr Source #
Num CLLong Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CLLong -> CLLong -> CLLong Source # (-) :: CLLong -> CLLong -> CLLong Source # (*) :: CLLong -> CLLong -> CLLong Source # negate :: CLLong -> CLLong Source # abs :: CLLong -> CLLong Source # signum :: CLLong -> CLLong Source # fromInteger :: Integer -> CLLong Source #
Num CLong Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CLong -> CLong -> CLong Source # (-) :: CLong -> CLong -> CLong Source # (*) :: CLong -> CLong -> CLong Source # negate :: CLong -> CLong Source # abs :: CLong -> CLong Source # signum :: CLong -> CLong Source # fromInteger :: Integer -> CLong Source #
Num CPtrdiff Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # (-) :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # (*) :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # negate :: CPtrdiff -> CPtrdiff Source # abs :: CPtrdiff -> CPtrdiff Source # signum :: CPtrdiff -> CPtrdiff Source # fromInteger :: Integer -> CPtrdiff Source #
Num CSChar Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CSChar -> CSChar -> CSChar Source # (-) :: CSChar -> CSChar -> CSChar Source # (*) :: CSChar -> CSChar -> CSChar Source # negate :: CSChar -> CSChar Source # abs :: CSChar -> CSChar Source # signum :: CSChar -> CSChar Source # fromInteger :: Integer -> CSChar Source #
Num CSUSeconds Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CSUSeconds -> CSUSeconds -> CSUSeconds Source # (-) :: CSUSeconds -> CSUSeconds -> CSUSeconds Source # (*) :: CSUSeconds -> CSUSeconds -> CSUSeconds Source # negate :: CSUSeconds -> CSUSeconds Source # abs :: CSUSeconds -> CSUSeconds Source # signum :: CSUSeconds -> CSUSeconds Source # fromInteger :: Integer -> CSUSeconds Source #
Num CShort Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CShort -> CShort -> CShort Source # (-) :: CShort -> CShort -> CShort Source # (*) :: CShort -> CShort -> CShort Source # negate :: CShort -> CShort Source # abs :: CShort -> CShort Source # signum :: CShort -> CShort Source # fromInteger :: Integer -> CShort Source #
Num CSigAtomic Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # (-) :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # (*) :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # negate :: CSigAtomic -> CSigAtomic Source # abs :: CSigAtomic -> CSigAtomic Source # signum :: CSigAtomic -> CSigAtomic Source # fromInteger :: Integer -> CSigAtomic Source #
Num CSize Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CSize -> CSize -> CSize Source # (-) :: CSize -> CSize -> CSize Source # (*) :: CSize -> CSize -> CSize Source # negate :: CSize -> CSize Source # abs :: CSize -> CSize Source # signum :: CSize -> CSize Source # fromInteger :: Integer -> CSize Source #
Num CTime Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CTime -> CTime -> CTime Source # (-) :: CTime -> CTime -> CTime Source # (*) :: CTime -> CTime -> CTime Source # negate :: CTime -> CTime Source # abs :: CTime -> CTime Source # signum :: CTime -> CTime Source # fromInteger :: Integer -> CTime Source #
Num CUChar Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CUChar -> CUChar -> CUChar Source # (-) :: CUChar -> CUChar -> CUChar Source # (*) :: CUChar -> CUChar -> CUChar Source # negate :: CUChar -> CUChar Source # abs :: CUChar -> CUChar Source # signum :: CUChar -> CUChar Source # fromInteger :: Integer -> CUChar Source #
Num CUInt Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CUInt -> CUInt -> CUInt Source # (-) :: CUInt -> CUInt -> CUInt Source # (*) :: CUInt -> CUInt -> CUInt Source # negate :: CUInt -> CUInt Source # abs :: CUInt -> CUInt Source # signum :: CUInt -> CUInt Source # fromInteger :: Integer -> CUInt Source #
Num CUIntMax Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CUIntMax -> CUIntMax -> CUIntMax Source # (-) :: CUIntMax -> CUIntMax -> CUIntMax Source # (*) :: CUIntMax -> CUIntMax -> CUIntMax Source # negate :: CUIntMax -> CUIntMax Source # abs :: CUIntMax -> CUIntMax Source # signum :: CUIntMax -> CUIntMax Source # fromInteger :: Integer -> CUIntMax Source #
Num CUIntPtr Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # (-) :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # (*) :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # negate :: CUIntPtr -> CUIntPtr Source # abs :: CUIntPtr -> CUIntPtr Source # signum :: CUIntPtr -> CUIntPtr Source # fromInteger :: Integer -> CUIntPtr Source #
Num CULLong Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CULLong -> CULLong -> CULLong Source # (-) :: CULLong -> CULLong -> CULLong Source # (*) :: CULLong -> CULLong -> CULLong Source # negate :: CULLong -> CULLong Source # abs :: CULLong -> CULLong Source # signum :: CULLong -> CULLong Source # fromInteger :: Integer -> CULLong Source #
Num CULong Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CULong -> CULong -> CULong Source # (-) :: CULong -> CULong -> CULong Source # (*) :: CULong -> CULong -> CULong Source # negate :: CULong -> CULong Source # abs :: CULong -> CULong Source # signum :: CULong -> CULong Source # fromInteger :: Integer -> CULong Source #
Num CUSeconds Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CUSeconds -> CUSeconds -> CUSeconds Source # (-) :: CUSeconds -> CUSeconds -> CUSeconds Source # (*) :: CUSeconds -> CUSeconds -> CUSeconds Source # negate :: CUSeconds -> CUSeconds Source # abs :: CUSeconds -> CUSeconds Source # signum :: CUSeconds -> CUSeconds Source # fromInteger :: Integer -> CUSeconds Source #
Num CUShort Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CUShort -> CUShort -> CUShort Source # (-) :: CUShort -> CUShort -> CUShort Source # (*) :: CUShort -> CUShort -> CUShort Source # negate :: CUShort -> CUShort Source # abs :: CUShort -> CUShort Source # signum :: CUShort -> CUShort Source # fromInteger :: Integer -> CUShort Source #
Num CWchar Source # |
Instance details Defined in Foreign.C.Types Methods (+) :: CWchar -> CWchar -> CWchar Source # (-) :: CWchar -> CWchar -> CWchar Source # (*) :: CWchar -> CWchar -> CWchar Source # negate :: CWchar -> CWchar Source # abs :: CWchar -> CWchar Source # signum :: CWchar -> CWchar Source # fromInteger :: Integer -> CWchar Source #
Num IntPtr Source # |
Instance details Defined in Foreign.Ptr Methods (+) :: IntPtr -> IntPtr -> IntPtr Source # (-) :: IntPtr -> IntPtr -> IntPtr Source # (*) :: IntPtr -> IntPtr -> IntPtr Source # negate :: IntPtr -> IntPtr Source # abs :: IntPtr -> IntPtr Source # signum :: IntPtr -> IntPtr Source # fromInteger :: Integer -> IntPtr Source #
Num WordPtr Source # |
Instance details Defined in Foreign.Ptr Methods (+) :: WordPtr -> WordPtr -> WordPtr Source # (-) :: WordPtr -> WordPtr -> WordPtr Source # (*) :: WordPtr -> WordPtr -> WordPtr Source # negate :: WordPtr -> WordPtr Source # abs :: WordPtr -> WordPtr Source # signum :: WordPtr -> WordPtr Source # fromInteger :: Integer -> WordPtr Source #
Num Int16 Source # | Since: base-2.1
Instance details Defined in GHC.Int Methods (+) :: Int16 -> Int16 -> Int16 Source # (-) :: Int16 -> Int16 -> Int16 Source # (*) :: Int16 -> Int16 -> Int16 Source # negate :: Int16 -> Int16 Source # abs :: Int16 -> Int16 Source # signum :: Int16 -> Int16 Source # fromInteger :: Integer -> Int16 Source #
Num Int32 Source # | Since: base-2.1
Instance details Defined in GHC.Int Methods (+) :: Int32 -> Int32 -> Int32 Source # (-) :: Int32 -> Int32 -> Int32 Source # (*) :: Int32 -> Int32 -> Int32 Source # negate :: Int32 -> Int32 Source # abs :: Int32 -> Int32 Source # signum :: Int32 -> Int32 Source # fromInteger :: Integer -> Int32 Source #
Num Int64 Source # | Since: base-2.1
Instance details Defined in GHC.Int Methods (+) :: Int64 -> Int64 -> Int64 Source # (-) :: Int64 -> Int64 -> Int64 Source # (*) :: Int64 -> Int64 -> Int64 Source # negate :: Int64 -> Int64 Source # abs :: Int64 -> Int64 Source # signum :: Int64 -> Int64 Source # fromInteger :: Integer -> Int64 Source #
Num Int8 Source # | Since: base-2.1
Instance details Defined in GHC.Int Methods (+) :: Int8 -> Int8 -> Int8 Source # (-) :: Int8 -> Int8 -> Int8 Source # (*) :: Int8 -> Int8 -> Int8 Source # negate :: Int8 -> Int8 Source # abs :: Int8 -> Int8 Source # signum :: Int8 -> Int8 Source # fromInteger :: Integer -> Int8 Source #
Num Word16 Source # | Since: base-2.1
Instance details Defined in GHC.Word Methods (+) :: Word16 -> Word16 -> Word16 Source # (-) :: Word16 -> Word16 -> Word16 Source # (*) :: Word16 -> Word16 -> Word16 Source # negate :: Word16 -> Word16 Source # abs :: Word16 -> Word16 Source # signum :: Word16 -> Word16 Source # fromInteger :: Integer -> Word16 Source #
Num Word32 Source # | Since: base-2.1
Instance details Defined in GHC.Word Methods (+) :: Word32 -> Word32 -> Word32 Source # (-) :: Word32 -> Word32 -> Word32 Source # (*) :: Word32 -> Word32 -> Word32 Source # negate :: Word32 -> Word32 Source # abs :: Word32 -> Word32 Source # signum :: Word32 -> Word32 Source # fromInteger :: Integer -> Word32 Source #
Num Word64 Source # | Since: base-2.1
Instance details Defined in GHC.Word Methods (+) :: Word64 -> Word64 -> Word64 Source # (-) :: Word64 -> Word64 -> Word64 Source # (*) :: Word64 -> Word64 -> Word64 Source # negate :: Word64 -> Word64 Source # abs :: Word64 -> Word64 Source # signum :: Word64 -> Word64 Source # fromInteger :: Integer -> Word64 Source #
Num Word8 Source # | Since: base-2.1
Instance details Defined in GHC.Word Methods (+) :: Word8 -> Word8 -> Word8 Source # (-) :: Word8 -> Word8 -> Word8 Source # (*) :: Word8 -> Word8 -> Word8 Source # negate :: Word8 -> Word8 Source # abs :: Word8 -> Word8 Source # signum :: Word8 -> Word8 Source # fromInteger :: Integer -> Word8 Source #
Num CBlkCnt Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CBlkCnt -> CBlkCnt -> CBlkCnt Source # (-) :: CBlkCnt -> CBlkCnt -> CBlkCnt Source # (*) :: CBlkCnt -> CBlkCnt -> CBlkCnt Source # negate :: CBlkCnt -> CBlkCnt Source # abs :: CBlkCnt -> CBlkCnt Source # signum :: CBlkCnt -> CBlkCnt Source # fromInteger :: Integer -> CBlkCnt Source #
Num CBlkSize Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CBlkSize -> CBlkSize -> CBlkSize Source # (-) :: CBlkSize -> CBlkSize -> CBlkSize Source # (*) :: CBlkSize -> CBlkSize -> CBlkSize Source # negate :: CBlkSize -> CBlkSize Source # abs :: CBlkSize -> CBlkSize Source # signum :: CBlkSize -> CBlkSize Source # fromInteger :: Integer -> CBlkSize Source #
Num CCc Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CCc -> CCc -> CCc Source # (-) :: CCc -> CCc -> CCc Source # (*) :: CCc -> CCc -> CCc Source # negate :: CCc -> CCc Source # abs :: CCc -> CCc Source # signum :: CCc -> CCc Source # fromInteger :: Integer -> CCc Source #
Num CClockId Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CClockId -> CClockId -> CClockId Source # (-) :: CClockId -> CClockId -> CClockId Source # (*) :: CClockId -> CClockId -> CClockId Source # negate :: CClockId -> CClockId Source # abs :: CClockId -> CClockId Source # signum :: CClockId -> CClockId Source # fromInteger :: Integer -> CClockId Source #
Num CDev Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CDev -> CDev -> CDev Source # (-) :: CDev -> CDev -> CDev Source # (*) :: CDev -> CDev -> CDev Source # negate :: CDev -> CDev Source # abs :: CDev -> CDev Source # signum :: CDev -> CDev Source # fromInteger :: Integer -> CDev Source #
Num CFsBlkCnt Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # (-) :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # (*) :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # negate :: CFsBlkCnt -> CFsBlkCnt Source # abs :: CFsBlkCnt -> CFsBlkCnt Source # signum :: CFsBlkCnt -> CFsBlkCnt Source # fromInteger :: Integer -> CFsBlkCnt Source #
Num CFsFilCnt Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # (-) :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # (*) :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # negate :: CFsFilCnt -> CFsFilCnt Source # abs :: CFsFilCnt -> CFsFilCnt Source # signum :: CFsFilCnt -> CFsFilCnt Source # fromInteger :: Integer -> CFsFilCnt Source #
Num CGid Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CGid -> CGid -> CGid Source # (-) :: CGid -> CGid -> CGid Source # (*) :: CGid -> CGid -> CGid Source # negate :: CGid -> CGid Source # abs :: CGid -> CGid Source # signum :: CGid -> CGid Source # fromInteger :: Integer -> CGid Source #
Num CId Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CId -> CId -> CId Source # (-) :: CId -> CId -> CId Source # (*) :: CId -> CId -> CId Source # negate :: CId -> CId Source # abs :: CId -> CId Source # signum :: CId -> CId Source # fromInteger :: Integer -> CId Source #
Num CIno Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CIno -> CIno -> CIno Source # (-) :: CIno -> CIno -> CIno Source # (*) :: CIno -> CIno -> CIno Source # negate :: CIno -> CIno Source # abs :: CIno -> CIno Source # signum :: CIno -> CIno Source # fromInteger :: Integer -> CIno Source #
Num CKey Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CKey -> CKey -> CKey Source # (-) :: CKey -> CKey -> CKey Source # (*) :: CKey -> CKey -> CKey Source # negate :: CKey -> CKey Source # abs :: CKey -> CKey Source # signum :: CKey -> CKey Source # fromInteger :: Integer -> CKey Source #
Num CMode Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CMode -> CMode -> CMode Source # (-) :: CMode -> CMode -> CMode Source # (*) :: CMode -> CMode -> CMode Source # negate :: CMode -> CMode Source # abs :: CMode -> CMode Source # signum :: CMode -> CMode Source # fromInteger :: Integer -> CMode Source #
Num CNfds Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CNfds -> CNfds -> CNfds Source # (-) :: CNfds -> CNfds -> CNfds Source # (*) :: CNfds -> CNfds -> CNfds Source # negate :: CNfds -> CNfds Source # abs :: CNfds -> CNfds Source # signum :: CNfds -> CNfds Source # fromInteger :: Integer -> CNfds Source #
Num CNlink Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CNlink -> CNlink -> CNlink Source # (-) :: CNlink -> CNlink -> CNlink Source # (*) :: CNlink -> CNlink -> CNlink Source # negate :: CNlink -> CNlink Source # abs :: CNlink -> CNlink Source # signum :: CNlink -> CNlink Source # fromInteger :: Integer -> CNlink Source #
Num COff Source # |
Instance details Defined in System.Posix.Types Methods (+) :: COff -> COff -> COff Source # (-) :: COff -> COff -> COff Source # (*) :: COff -> COff -> COff Source # negate :: COff -> COff Source # abs :: COff -> COff Source # signum :: COff -> COff Source # fromInteger :: Integer -> COff Source #
Num CPid Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CPid -> CPid -> CPid Source # (-) :: CPid -> CPid -> CPid Source # (*) :: CPid -> CPid -> CPid Source # negate :: CPid -> CPid Source # abs :: CPid -> CPid Source # signum :: CPid -> CPid Source # fromInteger :: Integer -> CPid Source #
Num CRLim Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CRLim -> CRLim -> CRLim Source # (-) :: CRLim -> CRLim -> CRLim Source # (*) :: CRLim -> CRLim -> CRLim Source # negate :: CRLim -> CRLim Source # abs :: CRLim -> CRLim Source # signum :: CRLim -> CRLim Source # fromInteger :: Integer -> CRLim Source #
Num CSocklen Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CSocklen -> CSocklen -> CSocklen Source # (-) :: CSocklen -> CSocklen -> CSocklen Source # (*) :: CSocklen -> CSocklen -> CSocklen Source # negate :: CSocklen -> CSocklen Source # abs :: CSocklen -> CSocklen Source # signum :: CSocklen -> CSocklen Source # fromInteger :: Integer -> CSocklen Source #
Num CSpeed Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CSpeed -> CSpeed -> CSpeed Source # (-) :: CSpeed -> CSpeed -> CSpeed Source # (*) :: CSpeed -> CSpeed -> CSpeed Source # negate :: CSpeed -> CSpeed Source # abs :: CSpeed -> CSpeed Source # signum :: CSpeed -> CSpeed Source # fromInteger :: Integer -> CSpeed Source #
Num CSsize Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CSsize -> CSsize -> CSsize Source # (-) :: CSsize -> CSsize -> CSsize Source # (*) :: CSsize -> CSsize -> CSsize Source # negate :: CSsize -> CSsize Source # abs :: CSsize -> CSsize Source # signum :: CSsize -> CSsize Source # fromInteger :: Integer -> CSsize Source #
Num CTcflag Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CTcflag -> CTcflag -> CTcflag Source # (-) :: CTcflag -> CTcflag -> CTcflag Source # (*) :: CTcflag -> CTcflag -> CTcflag Source # negate :: CTcflag -> CTcflag Source # abs :: CTcflag -> CTcflag Source # signum :: CTcflag -> CTcflag Source # fromInteger :: Integer -> CTcflag Source #
Num CUid Source # |
Instance details Defined in System.Posix.Types Methods (+) :: CUid -> CUid -> CUid Source # (-) :: CUid -> CUid -> CUid Source # (*) :: CUid -> CUid -> CUid Source # negate :: CUid -> CUid Source # abs :: CUid -> CUid Source # signum :: CUid -> CUid Source # fromInteger :: Integer -> CUid Source #
Num Fd Source # |
Instance details Defined in System.Posix.Types Methods (+) :: Fd -> Fd -> Fd Source # (-) :: Fd -> Fd -> Fd Source # (*) :: Fd -> Fd -> Fd Source # negate :: Fd -> Fd Source # abs :: Fd -> Fd Source # signum :: Fd -> Fd Source # fromInteger :: Integer -> Fd Source #
Num Integer Source # | Since: base-2.1
Instance details Defined in GHC.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 #
Num Natural Source # | Note that `Natural`'s `Num` instance isn't a ring: no element but 0 has an additive inverse. It is a semiring though. Since: base-4.8.0.0
Instance details Defined in GHC.Num Methods (+) :: Natural -> Natural -> Natural Source # (-) :: Natural -> Natural -> Natural Source # (*) :: Natural -> Natural -> Natural Source # negate :: Natural -> Natural Source # abs :: Natural -> Natural Source # signum :: Natural -> Natural Source # fromInteger :: Integer -> Natural Source #

Num Double Source #

Note that due to the presence of `NaN`, not all elements of `Double` have an additive inverse.

    >>> 0/0 + (negate 0/0 :: Double)
    NaN

Also note that due to the presence of -0, `Double`'s `Num` instance doesn't have an additive identity

    >>> 0 + (-0 :: Double)
    0.0

Since: base-2.1

Instance details Defined in GHC.Float Methods (+) :: Double -> Double -> Double Source # (-) :: Double -> Double -> Double Source # (*) :: Double -> Double -> Double Source # negate :: Double -> Double Source # abs :: Double -> Double Source # signum :: Double -> Double Source # fromInteger :: Integer -> Double Source #

Num Float Source #

Note that due to the presence of `NaN`, not all elements of `Float` have an additive inverse.

    >>> 0/0 + (negate 0/0 :: Float)
    NaN

Also note that due to the presence of -0, `Float`'s `Num` instance doesn't have an additive identity

    >>> 0 + (-0 :: Float)
    0.0

Since: base-2.1

Instance details Defined in GHC.Float Methods (+) :: Float -> Float -> Float Source # (-) :: Float -> Float -> Float Source # (*) :: Float -> Float -> Float Source # negate :: Float -> Float Source # abs :: Float -> Float Source # signum :: Float -> Float Source # fromInteger :: Integer -> Float Source #
Num Int Source # | Since: base-2.1
Instance details Defined in GHC.Num Methods (+) :: Int -> Int -> Int Source # (-) :: Int -> Int -> Int Source # (*) :: Int -> Int -> Int Source # negate :: Int -> Int Source # abs :: Int -> Int Source # signum :: Int -> Int Source # fromInteger :: Integer -> Int Source #
Num Word Source # | Since: base-2.1
Instance details Defined in GHC.Num Methods (+) :: Word -> Word -> Word Source # (-) :: Word -> Word -> Word Source # (*) :: Word -> Word -> Word Source # negate :: Word -> Word Source # abs :: Word -> Word Source # signum :: Word -> Word Source # fromInteger :: Integer -> Word Source #
RealFloat a => Num (Complex a) Source # | Since: base-2.1
Instance details Defined in Data.Complex Methods (+) :: Complex a -> Complex a -> Complex a Source # (-) :: Complex a -> Complex a -> Complex a Source # (*) :: Complex a -> Complex a -> Complex a Source # negate :: Complex a -> Complex a Source # abs :: Complex a -> Complex a Source # signum :: Complex a -> Complex a Source # fromInteger :: Integer -> Complex a Source #
Num a => Num (Identity a) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods (+) :: Identity a -> Identity a -> Identity a Source # (-) :: Identity a -> Identity a -> Identity a Source # (*) :: Identity a -> Identity a -> Identity a Source # negate :: Identity a -> Identity a Source # abs :: Identity a -> Identity a Source # signum :: Identity a -> Identity a Source # fromInteger :: Integer -> Identity a Source #
Num a => Num (Down a) Source # | Since: base-4.11.0.0
Instance details Defined in Data.Ord Methods (+) :: Down a -> Down a -> Down a Source # (-) :: Down a -> Down a -> Down a Source # (*) :: Down a -> Down a -> Down a Source # negate :: Down a -> Down a Source # abs :: Down a -> Down a Source # signum :: Down a -> Down a Source # fromInteger :: Integer -> Down a Source #
Num a => Num (Max a) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (+) :: Max a -> Max a -> Max a Source # (-) :: Max a -> Max a -> Max a Source # (*) :: Max a -> Max a -> Max a Source # negate :: Max a -> Max a Source # abs :: Max a -> Max a Source # signum :: Max a -> Max a Source # fromInteger :: Integer -> Max a Source #
Num a => Num (Min a) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (+) :: Min a -> Min a -> Min a Source # (-) :: Min a -> Min a -> Min a Source # (*) :: Min a -> Min a -> Min a Source # negate :: Min a -> Min a Source # abs :: Min a -> Min a Source # signum :: Min a -> Min a Source # fromInteger :: Integer -> Min a Source #
Num a => Num (Product a) Source # | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal Methods (+) :: Product a -> Product a -> Product a Source # (-) :: Product a -> Product a -> Product a Source # (*) :: Product a -> Product a -> Product a Source # negate :: Product a -> Product a Source # abs :: Product a -> Product a Source # signum :: Product a -> Product a Source # fromInteger :: Integer -> Product a Source #
Num a => Num (Sum a) Source # | Since: base-4.7.0.0
Instance details Defined in Data.Semigroup.Internal Methods (+) :: Sum a -> Sum a -> Sum a Source # (-) :: Sum a -> Sum a -> Sum a Source # (*) :: Sum a -> Sum a -> Sum a Source # negate :: Sum a -> Sum a Source # abs :: Sum a -> Sum a Source # signum :: Sum a -> Sum a Source # fromInteger :: Integer -> Sum a Source #
Integral a => Num (Ratio a) Source # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods (+) :: Ratio a -> Ratio a -> Ratio a Source # (-) :: Ratio a -> Ratio a -> Ratio a Source # (*) :: Ratio a -> Ratio a -> Ratio a Source # negate :: Ratio a -> Ratio a Source # abs :: Ratio a -> Ratio a Source # signum :: Ratio a -> Ratio a Source # fromInteger :: Integer -> Ratio a Source #
HasResolution a => Num (Fixed a) Source # | Since: base-2.1
Instance details Defined in Data.Fixed Methods (+) :: Fixed a -> Fixed a -> Fixed a Source # (-) :: Fixed a -> Fixed a -> Fixed a Source # (*) :: Fixed a -> Fixed a -> Fixed a Source # negate :: Fixed a -> Fixed a Source # abs :: Fixed a -> Fixed a Source # signum :: Fixed a -> Fixed a Source # fromInteger :: Integer -> Fixed a Source #
Num a => Num (Op a b) Source # |
Instance details Defined in Data.Functor.Contravariant Methods (+) :: Op a b -> Op a b -> Op a b Source # (-) :: Op a b -> Op a b -> Op a b Source # (*) :: Op a b -> Op a b -> Op a b Source # negate :: Op a b -> Op a b Source # abs :: Op a b -> Op a b Source # signum :: Op a b -> Op a b Source # fromInteger :: Integer -> Op a b Source #
Num a => Num (Const a b) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Const Methods (+) :: Const a b -> Const a b -> Const a b Source # (-) :: Const a b -> Const a b -> Const a b Source # (*) :: Const a b -> Const a b -> Const a b Source # negate :: Const a b -> Const a b Source # abs :: Const a b -> Const a b Source # signum :: Const a b -> Const a b Source # fromInteger :: Integer -> Const a b Source #

(Applicative f, Num a) => Num (Ap f a) Source #

Note that even if the underlying `Num` and `Applicative` instances are lawful, for most `Applicative`s, this instance will not be lawful. If you use this instance with the list `Applicative`, the following customary laws will not hold:

Commutativity:

    >>> Ap [10,20] + Ap [1,2]
    Ap {getAp = [11,12,21,22]}
    >>> Ap [1,2] + Ap [10,20]
    Ap {getAp = [11,21,12,22]}

Additive inverse:

    >>> Ap [] + negate (Ap [])
    Ap {getAp = []}
    >>> fromInteger 0 :: Ap [] Int
    Ap {getAp = [0]}

Distributivity:

    >>> Ap [1,2] * (3 + 4)
    Ap {getAp = [7,14]}
    >>> (Ap [1,2] * 3) + (Ap [1,2] * 4)
    Ap {getAp = [7,11,10,14]}

Since: base-4.12.0.0

Instance details Defined in Data.Monoid Methods (+) :: Ap f a -> Ap f a -> Ap f a Source # (-) :: Ap f a -> Ap f a -> Ap f a Source # (*) :: Ap f a -> Ap f a -> Ap f a Source # negate :: Ap f a -> Ap f a Source # abs :: Ap f a -> Ap f a Source # signum :: Ap f a -> Ap f a Source # fromInteger :: Integer -> Ap f a Source #
Num (f a) => Num (Alt f a) Source # | Since: base-4.8.0.0
Instance details Defined in Data.Semigroup.Internal Methods (+) :: Alt f a -> Alt f a -> Alt f a Source # (-) :: Alt f a -> Alt f a -> Alt f a Source # (*) :: Alt f a -> Alt f a -> Alt f a Source # negate :: Alt f a -> Alt f a Source # abs :: Alt f a -> Alt f a Source # signum :: Alt f a -> Alt f a Source # fromInteger :: Integer -> Alt f a Source #

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

Deprecated: Use integerQuotRem# instead

subtract :: Num a => a -> a -> a Source #

the same as ``flip` (`-`)`.

Because `-` is treated specially in the Haskell grammar, `(-` e`)` is not a section, but an application of prefix negation. However, `(`subtract`` exp`)` is equivalent to the disallowed section.

module GHC.Num.Integer

module GHC.Num.Natural

module GHC.Natural

module GHC.Integer