Previous Next Home
Following are the basic Numeric Types supported by Haskell. All these numeric types are instances of Num.
It is bounded Integer type, represent integer values, For 32-bit machines the range goes from -2147483648 to 2147483647. For 64-bit machine the range goes from -9223372036854775808 to 9223372036854775807
It is unbounded integer type, represent arbitrarily large integer values. Size is limited by the amount of memory available on your machine.
Double precision floating point value. Used to represent real numbers like 10.32, 9.86 etc.,
Following code snippet gives you the maximum and minimum values of Int type.
biggestInt, smallestInt :: Int
biggestInt = maxBound
smallestInt = minBound
Prelude> :load variable.hs
[1 of 1] Compiling Main ( variable.hs, interpreted )
Ok, modules loaded: Main.
When a function signature supports a type T, then it can able to support all the child types of type T.
Prelude> :t (+)
(+) :: Num a => a -> a -> a
Operator + takes any variable of type Num, so it can support all sub types like Int, Integer, Float, Double.
Prelude> 10 + 90.09