The language standardChapters
13. The module `i/core`
The module exports the built-in types Int, Float, String, List, BitArray, UtfCodepoint, Never, Boundary, Continuation, Key, Keyed, Request, and Ticket. These are the same types as the unqualified built-in names.
These are normal functions: they are called, given, and compared like any other function. Only their bodies are not written in i. Most of them do things that the rest of the language cannot do, such as looking at how any value is made (inspect, hash). Some, such as index_of and bit_array_concat, could be written in i, but the runtime does them much faster. They have no need.
| Function | Type | What it gives |
|---|---|---|
portable | <A>(A) -> Bool | True when the value is portable (§11.9) |
not | (Bool) -> Bool | True for False, and False for True |
to_float | (Int) -> Float | The nearest Float, with ties to even. If it is not finite, the program stops. |
truncate | (Float) -> Int | The Float without its fraction, rounded toward zero |
floor | (Float) -> Float | The greatest whole number that is not greater |
ceiling | (Float) -> Float | The smallest whole number that is not smaller |
sqrt | (Float) -> Float | The square root. For a negative number the result is not finite, so the program stops (§11.3). |
float_to_bits | (Float) -> Int | The 64 bits of the IEEE 754 binary64 value, as a number from 0 to 2^64 − 1 |
float_from_bits | (Int) -> Float | The float with the lowest 64 bits of the number. If it is not finite, the program stops. |
bit_and, bit_or, bit_xor | (Int, Int) -> Int | The bitwise operation on the numbers as two’s complement with no end |
bit_not | (Int) -> Int | -x - 1 |
shift_left | (Int, Int) -> Int | x × 2^n. A negative n is shift_right by −n. |
shift_right | (Int, Int) -> Int | x ÷ 2^n, rounded down. A negative n is shift_left by −n. |
concat | (List(String)) -> String | The strings one after the other |
byte_size | (String) -> Int | The number of UTF-8 bytes |
byte_slice | (String, Int, Int) -> Result(String, Nil) | The bytes from start (counting from 0), length of them. Error(Nil) when they are not all in the string, or when the start or the end is inside a character. |
codepoints | (String) -> List(UtfCodepoint) | The characters in order |
from_codepoints | (List(UtfCodepoint)) -> String | The string of these characters |
codepoint_to_int | (UtfCodepoint) -> Int | The number of the character |
int_to_codepoint | (Int) -> Result(UtfCodepoint, Nil) | The character with this number, or Error(Nil) when it is not a Unicode scalar value |
to_upper | (String) -> String | The string with each character changed to its simple uppercase mapping in Unicode 18.0.0 (UnicodeData.txt). This is one character for one character, and no language changes it. A character with no simple uppercase mapping, such as ß, stays the same. |
to_lower | (String) -> String | The string with each character changed to its simple lowercase mapping in Unicode 18.0.0, in the same way |
index_of | (String, String, Int) -> Result(Int, Nil) | The byte offset (counting from 0) of the first find in in that starts at from or after it. An empty find is at from. Error(Nil) when there is no such find, when from is less than 0 or greater than the byte size of in, or when from is inside a character. |
bit_size | (BitArray) -> Int | The number of bits |
bit_array_to_string | (BitArray) -> Result(String, Nil) | The string, when the bits are whole bytes of correct UTF-8; Error(Nil) when not |
bit_array_concat | (List(BitArray)) -> BitArray | The bit arrays one after the other. Their sizes may be any number of bits. |
inspect | <A>(A) -> String | The text form of the value (§11.8) |
hash | <A>(A) -> Int | A number from 0 to 2^32 − 1. Values that are the same (§11.4) give the same number. Which number is not fixed outside macros; macro execution uses §14.9. |
never | <A>(Never) -> A | The match on Never (§6.12); it is never called with a value |