| 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
Synopsis
- class Num a where
- 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
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
- fromInteger0
- x + fromInteger 0=- x
- negategives the additive inverse
- x + negate x=- fromInteger 0
- Associativity of (*)
- (x * y) * z=- x * (y * z)
- fromInteger1
- x * fromInteger 1=- xand- fromInteger 1 * x=- x
- Distributivity of (with respect to*)(+)
- a * (b + c)=- (a * b) + (a * c)and- (b + c) * a=- (b * a) + (c * a)
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.
Methods
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 #
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
| Num CBool # | |
| Num CChar # | |
| Num CClock # | |
| Num CDouble # | |
| Num CFloat # | |
| Num CInt # | |
| Num CIntMax # | |
| Num CIntPtr # | |
| Num CLLong # | |
| Num CLong # | |
| Num CPtrdiff # | |
| Num CSChar # | |
| Num CSUSeconds # | |
| Defined in Foreign.C.Types Methods (+) :: CSUSeconds -> CSUSeconds -> CSUSeconds # (-) :: CSUSeconds -> CSUSeconds -> CSUSeconds # (*) :: CSUSeconds -> CSUSeconds -> CSUSeconds # negate :: CSUSeconds -> CSUSeconds # abs :: CSUSeconds -> CSUSeconds # signum :: CSUSeconds -> CSUSeconds # fromInteger :: Integer -> CSUSeconds # | |
| Num CShort # | |
| Num CSigAtomic # | |
| Defined in Foreign.C.Types Methods (+) :: CSigAtomic -> CSigAtomic -> CSigAtomic # (-) :: CSigAtomic -> CSigAtomic -> CSigAtomic # (*) :: CSigAtomic -> CSigAtomic -> CSigAtomic # negate :: CSigAtomic -> CSigAtomic # abs :: CSigAtomic -> CSigAtomic # signum :: CSigAtomic -> CSigAtomic # fromInteger :: Integer -> CSigAtomic # | |
| Num CSize # | |
| Num CTime # | |
| Num CUChar # | |
| Num CUInt # | |
| Num CUIntMax # | |
| Num CUIntPtr # | |
| Num CULLong # | |
| Num CULong # | |
| Num CUSeconds # | |
| Defined in Foreign.C.Types | |
| Num CUShort # | |
| Num CWchar # | |
| Num IntPtr # | |
| Num WordPtr # | |
| Num Int16 # | Since: base-2.1 | 
| Num Int32 # | Since: base-2.1 | 
| Num Int64 # | Since: base-2.1 | 
| Num Int8 # | Since: base-2.1 | 
| Num Word16 # | Since: base-2.1 | 
| Num Word32 # | Since: base-2.1 | 
| Num Word64 # | Since: base-2.1 | 
| Num CBlkCnt # | |
| Num CBlkSize # | |
| Num CCc # | |
| Num CClockId # | |
| Num CDev # | |
| Num CFsBlkCnt # | |
| Defined in System.Posix.Types | |
| Num CFsFilCnt # | |
| Defined in System.Posix.Types | |
| Num CGid # | |
| Num CId # | |
| Num CIno # | |
| Num CKey # | |
| Num CMode # | |
| Num CNfds # | |
| Num CNlink # | |
| Num COff # | |
| Num CPid # | |
| Num CRLim # | |
| Num CSocklen # | |
| Num CSpeed # | |
| Num CSsize # | |
| Num CTcflag # | |
| Num CUid # | |
| Num Fd # | |
| Num Word8 # | Since: base-2.1 | 
| Num Integer # | Since: base-2.1 | 
| Num Natural # | Note that  Since: base-4.8.0.0 | 
| Num Double # | Note that due to the presence of  
 Also note that due to the presence of -0,  
 Since: base-2.1 | 
| Num Float # | Note that due to the presence of  
 Also note that due to the presence of -0,  
 Since: base-2.1 | 
| Num Int # | Since: base-2.1 | 
| Num Word # | Since: base-2.1 | 
| RealFloat a => Num (Complex a) # | Since: base-2.1 | 
| Num a => Num (Identity a) # | Since: base-4.9.0.0 | 
| Defined in Data.Functor.Identity | |
| Num a => Num (Down a) # | Since: base-4.11.0.0 | 
| Num a => Num (Max a) # | Since: base-4.9.0.0 | 
| Num a => Num (Min a) # | Since: base-4.9.0.0 | 
| Num a => Num (Product a) # | Since: base-4.7.0.0 | 
| Defined in Data.Semigroup.Internal | |
| Num a => Num (Sum a) # | Since: base-4.7.0.0 | 
| Integral a => Num (Ratio a) # | Since: base-2.0.1 | 
| HasResolution a => Num (Fixed a) # | Since: base-2.1 | 
| Num a => Num (Op a b) # | |
| Num a => Num (Const a b) # | Since: base-4.9.0.0 | 
| Defined in Data.Functor.Const | |
| (Applicative f, Num a) => Num (Ap f a) # | Note that even if the underlying  Commutativity: 
 Additive inverse: 
 Distributivity: 
 Since: base-4.12.0.0 | 
| Num (f a) => Num (Alt f a) # | Since: base-4.8.0.0 | 
quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) #
Deprecated: Use integerQuotRem# instead
module GHC.Num.Integer
module GHC.Num.Natural
module GHC.Natural
module GHC.Integer