Safe HaskellSafe

Eta.Classes.Num

Description

The Num type class defines basic numerical operations:

  • Addition (+)
  • Subtraction (-)
  • Multiplication (*)
  • Negation (negate)
  • Absolute value (absoluteValue)
  • Sign of a number (numberSign)
  • Conversion from Integer (fromInteger)

Synopsis

Documentation

class Num a where #

Minimal complete definition

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

Methods

(+) :: a -> a -> a #

(-) :: a -> a -> a #

(*) :: a -> a -> a #

negate :: a -> a #

abs :: a -> a #

signum :: a -> a #

fromInteger :: Integer -> a #

Instances

Num Int 

Methods

(+) :: Int -> Int -> Int #

(-) :: Int -> Int -> Int #

(*) :: Int -> Int -> Int #

negate :: Int -> Int #

abs :: Int -> Int #

signum :: Int -> Int #

fromInteger :: Integer -> Int #

Num Int8 

Methods

(+) :: Int8 -> Int8 -> Int8 #

(-) :: Int8 -> Int8 -> Int8 #

(*) :: Int8 -> Int8 -> Int8 #

negate :: Int8 -> Int8 #

abs :: Int8 -> Int8 #

signum :: Int8 -> Int8 #

fromInteger :: Integer -> Int8 #

Num Int16 

Methods

(+) :: Int16 -> Int16 -> Int16 #

(-) :: Int16 -> Int16 -> Int16 #

(*) :: Int16 -> Int16 -> Int16 #

negate :: Int16 -> Int16 #

abs :: Int16 -> Int16 #

signum :: Int16 -> Int16 #

fromInteger :: Integer -> Int16 #

Num Int32 

Methods

(+) :: Int32 -> Int32 -> Int32 #

(-) :: Int32 -> Int32 -> Int32 #

(*) :: Int32 -> Int32 -> Int32 #

negate :: Int32 -> Int32 #

abs :: Int32 -> Int32 #

signum :: Int32 -> Int32 #

fromInteger :: Integer -> Int32 #

Num Int64 

Methods

(+) :: Int64 -> Int64 -> Int64 #

(-) :: Int64 -> Int64 -> Int64 #

(*) :: Int64 -> Int64 -> Int64 #

negate :: Int64 -> Int64 #

abs :: Int64 -> Int64 #

signum :: Int64 -> Int64 #

fromInteger :: Integer -> Int64 #

Num Integer 

Methods

(+) :: Integer -> Integer -> Integer #

(-) :: Integer -> Integer -> Integer #

(*) :: Integer -> Integer -> Integer #

negate :: Integer -> Integer #

abs :: Integer -> Integer #

signum :: Integer -> Integer #

fromInteger :: Integer -> Integer #

Num Word 

Methods

(+) :: Word -> Word -> Word #

(-) :: Word -> Word -> Word #

(*) :: Word -> Word -> Word #

negate :: Word -> Word #

abs :: Word -> Word #

signum :: Word -> Word #

fromInteger :: Integer -> Word #

Integral a => Num (Ratio a) 

Methods

(+) :: Ratio a -> Ratio a -> Ratio a #

(-) :: Ratio a -> Ratio a -> Ratio a #

(*) :: Ratio a -> Ratio a -> Ratio a #

negate :: Ratio a -> Ratio a #

abs :: Ratio a -> Ratio a #

signum :: Ratio a -> Ratio a #

fromInteger :: Integer -> Ratio a #

Num a => Num (Sum a) 

Methods

(+) :: Sum a -> Sum a -> Sum a #

(-) :: Sum a -> Sum a -> Sum a #

(*) :: Sum a -> Sum a -> Sum a #

negate :: Sum a -> Sum a #

abs :: Sum a -> Sum a #

signum :: Sum a -> Sum a #

fromInteger :: Integer -> Sum a #

Num a => Num (Product a) 

Methods

(+) :: Product a -> Product a -> Product a #

(-) :: Product a -> Product a -> Product a #

(*) :: Product a -> Product a -> Product a #

negate :: Product a -> Product a #

abs :: Product a -> Product a #

signum :: Product a -> Product a #

fromInteger :: Integer -> Product a #

Num (f a) => Num (Alt k f a) 

Methods

(+) :: Alt k f a -> Alt k f a -> Alt k f a #

(-) :: Alt k f a -> Alt k f a -> Alt k f a #

(*) :: Alt k f a -> Alt k f a -> Alt k f a #

negate :: Alt k f a -> Alt k f a #

abs :: Alt k f a -> Alt k f a #

signum :: Alt k f a -> Alt k f a #

fromInteger :: Integer -> Alt k f a #

absoluteValue :: Num a => a -> a #

Returns the absolute value

>>> absoluteValue (-1)
1
>>> absoluteValue 1
1

numberSign :: Num a => a -> a #

Returns the number sign

>>> numberSign (-4)
-1
>>> numberSign 9
1
>>> numberSign 0
0