Int package:prelude-compat
A fixed-precision integer type with at least the range
[-2^29 ..
2^29-1]. The exact range for a given implementation can be
determined by using
minBound and
maxBound from the
Bounded class.
Invariant:
Jn# and
Jp# are used iff value doesn't fit in
S#
Useful properties resulting from the invariants:
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.
The
interact function takes a function of type
String->String as its argument. The entire input from the
standard input device is passed to this function as its argument, and
the resulting string is output on the standard output device.
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.
general coercion from integral types
The
print function outputs a value of any printable type to the
standard output device. Printable types are those that are instances
of class
Show;
print converts values to strings for
output using the
show operation and adds a newline.
For example, a program to print the first 20 integers and their powers
of 2 could be written as:
main = print ([(n, 2^n) | n <- [0..19]])