Skip to Content
i documentation
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.

FunctionTypeWhat it gives
portable<A>(A) -> BoolTrue when the value is portable (§11.9)
not(Bool) -> BoolTrue for False, and False for True
to_float(Int) -> FloatThe nearest Float, with ties to even. If it is not finite, the program stops.
truncate(Float) -> IntThe Float without its fraction, rounded toward zero
floor(Float) -> FloatThe greatest whole number that is not greater
ceiling(Float) -> FloatThe smallest whole number that is not smaller
sqrt(Float) -> FloatThe square root. For a negative number the result is not finite, so the program stops (§11.3).
float_to_bits(Float) -> IntThe 64 bits of the IEEE 754 binary64 value, as a number from 0 to 2^64 − 1
float_from_bits(Int) -> FloatThe 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) -> IntThe bitwise operation on the numbers as two’s complement with no end
bit_not(Int) -> Int-x - 1
shift_left(Int, Int) -> Intx × 2^n. A negative n is shift_right by −n.
shift_right(Int, Int) -> Intx ÷ 2^n, rounded down. A negative n is shift_left by −n.
concat(List(String)) -> StringThe strings one after the other
byte_size(String) -> IntThe 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)) -> StringThe string of these characters
codepoint_to_int(UtfCodepoint) -> IntThe 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) -> StringThe 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) -> StringThe 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) -> IntThe 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)) -> BitArrayThe bit arrays one after the other. Their sizes may be any number of bits.
inspect<A>(A) -> StringThe text form of the value (§11.8)
hash<A>(A) -> IntA 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) -> AThe match on Never (§6.12); it is never called with a value