| 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
 - subtract :: Num a => a -> a -> a
 - module GHC.Integer
 - module GHC.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 + xis the additive identityfromInteger0x + fromInteger 0=xnegategives the additive inversex + negate x=fromInteger 0- Associativity of 
(*) (x * y) * z=x * (y * z)is the multiplicative identityfromInteger1x * fromInteger 1=xandfromInteger 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
(+) :: 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
module GHC.Integer
module GHC.Natural