protolude-0.3.2: A small prelude.

Protolude

Synopsis

# Base functions

(++) :: [a] -> [a] -> [a] infixr 5 #

Append two lists, i.e.,

[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]

If the first list is not finite, the result is the first list.

seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b infixr 0 #

The value of seq a b is bottom if a is bottom, and otherwise equal to b. In other words, it evaluates the first argument a to weak head normal form (WHNF). seq is usually introduced to improve performance by avoiding unneeded laziness.

A note on evaluation order: the expression seq a b does not guarantee that a will be evaluated before b. The only guarantee given by seq is that the both a and b will be evaluated before seq returns a value. In particular, this means that b may be evaluated before a. If you need to guarantee a specific order of evaluation, you must use the function pseq from the "parallel" package.

fromIntegral :: (Integral a, Num b) => a -> b #

general coercion from integral types

realToFrac :: (Real a, Fractional b) => a -> b #

general coercion to fractional types

class Bounded a where #

The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.

The Bounded class may be derived for any enumeration type; minBound is the first constructor listed in the data declaration and maxBound is the last. Bounded may also be derived for single-constructor datatypes whose constituent types are in Bounded.

Methods

minBound :: a #

maxBound :: a #

#### Instances

Instances details
 Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-4.10.0.0 Instance detailsDefined in GHC.Enum Methods Since: base-4.10.0.0 Instance detailsDefined in GHC.Enum Methods Bounded () Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: () #maxBound :: () # Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.Ptr Methods Instance detailsDefined in Foreign.Ptr Methods Since: base-2.1 Instance detailsDefined in GHC.Unicode Methods Source # Instance detailsDefined in Protolude.Conv Methods Bounded a => Bounded (Min a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup MethodsminBound :: Min a #maxBound :: Min a # Bounded a => Bounded (Max a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup MethodsminBound :: Max a #maxBound :: Max a # Bounded a => Bounded (First a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods Bounded a => Bounded (Last a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods Bounded m => Bounded (WrappedMonoid m) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods Bounded a => Bounded (Identity a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Identity Methods Bounded a => Bounded (Dual a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods Bounded a => Bounded (Sum a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal MethodsminBound :: Sum a #maxBound :: Sum a # Bounded a => Bounded (Product a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods Bounded a => Bounded (Down a) Since: base-4.14.0.0 Instance detailsDefined in Data.Ord Methods (Bounded a, Bounded b) => Bounded (a, b) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b) #maxBound :: (a, b) # Bounded (Proxy t) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methods (Bounded a, Bounded b, Bounded c) => Bounded (a, b, c) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c) #maxBound :: (a, b, c) # Bounded a => Bounded (Const a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const MethodsminBound :: Const a b #maxBound :: Const a b # (Applicative f, Bounded a) => Bounded (Ap f a) Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid MethodsminBound :: Ap f a #maxBound :: Ap f a # Coercible a b => Bounded (Coercion a b) Since: base-4.7.0.0 Instance detailsDefined in Data.Type.Coercion MethodsminBound :: Coercion a b #maxBound :: Coercion a b # a ~ b => Bounded (a :~: b) Since: base-4.7.0.0 Instance detailsDefined in Data.Type.Equality MethodsminBound :: a :~: b #maxBound :: a :~: b # (Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d) #maxBound :: (a, b, c, d) # a ~~ b => Bounded (a :~~: b) Since: base-4.10.0.0 Instance detailsDefined in Data.Type.Equality MethodsminBound :: a :~~: b #maxBound :: a :~~: b # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a, b, c, d, e) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e) #maxBound :: (a, b, c, d, e) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded (a, b, c, d, e, f) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f) #maxBound :: (a, b, c, d, e, f) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g) => Bounded (a, b, c, d, e, f, g) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g) #maxBound :: (a, b, c, d, e, f, g) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h) => Bounded (a, b, c, d, e, f, g, h) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h) #maxBound :: (a, b, c, d, e, f, g, h) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i) => Bounded (a, b, c, d, e, f, g, h, i) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i) #maxBound :: (a, b, c, d, e, f, g, h, i) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j) => Bounded (a, b, c, d, e, f, g, h, i, j) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j) #maxBound :: (a, b, c, d, e, f, g, h, i, j) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k) => Bounded (a, b, c, d, e, f, g, h, i, j, k) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n, Bounded o) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) #

class Enum a where #

Class Enum defines operations on sequentially ordered types.

The enumFrom... methods are used in Haskell's translation of arithmetic sequences.

Instances of Enum may be derived for any enumeration type (types whose constructors have no fields). The nullary constructors are assumed to be numbered left-to-right by fromEnum from 0 through n-1. See Chapter 10 of the Haskell Report for more details.

For any type that is an instance of class Bounded as well as Enum, the following should hold:

• The calls succ maxBound and pred minBound should result in a runtime error.
• fromEnum and toEnum should give a runtime error if the result value is not representable in the result type. For example, toEnum 7 :: Bool is an error.
• enumFrom and enumFromThen should be defined with an implicit bound, thus:
   enumFrom     x   = enumFromTo     x maxBound
enumFromThen x y = enumFromThenTo x y bound
where
| otherwise                = minBound

Minimal complete definition

Methods

succ :: a -> a #

the successor of a value. For numeric types, succ adds 1.

pred :: a -> a #

the predecessor of a value. For numeric types, pred subtracts 1.

toEnum :: Int -> a #

Convert from an Int.

fromEnum :: a -> Int #

Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.

enumFrom :: a -> [a] #

Used in Haskell's translation of [n..] with [n..] = enumFrom n, a possible implementation being enumFrom n = n : enumFrom (succ n). For example:

• enumFrom 4 :: [Integer] = [4,5,6,7,...]
• enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: Int]

enumFromThen :: a -> a -> [a] #

Used in Haskell's translation of [n,n'..] with [n,n'..] = enumFromThen n n', a possible implementation being enumFromThen n n' = n : n' : worker (f x) (f x n'), worker s v = v : worker s (s v), x = fromEnum n' - fromEnum n and f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y For example:

• enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
• enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: Int]

enumFromTo :: a -> a -> [a] #

Used in Haskell's translation of [n..m] with [n..m] = enumFromTo n m, a possible implementation being enumFromTo n m | n <= m = n : enumFromTo (succ n) m | otherwise = []. For example:

• enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
• enumFromTo 42 1 :: [Integer] = []

enumFromThenTo :: a -> a -> a -> [a] #

Used in Haskell's translation of [n,n'..m] with [n,n'..m] = enumFromThenTo n n' m, a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m, x = fromEnum n' - fromEnum n, c x = bool (>=) ((x 0) f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y and worker s c v m | c v m = v : worker s c (s v) m | otherwise = [] For example:

• enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
• enumFromThenTo 6 8 2 :: [Int] = []

#### Instances

Instances details

class Fractional a => Floating a where #

Trigonometric and hyperbolic functions and related functions.

The Haskell Report defines no laws for Floating. However, (+), (*) and exp are customarily expected to define an exponential field and have the following properties:

• exp (a + b) = exp a * exp b
• exp (fromInteger 0) = fromInteger 1

Minimal complete definition

Methods

pi :: a #

exp :: a -> a #

log :: a -> a #

sqrt :: a -> a #

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

logBase :: a -> a -> a #

sin :: a -> a #

cos :: a -> a #

tan :: a -> a #

asin :: a -> a #

acos :: a -> a #

atan :: a -> a #

sinh :: a -> a #

cosh :: a -> a #

tanh :: a -> a #

asinh :: a -> a #

acosh :: a -> a #

atanh :: a -> a #

log1p :: a -> a #

log1p x computes log (1 + x), but provides more precise results for small (absolute) values of x if possible.

Since: base-4.9.0.0

expm1 :: a -> a #

expm1 x computes exp x - 1, but provides more precise results for small (absolute) values of x if possible.

Since: base-4.9.0.0

log1pexp :: a -> a #

log1pexp x computes log (1 + exp x), but provides more precise results if possible.

Examples:

• if x is a large negative number, log (1 + exp x) will be imprecise for the reasons given in log1p.
• if exp x is close to -1, log (1 + exp x) will be imprecise for the reasons given in expm1.

Since: base-4.9.0.0

log1mexp :: a -> a #

log1mexp x computes log (1 - exp x), but provides more precise results if possible.

Examples:

• if x is a large negative number, log (1 - exp x) will be imprecise for the reasons given in log1p.
• if exp x is close to 1, log (1 - exp x) will be imprecise for the reasons given in expm1.

Since: base-4.9.0.0

#### Instances

Instances details
 Since: base-2.1 Instance detailsDefined in GHC.Float Methodsexp :: Double -> Double #log :: Double -> Double #(**) :: Double -> Double -> Double #sin :: Double -> Double #cos :: Double -> Double #tan :: Double -> Double # Since: base-2.1 Instance detailsDefined in GHC.Float Methodspi :: Float #exp :: Float -> Float #log :: Float -> Float #sqrt :: Float -> Float #(**) :: Float -> Float -> Float #logBase :: Float -> Float -> Float #sin :: Float -> Float #cos :: Float -> Float #tan :: Float -> Float #asin :: Float -> Float #acos :: Float -> Float #atan :: Float -> Float #sinh :: Float -> Float #cosh :: Float -> Float #tanh :: Float -> Float #asinh :: Float -> Float #acosh :: Float -> Float #atanh :: Float -> Float #log1p :: Float -> Float #expm1 :: Float -> Float # Instance detailsDefined in Foreign.C.Types Methodsexp :: CFloat -> CFloat #log :: CFloat -> CFloat #(**) :: CFloat -> CFloat -> CFloat #sin :: CFloat -> CFloat #cos :: CFloat -> CFloat #tan :: CFloat -> CFloat # Instance detailsDefined in Foreign.C.Types Methods RealFloat a => Floating (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methodspi :: Complex a #exp :: Complex a -> Complex a #log :: Complex a -> Complex a #sqrt :: Complex a -> Complex a #(**) :: Complex a -> Complex a -> Complex a #logBase :: Complex a -> Complex a -> Complex a #sin :: Complex a -> Complex a #cos :: Complex a -> Complex a #tan :: Complex a -> Complex a #asin :: Complex a -> Complex a #acos :: Complex a -> Complex a #atan :: Complex a -> Complex a #sinh :: Complex a -> Complex a #cosh :: Complex a -> Complex a #tanh :: Complex a -> Complex a #asinh :: Complex a -> Complex a #acosh :: Complex a -> Complex a #atanh :: Complex a -> Complex a #log1p :: Complex a -> Complex a #expm1 :: Complex a -> Complex a #log1pexp :: Complex a -> Complex a #log1mexp :: Complex a -> Complex a # Floating a => Floating (Identity a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Identity Methodspi :: Identity a #exp :: Identity a -> Identity a #log :: Identity a -> Identity a #sqrt :: Identity a -> Identity a #(**) :: Identity a -> Identity a -> Identity a #logBase :: Identity a -> Identity a -> Identity a #sin :: Identity a -> Identity a #cos :: Identity a -> Identity a #tan :: Identity a -> Identity a #asin :: Identity a -> Identity a #acos :: Identity a -> Identity a #atan :: Identity a -> Identity a #sinh :: Identity a -> Identity a #cosh :: Identity a -> Identity a #tanh :: Identity a -> Identity a #asinh :: Identity a -> Identity a #acosh :: Identity a -> Identity a #atanh :: Identity a -> Identity a #log1p :: Identity a -> Identity a #expm1 :: Identity a -> Identity a #log1pexp :: Identity a -> Identity a #log1mexp :: Identity a -> Identity a # Floating a => Floating (Down a) Since: base-4.14.0.0 Instance detailsDefined in Data.Ord Methodspi :: Down a #exp :: Down a -> Down a #log :: Down a -> Down a #sqrt :: Down a -> Down a #(**) :: Down a -> Down a -> Down a #logBase :: Down a -> Down a -> Down a #sin :: Down a -> Down a #cos :: Down a -> Down a #tan :: Down a -> Down a #asin :: Down a -> Down a #acos :: Down a -> Down a #atan :: Down a -> Down a #sinh :: Down a -> Down a #cosh :: Down a -> Down a #tanh :: Down a -> Down a #asinh :: Down a -> Down a #acosh :: Down a -> Down a #atanh :: Down a -> Down a #log1p :: Down a -> Down a #expm1 :: Down a -> Down a #log1pexp :: Down a -> Down a #log1mexp :: Down a -> Down a # Floating a => Floating (Const a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const Methodspi :: Const a b #exp :: Const a b -> Const a b #log :: Const a b -> Const a b #sqrt :: Const a b -> Const a b #(**) :: Const a b -> Const a b -> Const a b #logBase :: Const a b -> Const a b -> Const a b #sin :: Const a b -> Const a b #cos :: Const a b -> Const a b #tan :: Const a b -> Const a b #asin :: Const a b -> Const a b #acos :: Const a b -> Const a b #atan :: Const a b -> Const a b #sinh :: Const a b -> Const a b #cosh :: Const a b -> Const a b #tanh :: Const a b -> Const a b #asinh :: Const a b -> Const a b #acosh :: Const a b -> Const a b #atanh :: Const a b -> Const a b #log1p :: Const a b -> Const a b #expm1 :: Const a b -> Const a b #log1pexp :: Const a b -> Const a b #log1mexp :: Const a b -> Const a b #

class Num a => Fractional a where #

Fractional numbers, supporting real division.

The Haskell Report defines no laws for Fractional. However, (+) and (*) are customarily expected to define a division ring and have the following properties:

recip gives the multiplicative inverse
x * recip x = recip x * x = fromInteger 1

Note that it isn't customarily expected that a type instance of Fractional implement a field. However, all instances in base do.

Minimal complete definition

fromRational, (recip | (/))

Methods

(/) :: a -> a -> a infixl 7 #

Fractional division.

recip :: a -> a #

Reciprocal fraction.

fromRational :: Rational -> a #

Conversion from a Rational (that is Ratio Integer). A floating literal stands for an application of fromRational to a value of type Rational, so such literals have type (Fractional a) => a.

#### Instances

Instances details
 Instance detailsDefined in Foreign.C.Types Methods(/) :: CFloat -> CFloat -> CFloat # Instance detailsDefined in Foreign.C.Types Methods Integral a => Fractional (Ratio a) Since: base-2.0.1 Instance detailsDefined in GHC.Real Methods(/) :: Ratio a -> Ratio a -> Ratio a #recip :: Ratio a -> Ratio a # RealFloat a => Fractional (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methods(/) :: Complex a -> Complex a -> Complex a #recip :: Complex a -> Complex a # Fractional a => Fractional (Identity a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Identity Methods(/) :: Identity a -> Identity a -> Identity a #recip :: Identity a -> Identity a # Fractional a => Fractional (Down a) Since: base-4.14.0.0 Instance detailsDefined in Data.Ord Methods(/) :: Down a -> Down a -> Down a #recip :: Down a -> Down a # Fractional a => Fractional (Const a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const Methods(/) :: Const a b -> Const a b -> Const a b #recip :: Const a b -> Const a b #fromRational :: Rational -> Const a b #

class (Real a, Enum a) => Integral a where #

Integral numbers, supporting integer division.

The Haskell Report defines no laws for Integral. However, Integral instances are customarily expected to define a Euclidean domain and have the following properties for the div/mod and quot/rem pairs, given suitable Euclidean functions f and g:

• x = y * quot x y + rem x y with rem x y = fromInteger 0 or g (rem x y) < g y
• x = y * div x y + mod x y with mod x y = fromInteger 0 or f (mod x y) < f y

An example of a suitable Euclidean function, for Integer's instance, is abs.

Minimal complete definition

Methods

quot :: a -> a -> a infixl 7 #

integer division truncated toward zero

rem :: a -> a -> a infixl 7 #

integer remainder, satisfying

(x quot y)*y + (x rem y) == x

div :: a -> a -> a infixl 7 #

integer division truncated toward negative infinity

mod :: a -> a -> a infixl 7 #

integer modulus, satisfying

(x div y)*y + (x mod y) == x

quotRem :: a -> a -> (a, a) #

simultaneous quot and rem

divMod :: a -> a -> (a, a) #

simultaneous div and mod

toInteger :: a -> Integer #

conversion to Integer

#### Instances

Instances details

class Num a where #

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)

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 #

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

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

negate :: a -> a #

Unary negation.

abs :: a -> a #

Absolute value.

signum :: a -> a #

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

Instances details
 Since: base-2.1 Instance detailsDefined in GHC.Num Methods(+) :: Int -> Int -> Int #(-) :: Int -> Int -> Int #(*) :: Int -> Int -> Int #negate :: Int -> Int #abs :: Int -> Int #signum :: Int -> Int # Since: base-2.1 Instance detailsDefined in GHC.Int Methods(+) :: Int8 -> Int8 -> Int8 #(-) :: Int8 -> Int8 -> Int8 #(*) :: Int8 -> Int8 -> Int8 #negate :: Int8 -> Int8 #abs :: Int8 -> Int8 #signum :: Int8 -> Int8 # Since: base-2.1 Instance detailsDefined in GHC.Int Methods(+) :: Int16 -> Int16 -> Int16 #(-) :: Int16 -> Int16 -> Int16 #(*) :: Int16 -> Int16 -> Int16 #abs :: Int16 -> Int16 # Since: base-2.1 Instance detailsDefined in GHC.Int Methods(+) :: Int32 -> Int32 -> Int32 #(-) :: Int32 -> Int32 -> Int32 #(*) :: Int32 -> Int32 -> Int32 #abs :: Int32 -> Int32 # Since: base-2.1 Instance detailsDefined in GHC.Int Methods(+) :: Int64 -> Int64 -> Int64 #(-) :: Int64 -> Int64 -> Int64 #(*) :: Int64 -> Int64 -> Int64 #abs :: Int64 -> Int64 # Since: base-2.1 Instance detailsDefined in GHC.Num Methods 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 detailsDefined in GHC.Num Methods Since: base-2.1 Instance detailsDefined in GHC.Num Methods(+) :: Word -> Word -> Word #(-) :: Word -> Word -> Word #(*) :: Word -> Word -> Word #negate :: Word -> Word #abs :: Word -> Word #signum :: Word -> Word # Since: base-2.1 Instance detailsDefined in GHC.Word Methods(+) :: Word8 -> Word8 -> Word8 #(-) :: Word8 -> Word8 -> Word8 #(*) :: Word8 -> Word8 -> Word8 #abs :: Word8 -> Word8 # Since: base-2.1 Instance detailsDefined in GHC.Word Methods(+) :: Word16 -> Word16 -> Word16 #(-) :: Word16 -> Word16 -> Word16 #(*) :: Word16 -> Word16 -> Word16 #abs :: Word16 -> Word16 # Since: base-2.1 Instance detailsDefined in GHC.Word Methods(+) :: Word32 -> Word32 -> Word32 #(-) :: Word32 -> Word32 -> Word32 #(*) :: Word32 -> Word32 -> Word32 #abs :: Word32 -> Word32 # Since: base-2.1 Instance detailsDefined in GHC.Word Methods(+) :: Word64 -> Word64 -> Word64 #(-) :: Word64 -> Word64 -> Word64 #(*) :: Word64 -> Word64 -> Word64 #abs :: Word64 -> Word64 # Instance detailsDefined in System.Posix.Types Methods(+) :: CDev -> CDev -> CDev #(-) :: CDev -> CDev -> CDev #(*) :: CDev -> CDev -> CDev #negate :: CDev -> CDev #abs :: CDev -> CDev #signum :: CDev -> CDev # Instance detailsDefined in System.Posix.Types Methods(+) :: CIno -> CIno -> CIno #(-) :: CIno -> CIno -> CIno #(*) :: CIno -> CIno -> CIno #negate :: CIno -> CIno #abs :: CIno -> CIno #signum :: CIno -> CIno # Instance detailsDefined in System.Posix.Types Methods(+) :: CMode -> CMode -> CMode #(-) :: CMode -> CMode -> CMode #(*) :: CMode -> CMode -> CMode #abs :: CMode -> CMode # Instance detailsDefined in System.Posix.Types Methods(+) :: COff -> COff -> COff #(-) :: COff -> COff -> COff #(*) :: COff -> COff -> COff #negate :: COff -> COff #abs :: COff -> COff #signum :: COff -> COff # Instance detailsDefined in System.Posix.Types Methods(+) :: CPid -> CPid -> CPid #(-) :: CPid -> CPid -> CPid #(*) :: CPid -> CPid -> CPid #negate :: CPid -> CPid #abs :: CPid -> CPid #signum :: CPid -> CPid # Instance detailsDefined in System.Posix.Types Methods(+) :: CSsize -> CSsize -> CSsize #(-) :: CSsize -> CSsize -> CSsize #(*) :: CSsize -> CSsize -> CSsize #abs :: CSsize -> CSsize # Instance detailsDefined in System.Posix.Types Methods(+) :: CGid -> CGid -> CGid #(-) :: CGid -> CGid -> CGid #(*) :: CGid -> CGid -> CGid #negate :: CGid -> CGid #abs :: CGid -> CGid #signum :: CGid -> CGid # Instance detailsDefined in System.Posix.Types Methods(+) :: CNlink -> CNlink -> CNlink #(-) :: CNlink -> CNlink -> CNlink #(*) :: CNlink -> CNlink -> CNlink #abs :: CNlink -> CNlink # Instance detailsDefined in System.Posix.Types Methods(+) :: CUid -> CUid -> CUid #(-) :: CUid -> CUid -> CUid #(*) :: CUid -> CUid -> CUid #negate :: CUid -> CUid #abs :: CUid -> CUid #signum :: CUid -> CUid # Instance detailsDefined in System.Posix.Types Methods(+) :: CCc -> CCc -> CCc #(-) :: CCc -> CCc -> CCc #(*) :: CCc -> CCc -> CCc #negate :: CCc -> CCc #abs :: CCc -> CCc #signum :: CCc -> CCc # Instance detailsDefined in System.Posix.Types Methods(+) :: CSpeed -> CSpeed -> CSpeed #(-) :: CSpeed -> CSpeed -> CSpeed #(*) :: CSpeed -> CSpeed -> CSpeed #abs :: CSpeed -> CSpeed # Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods(+) :: CRLim -> CRLim -> CRLim #(-) :: CRLim -> CRLim -> CRLim #(*) :: CRLim -> CRLim -> CRLim #abs :: CRLim -> CRLim # Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods(+) :: CId -> CId -> CId #(-) :: CId -> CId -> CId #(*) :: CId -> CId -> CId #negate :: CId -> CId #abs :: CId -> CId #signum :: CId -> CId # Instance detailsDefined in System.Posix.Types Methods(+) :: CKey -> CKey -> CKey #(-) :: CKey -> CKey -> CKey #(*) :: CKey -> CKey -> CKey #negate :: CKey -> CKey #abs :: CKey -> CKey #signum :: CKey -> CKey # Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods(+) :: CNfds -> CNfds -> CNfds #(-) :: CNfds -> CNfds -> CNfds #(*) :: CNfds -> CNfds -> CNfds #abs :: CNfds -> CNfds # Instance detailsDefined in System.Posix.Types Methods(+) :: Fd -> Fd -> Fd #(-) :: Fd -> Fd -> Fd #(*) :: Fd -> Fd -> Fd #negate :: Fd -> Fd #abs :: Fd -> Fd #signum :: Fd -> Fd # Instance detailsDefined in Foreign.C.Types Methods(+) :: CChar -> CChar -> CChar #(-) :: CChar -> CChar -> CChar #(*) :: CChar -> CChar -> CChar #abs :: CChar -> CChar # Instance detailsDefined in Foreign.C.Types Methods(+) :: CSChar -> CSChar -> CSChar #(-) :: CSChar -> CSChar -> CSChar #(*) :: CSChar -> CSChar -> CSChar #abs :: CSChar -> CSChar # Instance detailsDefined in Foreign.C.Types Methods(+) :: CUChar -> CUChar -> CUChar #(-) :: CUChar -> CUChar -> CUChar #(*) :: CUChar -> CUChar -> CUChar #abs :: CUChar -> CUChar # Instance detailsDefined in Foreign.C.Types Methods(+) :: CShort -> CShort -> CShort #(-) :: CShort -> CShort -> CShort #(*) :: CShort -> CShort -> CShort #abs :: CShort -> CShort # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods(+) :: CInt -> CInt -> CInt #(-) :: CInt -> CInt -> CInt #(*) :: CInt -> CInt -> CInt #negate :: CInt -> CInt #abs :: CInt -> CInt #signum :: CInt -> CInt # Instance detailsDefined in Foreign.C.Types Methods(+) :: CUInt -> CUInt -> CUInt #(-) :: CUInt -> CUInt -> CUInt #(*) :: CUInt -> CUInt -> CUInt #abs :: CUInt -> CUInt # Instance detailsDefined in Foreign.C.Types Methods(+) :: CLong -> CLong -> CLong #(-) :: CLong -> CLong -> CLong #(*) :: CLong -> CLong -> CLong #abs :: CLong -> CLong # Instance detailsDefined in Foreign.C.Types Methods(+) :: CULong -> CULong -> CULong #(-) :: CULong -> CULong -> CULong #(*) :: CULong -> CULong -> CULong #abs :: CULong -> CULong # Instance detailsDefined in Foreign.C.Types Methods(+) :: CLLong -> CLLong -> CLLong #(-) :: CLLong -> CLLong -> CLLong #(*) :: CLLong -> CLLong -> CLLong #abs :: CLLong -> CLLong # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods(+) :: CBool -> CBool -> CBool #(-) :: CBool -> CBool -> CBool #(*) :: CBool -> CBool -> CBool #abs :: CBool -> CBool # Instance detailsDefined in Foreign.C.Types Methods(+) :: CFloat -> CFloat -> CFloat #(-) :: CFloat -> CFloat -> CFloat #(*) :: CFloat -> CFloat -> CFloat #abs :: CFloat -> CFloat # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods(+) :: CSize -> CSize -> CSize #(-) :: CSize -> CSize -> CSize #(*) :: CSize -> CSize -> CSize #abs :: CSize -> CSize # Instance detailsDefined in Foreign.C.Types Methods(+) :: CWchar -> CWchar -> CWchar #(-) :: CWchar -> CWchar -> CWchar #(*) :: CWchar -> CWchar -> CWchar #abs :: CWchar -> CWchar # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods(+) :: CClock -> CClock -> CClock #(-) :: CClock -> CClock -> CClock #(*) :: CClock -> CClock -> CClock #abs :: CClock -> CClock # Instance detailsDefined in Foreign.C.Types Methods(+) :: CTime -> CTime -> CTime #(-) :: CTime -> CTime -> CTime #(*) :: CTime -> CTime -> CTime #abs :: CTime -> CTime # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.Ptr Methods Instance detailsDefined in Foreign.Ptr Methods(+) :: IntPtr -> IntPtr -> IntPtr #(-) :: IntPtr -> IntPtr -> IntPtr #(*) :: IntPtr -> IntPtr -> IntPtr #abs :: IntPtr -> IntPtr # Num CodePoint Instance detailsDefined in Data.Text.Encoding Methods(+) :: CodePoint -> CodePoint -> CodePoint #(-) :: CodePoint -> CodePoint -> CodePoint #(*) :: CodePoint -> CodePoint -> CodePoint #negate :: CodePoint -> CodePoint #abs :: CodePoint -> CodePoint #signum :: CodePoint -> CodePoint #fromInteger :: Integer -> CodePoint # Num DecoderState Instance detailsDefined in Data.Text.Encoding Methods(+) :: DecoderState -> DecoderState -> DecoderState #(-) :: DecoderState -> DecoderState -> DecoderState #(*) :: DecoderState -> DecoderState -> DecoderState #negate :: DecoderState -> DecoderState #abs :: DecoderState -> DecoderState #signum :: DecoderState -> DecoderState #fromInteger :: Integer -> DecoderState # Integral a => Num (Ratio a) Since: base-2.0.1 Instance detailsDefined in GHC.Real Methods(+) :: Ratio a -> Ratio a -> Ratio a #(-) ::