Int package:protolude

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.
A map of integers to values a.
A signed integral type that can be losslessly converted to and from Ptr. This type is also compatible with the C99 type intptr_t, and can be marshalled to and from that type safely.
A set of integers.
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 IP and IN constructors are used to store a BigNat representing respectively the positive or the negative value magnitude. Invariant: IP 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.
Convert an Int in the range 0..15 to the corresponding single digit Char. This function fails on other inputs, and generates lower-case hexadecimal digits.
The interact function takes a function of type Text -> Text 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.
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.

Laziness

intercalate has the following properties:
>>> take 5 (intercalate undefined ("Lorem" : undefined))
"Lorem"
>>> take 6 (intercalate ", " ("Lorem" : undefined))
"Lorem*** Exception: Prelude.undefined

Examples

>>> intercalate ", " ["Lorem", "ipsum", "dolor"]
"Lorem, ipsum, dolor"
>>> intercalate [0, 1] [[2, 3], [4, 5, 6], []]
[2,3,0,1,4,5,6,0,1]
>>> intercalate [1, 2, 3] [[], []]
[1,2,3]
Allow asynchronous exceptions to be raised even inside mask, making the operation interruptible (see the discussion of "Interruptible operations" in Exception). When called outside mask, or inside uninterruptibleMask, this function has no effect.
The intersperse function takes an element and a list and `intersperses' that element between the elements of the list.

Laziness

intersperse has the following properties
>>> take 1 (intersperse undefined ('a' : undefined))
"a"
>>> take 2 (intersperse ',' ('a' : undefined))
"a*** Exception: Prelude.undefined

Examples

>>> intersperse ',' "abcde"
"a,b,c,d,e"
>>> intersperse 1 [3, 4, 5]
[3,1,4,1,5]
The kind of lifted constraints
the state during mask: asynchronous exceptions are masked, but blocking operations may still be interrupted
the state during uninterruptibleMask: asynchronous exceptions are masked, and blocking operations may not be interrupted
This exception is raised by default in the main thread of the program when the user requests to terminate the program via the usual mechanism(s) (e.g. Control-C in the console).
When invoked inside mask, this function allows a masked asynchronous exception to be raised, if one exists. It is equivalent to performing an interruptible operation (see #interruptible), but does not involve any actual blocking. When called outside mask, or inside uninterruptibleMask, this function has no effect.
Convert a single digit Char to the corresponding Int. This function fails unless its argument satisfies isHexDigit, but recognises both upper- and lower-case hexadecimal digits (that is, '0'..'9', 'a'..'f', 'A'..'F').

Examples

Characters '0' through '9' are converted properly to 0..9:
>>> map digitToInt ['0'..'9']
[0,1,2,3,4,5,6,7,8,9]
Both upper- and lower-case 'A' through 'F' are converted as well, to 10..15.
>>> map digitToInt ['a'..'f']
[10,11,12,13,14,15]

>>> map digitToInt ['A'..'F']
[10,11,12,13,14,15]
Anything else throws an exception:
>>> digitToInt 'G'
*** Exception: Char.digitToInt: not a digit 'G'

>>> digitToInt '♥'
*** Exception: Char.digitToInt: not a digit '\9829'
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.
Selects printable Unicode characters (letters, numbers, marks, punctuation, symbols and spaces).