Int package:universum
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.
16-bit signed integer type
32-bit signed integer type
64-bit signed integer type
8-bit signed integer type
Arbitrary precision integers. In contrast with fixed-size integral
types such as
Int, the
Integer type represents the
entire infinite range of integers.
Integers are stored in a kind of sign-magnitude form, hence do not
expect two's complement form when using bit operations.
If the value is small (fit into an
Int),
IS constructor
is used. Otherwise
Integer and
IN constructors are used
to store a
BigNat representing respectively the positive or the
negative value magnitude.
Invariant:
Integer and
IN are used iff value doesn't fit
in
IS
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.
In addition,
toInteger should be total, and
fromInteger
should be a left inverse for it, i.e.
fromInteger (toInteger i) =
i.
A map of integers to values a.
You may import this module to define your own, custom instances of
Print. Be advised however that this module is an internal API
and may be subject to change
even for minor version increments.
intercalate xs xss is equivalent to
(concat
(intersperse xs xss)). It inserts the list
xs in
between the lists in
xss and concatenates the result.
>>> intercalate ", " ["Lorem", "ipsum", "dolor"]
"Lorem, ipsum, dolor"
The
intersperse function takes an element and a
list and `intersperses' that element between the elements of the list.
For example,
>>> intersperse ',' "abcde"
"a,b,c,d,e"
The kind of lifted constraints
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.
WARNING: This function performs silent truncation if the result type
is not at least as big as the argument's type.
Like
mask, but the masked computation is not interruptible (see
Control.Exception's
uninterruptibleMask. WARNING: Only
use if you need to mask exceptions around an interruptible operation
AND you can guarantee the interruptible operation will only block for
a short period of time. Otherwise you render the program/thread
unresponsive and/or unkillable.
Generalizes the
putStr family of functions for String likes
such as lazy and strict versions of
Text and
ByteString.
A caveat to using overloaded functions is that printing string
literals raises ambiguity errors in the presence of
OverloadedStrings. To avoid this problem wither add a type
annotation
putStr ("Hello World!" :: Text) or use one of the
type constrained functions
putText,
putLText etc.
You may add support for your own types by importing
Universum.Print.Internal and implementing
Print. However
be advised that only the functions in this module should be considered
stable, not the interface for
Print.
Support class to overload writing of string like values.