Manuscript Documentation
v2026.12.0

prelude#

Names available in every module; no import required.

Bool Type#

Boolean truth values true and false; conditions require this type.

Manuscript
type Bool { ... }

Bool.clone#

Returns the value itself: a Bool copies by value.

Manuscript
fn clone() Bool

Clonable Interface#

A type whose values can be duplicated. Plain data is Clonable; resource handles, natives without a clone of their own (a Regex, a Pipe), function values, and any record, alternative or collection holding one of those are not. There is nothing to implement: the bound T Clonable makes value.clone() available on a type parameter.

Manuscript
interface Clonable {
    fn clone() Self
}

Clonable.clone#

Returns an independent deep copy of this value.

Manuscript
fn clone() Self

Comparable Interface#

A type with a total order; compare agrees with equals when both are implemented.

Manuscript
interface Comparable {
    fn compare(other Self) Int
}

Comparable.compare#

Orders this value against another of the same type: negative when it sorts before, zero when neither sorts first, positive when it sorts after.

Manuscript
fn compare(other Self) Int

Equal Interface#

A type that can be compared for equality. Built-in data keeps its value semantics; an explicit implementation chooses what counts as the same value.

Manuscript
interface Equal {
    fn equals(other Self) Bool
}

Equal.equals#

Compares this value with another value of the same type.

Manuscript
fn equals(other Self) Bool

Error Type#

An expected failure as a plain value: a message, a short code callers can branch on, and string details. Build one like any record: Error("no such file", kind: "ENOENT", details: {"path": path}). T! is Result[T, Error].

Manuscript
type Error {
    message String
    kind String? = null
    details Map[String, String] = Map[String, String]()
}

Error.details#

Extra facts about the failure, such as the path or operation, keyed by name.

Manuscript
details Map[String, String] = Map[String, String]()

Error.kind#

A short code for what went wrong, or null when no code fits. The kind itself never allocates when it is a literal or at most 15 bytes. The standard library reports POSIX errno names (EAUTH is Manuscript’s own), so error.kind == "ENOENT" means the same on every platform:

  • EINVAL: caller input is invalid
  • EBADMSG: input data is malformed
  • EOVERFLOW: a limit was exceeded
  • ERANGE: a value or index is out of range
  • ENOENT: not found
  • EEXIST: already exists
  • ENOTEMPTY: directory not empty
  • EACCES: permission denied
  • ENOTSUP: unsupported
  • ENOTTY: not a terminal
  • EBADF: resource closed
  • EIO: a task, process or peer ended abnormally
  • EAGAIN: service unavailable
  • EBUSY: resource busy
  • ENAMETOOLONG: a file name or path is too long
  • ELOOP: too many symbolic links
  • ENOSPC: no space left on the device
  • EROFS: the file system is read-only
  • EXDEV: the paths are on different devices
  • EMFILE: too many open files
  • ETIMEDOUT: a deadline expired
  • ECANCELED: cancelled
  • EAUTH: authentication failed

Your own code uses its own prefix, such as "EQUOTA".

Manuscript
kind String? = null

Error.message#

Human-readable description of the failure.

Manuscript
message String

Float Type#

Binary floating-point values, including signed zero, infinities and NaN.

Manuscript
type Float { ... }

Float.abs#

Returns the absolute value; NaN stays NaN and -0.0 becomes 0.0.

Manuscript
fn abs() Float

Float.clone#

Returns the value itself: a Float copies by value.

Manuscript
fn clone() Float

Float.compare#

Returns -1, 0 or 1 in a total order: -0.0 equals 0.0, and NaN is equal to NaN and greater than every other value, including +Inf.

Manuscript
fn compare(other Float) Int

Float.is_finite#

Tests whether the value is neither NaN nor an infinity.

Manuscript
fn is_finite() Bool

Float.is_nan#

Tests whether the value is NaN.

Manuscript
fn is_nan() Bool

Float.sign#

Returns -1.0 or 1.0 by sign; zeros and NaN are returned unchanged.

Manuscript
fn sign() Float

Float.to_exponential#

Formats in scientific notation with digits fractional digits, from 0 to 100; a count outside 0..100 faults.

Manuscript
fn to_exponential(digits Int) String

Float.to_fixed#

Formats with digits fractional digits, from 0 to 100; a magnitude of 1e21 or more uses the ordinary round-trip notation. A count outside 0..100 faults. Rounding is binary64 round half to even. Example: 3.14159.to_fixed(2) is "3.14".

Manuscript
fn to_fixed(digits Int) String

Float.to_float32#

Converts to Float32, rounding to the nearest binary32 value. A finite value too large for Float32 returns null instead of becoming infinity; NaN and infinities convert unchanged.

Manuscript
fn to_float32() Float32?

Float.to_precision#

Formats with precision significant digits, from 1 to 100, keeping trailing zeros; a count outside 1..100 faults.

Manuscript
fn to_precision(precision Int) String

Float.to_string#

Returns the shortest round-trip representation, including NaN and signed infinities.

Manuscript
fn to_string() String

Float.truncate_to_int#

Truncates toward zero, or returns null for nonfinite values or Int overflow.

Manuscript
fn truncate_to_int() Int?

Float32 Type#

Binary32 floating-point values; each operation rounds to binary32, and literals need a Float32 type to adopt it.

Manuscript
type Float32 { ... }

Float32.abs#

Returns the absolute value; NaN stays NaN and -0.0 becomes 0.0.

Manuscript
fn abs() Float32

Float32.clone#

Returns the value itself: a Float32 copies by value.

Manuscript
fn clone() Float32

Float32.compare#

Returns -1, 0 or 1 in a total order: -0.0 equals 0.0, and NaN is equal to NaN and greater than every other value, including +Inf.

Manuscript
fn compare(other Float32) Int

Float32.is_finite#

Tests whether the value is neither NaN nor an infinity.

Manuscript
fn is_finite() Bool

Float32.is_nan#

Tests whether the value is NaN.

Manuscript
fn is_nan() Bool

Float32.sign#

Returns -1.0 or 1.0 by sign; zeros and NaN are returned unchanged.

Manuscript
fn sign() Float32

Float32.to_float#

Converts to Float; every Float32 converts exactly.

Manuscript
fn to_float() Float

Float32.to_float64#

Converts to Float64; every Float32 converts exactly.

Manuscript
fn to_float64() Float64

Float32.truncate_to_int#

Truncates toward zero, or returns null for nonfinite values or Int overflow.

Manuscript
fn truncate_to_int() Int?

Float64 Type#

Binary64 floating-point values; the same type as Float.

Manuscript
type Float64 { ... }

Hashable Interface#

A type with a stable hash that is consistent with its Equal implementation.

Manuscript
interface Hashable {
    fn hash() Int
}

Hashable.hash#

Returns a stable hash consistent with equals for the same value.

Manuscript
fn hash() Int

Int Type#

Signed whole numbers with checked arithmetic; overflow and division by zero fault.

Manuscript
type Int { ... }

Int.abs#

Returns the absolute value; the most negative value has none and faults like any overflow.

Manuscript
fn abs() Int

Int.clone#

Plain numbers and flags copy by value: their clone is the value itself.

Manuscript
fn clone() Int

Int.compare#

Returns -1, 0 or 1 as this value is less than, equal to or greater than other.

Manuscript
fn compare(other Int) Int

Int.milliseconds#

Returns a Duration of this many milliseconds; a count that overflows nanoseconds faults.

Manuscript
fn milliseconds() Duration

Int.minutes#

Returns a Duration of this many minutes; a count that overflows nanoseconds faults.

Manuscript
fn minutes() Duration

Int.seconds#

Returns a Duration of this many seconds; a count that overflows nanoseconds faults.

Manuscript
fn seconds() Duration

Int.sign#

Returns -1, 0 or 1 as this value is negative, zero or positive.

Manuscript
fn sign() Int

Int.to_binary#

Formats the integer in base 2 with a leading - for negatives, as to_string_radix(2) does; it cannot fail.

Manuscript
fn to_binary() String

Int.to_decimal#

Converts to the exactly equal Decimal; no rounding occurs.

Manuscript
fn to_decimal() Decimal

Int.to_float#

Converts to the nearest Float; integers beyond 2^53 in magnitude can lose low-order digits.

Manuscript
fn to_float() Float

Int.to_float32#

Converts to Float32, rounding to the nearest binary32 value.

Manuscript
fn to_float32() Float32

Int.to_hex#

Formats the integer in base 16 using lowercase digits and a leading - for negatives, as to_string_radix(16) does; it cannot fail.

Manuscript
fn to_hex() String

Int.to_int#

Converts to Int; every value fits, so no check is needed.

Manuscript
fn to_int() Int

Int.to_int16#

Converts to Int16, or returns null when the value is outside Int16’s range.

Manuscript
fn to_int16() Int16?

Int.to_int32#

Converts to Int32, or returns null when the value is outside Int32’s range.

Manuscript
fn to_int32() Int32?

Int.to_int64#

Returns the same value. Int64 is another name for Int while Int is 64 bits wide.

Manuscript
fn to_int64() Int64

Int.to_int8#

Converts to Int8, or returns null when the value is outside Int8’s range.

Manuscript
fn to_int8() Int8?

Int.to_string_radix#

Formats the integer in a radix from 2 through 36 using lowercase digits and a leading - for negatives, or null when the radix is outside 2 through 36.

Manuscript
fn to_string_radix(radix Int) String?

Int.to_uint16#

Converts to UInt16, or returns null when the value is outside UInt16’s range.

Manuscript
fn to_uint16() UInt16?

Int.to_uint32#

Converts to UInt32, or returns null when the value is outside UInt32’s range.

Manuscript
fn to_uint32() UInt32?

Int.to_uint64#

Converts to UInt64, or returns null when the value is negative.

Manuscript
fn to_uint64() UInt64?

Int.to_uint8#

Converts to UInt8, or returns null when the value is outside UInt8’s range.

Manuscript
fn to_uint8() UInt8?

Int16 Type#

Signed 16-bit whole numbers (-32768 to 32767); arithmetic faults when the result leaves the range.

Manuscript
type Int16 { ... }

Int16.abs#

Returns the absolute value; the most negative value has none and faults like any overflow.

Manuscript
fn abs() Int16

Int16.clone#

Returns the value itself: a Int16 copies by value.

Manuscript
fn clone() Int16

Int16.compare#

Returns -1, 0 or 1 as this value is less than, equal to or greater than other.

Manuscript
fn compare(other Int16) Int

Int16.sign#

Returns -1, 0 or 1 as this value is negative, zero or positive.

Manuscript
fn sign() Int

Int16.to_binary#

Formats the integer in base 2 with a leading - for negatives, as to_string_radix(2) does; it cannot fail.

Manuscript
fn to_binary() String

Int16.to_decimal#

Converts to the exactly equal Decimal; no rounding occurs.

Manuscript
fn to_decimal() Decimal

Int16.to_float#

Converts to the nearest Float; integers beyond 2^53 in magnitude can lose low-order digits.

Manuscript
fn to_float() Float

Int16.to_float32#

Converts to Float32, rounding to the nearest binary32 value.

Manuscript
fn to_float32() Float32

Int16.to_hex#

Formats the integer in base 16 using lowercase digits and a leading - for negatives, as to_string_radix(16) does; it cannot fail.

Manuscript
fn to_hex() String

Int16.to_int#

Converts to Int; every value fits, so no check is needed.

Manuscript
fn to_int() Int

Int16.to_int64#

Converts to Int64; every value fits, so no check is needed.

Manuscript
fn to_int64() Int64

Int16.to_int8#

Converts to Int8, or returns null when the value is outside Int8’s range.

Manuscript
fn to_int8() Int8?

Int16.to_string_radix#

Formats the integer in a radix from 2 through 36 using lowercase digits and a leading - for negatives, or null when the radix is outside 2 through 36.

Manuscript
fn to_string_radix(radix Int) String?

Int32 Type#

Signed 32-bit whole numbers (-2147483648 to 2147483647); arithmetic faults when the result leaves the range.

Manuscript
type Int32 { ... }

Int32.abs#

Returns the absolute value; the most negative value has none and faults like any overflow.

Manuscript
fn abs() Int32

Int32.clone#

Returns the value itself: a Int32 copies by value.

Manuscript
fn clone() Int32

Int32.compare#

Returns -1, 0 or 1 as this value is less than, equal to or greater than other.

Manuscript
fn compare(other Int32) Int

Int32.sign#

Returns -1, 0 or 1 as this value is negative, zero or positive.

Manuscript
fn sign() Int

Int32.to_binary#

Formats the integer in base 2 with a leading - for negatives, as to_string_radix(2) does; it cannot fail.

Manuscript
fn to_binary() String

Int32.to_decimal#

Converts to the exactly equal Decimal; no rounding occurs.

Manuscript
fn to_decimal() Decimal

Int32.to_float#

Converts to the nearest Float; integers beyond 2^53 in magnitude can lose low-order digits.

Manuscript
fn to_float() Float

Int32.to_float32#

Converts to Float32, rounding to the nearest binary32 value.

Manuscript
fn to_float32() Float32

Int32.to_hex#

Formats the integer in base 16 using lowercase digits and a leading - for negatives, as to_string_radix(16) does; it cannot fail.

Manuscript
fn to_hex() String

Int32.to_int#

Converts to Int; every value fits, so no check is needed.

Manuscript
fn to_int() Int

Int32.to_int16#

Converts to Int16, or returns null when the value is outside Int16’s range.

Manuscript
fn to_int16() Int16?

Int32.to_int64#

Converts to Int64; every value fits, so no check is needed.

Manuscript
fn to_int64() Int64

Int32.to_int8#

Converts to Int8, or returns null when the value is outside Int8’s range.

Manuscript
fn to_int8() Int8?

Int32.to_string_radix#

Formats the integer in a radix from 2 through 36 using lowercase digits and a leading - for negatives, or null when the radix is outside 2 through 36.

Manuscript
fn to_string_radix(radix Int) String?

Int64 Type#

Signed 64-bit whole numbers; the same type as Int while Int is 64 bits wide.

Manuscript
type Int64 { ... }

Int8 Type#

Signed 8-bit whole numbers (-128 to 127); arithmetic faults when the result leaves the range.

Manuscript
type Int8 { ... }

Int8.abs#

Returns the absolute value; the most negative value has none and faults like any overflow.

Manuscript
fn abs() Int8

Int8.clone#

Returns the value itself: a Int8 copies by value.

Manuscript
fn clone() Int8

Int8.compare#

Returns -1, 0 or 1 as this value is less than, equal to or greater than other.

Manuscript
fn compare(other Int8) Int

Int8.sign#

Returns -1, 0 or 1 as this value is negative, zero or positive.

Manuscript
fn sign() Int

Int8.to_binary#

Formats the integer in base 2 with a leading - for negatives, as to_string_radix(2) does; it cannot fail.

Manuscript
fn to_binary() String

Int8.to_decimal#

Converts to the exactly equal Decimal; no rounding occurs.

Manuscript
fn to_decimal() Decimal

Int8.to_float#

Converts to the nearest Float; integers beyond 2^53 in magnitude can lose low-order digits.

Manuscript
fn to_float() Float

Int8.to_float32#

Converts to Float32, rounding to the nearest binary32 value.

Manuscript
fn to_float32() Float32

Int8.to_hex#

Formats the integer in base 16 using lowercase digits and a leading - for negatives, as to_string_radix(16) does; it cannot fail.

Manuscript
fn to_hex() String

Int8.to_int#

Converts to Int; every value fits, so no check is needed.

Manuscript
fn to_int() Int

Int8.to_int16#

Converts to Int16; every value fits, so no check is needed.

Manuscript
fn to_int16() Int16

Int8.to_int32#

Converts to Int32; every value fits, so no check is needed.

Manuscript
fn to_int32() Int32

Int8.to_int64#

Converts to Int64; every value fits, so no check is needed.

Manuscript
fn to_int64() Int64

Int8.to_string_radix#

Formats the integer in a radix from 2 through 36 using lowercase digits and a leading - for negatives, or null when the radix is outside 2 through 36.

Manuscript
fn to_string_radix(radix Int) String?

List Native type#

An ordered mutable collection with indexing, iteration and transformations. Start with a literal such as ["docs", "release"]; use var when you want to append, remove or replace items. A list has one owner; clone() makes a deep copy, and xs[i] and accessors such as first borrow elements. List[T]() creates an empty list. List[T](reserve: n) also preallocates room for n items without changing the length; a negative n reserves nothing.

Manuscript
type List[T] {
    reserve Int? = null
}

fn List[T].is_empty() Bool { ... }
fn var List[T].prepend(move value T) Void { ... }
fn var List[T].insert(index Int, move value T) Void { ... }
fn var List[T].pop() T? { ... }
fn var List[T].set(index Int, move value T) Void { ... }
fn var List[T].replace(index Int, move value T) T { ... }
fn var List[T].swap(i Int, j Int) Void { ... }
fn var List[T].remove(index Int) Void { ... }
fn var List[T].reverse() Void { ... }
fn var List[T].sort(compare fn(T, T) Int) Void { ... }
fn var List[T].splice(start Int, delete_count Int, move replacement List[T]) Void { ... }
fn var List[T].drain(start Int, end Int) List[T] { ... }
fn var List[T].truncate(length Int) Void { ... }
fn List[T].keys() List[Int] { ... }
fn var List[T].append(move value T) Void { ... }
fn List[T].length() Int { ... }
fn List[T].clone() List[T] { ... }
fn List[T].slice(start Int, end Int) Result[List[T], Error] { ... }
fn List[T].take(count Int) List[T] { ... }
fn List[T].drop(count Int) List[T] { ... }
fn List[T].chunks(size Int) List[List[T]] { ... }
fn List[T].windows(size Int) List[List[T]] { ... }
fn List[T].sorted(compare fn(T, T) Int) List[T] { ... }
fn var List[T].fill(move value T, start Int, end Int) Void { ... }
fn var List[T].copy_within(target Int, start Int, end Int) Void { ... }
fn List[T].concat(other List[T]) List[T] { ... }
fn List[T].group_by[K Hashable](key fn(T) K) Map[K, List[T]] { ... }
fn List[T].repeated(count Int) List[T] { ... }
fn var List[T].extend(other List[T]) Void { ... }

List.reserve#

Constructor-only capacity hint in items: room for this many elements is allocated up front. The list starts empty. null or a negative value reserves nothing.

Manuscript
reserve Int? = null

List.all#

Reports whether every value satisfies predicate; an empty list returns true.

Manuscript
fn all(predicate fn(T) Bool) Bool

List.any#

Reports whether at least one value satisfies predicate.

Manuscript
fn any(predicate fn(T) Bool) Bool

List.append#

Adds value at the end in place.

Manuscript
var fn append(move value T) Void { ... }

List.append_all#

Moves every element of other to the end of this list, in order, and consumes other. Nothing is cloned, so it works for any element type. Example: after var xs = [1], xs.append_all([2, 3]) leaves xs as [1, 2, 3].

Manuscript
var fn append_all(move other List[T]) Void

Searches in O(log n) comparisons without copying elements or changing the list. The list must be in ascending natural order, as sorted() produces: comparisons must form a total order, with Float NaNs last. Sortedness is not checked; a list in the wrong order gives an unspecified result. Returns the index of the first element that compares equal, or the insertion position with found: false. An empty list returns index 0. Example: [1, 3, 3, 5].binary_search(3).index is 1; searching for 4 gives index 3 with found: false.

Manuscript
// Receiver: List[T]; T Comparable
fn binary_search(value T) SearchResult

List.chunks#

Splits the list into consecutive chunks of size elements, as copies. The last chunk may be shorter. An empty list, or a size of zero or less, gives an empty list.

Manuscript
fn chunks(size Int) List[List[T]] { ... }

List.clear#

Removes every element in place and keeps the allocated capacity, so a scratch list can be refilled without reallocating.

Manuscript
var fn clear() Void

List.clone#

Returns a deep copy with independent list and nested value storage.

Manuscript
fn clone() List[T] { ... }

List.compact#

Collapses each run of consecutive equal elements into its first element, in place. Elements must implement Equal. Sort first to remove every duplicate, or use distinct(), which keeps the first of all equal elements without sorting. Example: var xs = [1, 1, 2, 2, 1] then xs.compact() leaves [1, 2, 1].

Manuscript
// Receiver: List[T]; T Equal
var fn compact() Void

List.compact_by#

Collapses each run of consecutive elements that same calls equal into its first element, in place. same(previous, next) receives the last kept element and the candidate, so it runs once for each element after the first. Example: var xs = [1, 1, 2, 1] then xs.compact_by((a, b) => a == b) leaves [1, 2, 1].

Manuscript
var fn compact_by(same fn(T, T) Bool) Void

List.concat#

Returns a new list holding this list’s elements followed by other; neither operand is changed.

Manuscript
fn concat(other List[T]) List[T] { ... }

List.contains#

Reports whether any element equals value, using the element type’s Equal implementation. An empty list returns false.

Manuscript
// Receiver: List[T]; T Equal
fn contains(value T) Bool

List.copy_within#

Copies the elements in [start, end) to begin at index target, in place. The list never grows: copying stops at the end of the list. Source bounds must satisfy 0 <= start <= end <= length() and a target must be within 0 through length(); otherwise the call faults.

Manuscript
var fn copy_within(target Int, start Int, end Int) Void { ... }

List.count#

Counts the values for which predicate is true, calling it once per element in order.

Manuscript
fn count(predicate fn(T) Bool) Int

List.counts#

Counts how many times each distinct element occurs. Keys appear in first-seen order. Example: ["a", "b", "a"].counts() maps "a" to 2 and "b" to 1.

Manuscript
// Receiver: List[T]; T Hashable & Clonable
fn counts() Map[T, Int]

List.distinct#

Returns a new list with a copy of the first of each group of equal elements, in order. Elements must implement Equal and be Clonable.

Manuscript
// Receiver: List[T]; T Equal & Clonable
fn distinct() List[T]

List.drain#

Moves the elements in [start, end) out into a new list, in order, and closes the gap. Nothing is cloned, so it works for any element type. Bounds must satisfy 0 <= start <= end <= length(); otherwise the call faults.

Manuscript
var fn drain(start Int, end Int) List[T] { ... }

List.drop#

Returns a new list with copies of the elements after the first count. The receiver is unchanged; a count of zero or below drops nothing.

Manuscript
fn drop(count Int) List[T] { ... }

List.drop_while#

Copies the elements from the first one that fails predicate to the end, so it is what take_while leaves. Example: [1, 2, 5, 1].drop_while(x => x < 3) is [5, 1].

Manuscript
// Receiver: List[T]; T Clonable
fn drop_while(predicate fn(T) Bool) List[T]

List.entries#

Returns a new list of ListEntry records pairing each zero-based index with its element, in order.

Manuscript
// Receiver: List[T]; T Clonable
fn entries() List[ListEntry[T]]

List.extend#

Appends a copy of every element of other, in order, to this list in place; other is unchanged. The argument cannot be the receiver. Example: after var xs = [1], xs.extend([2, 3]) leaves xs as [1, 2, 3].

Manuscript
var fn extend(other List[T]) Void { ... }

List.fill#

Sets the elements in [start, end) to copies of value in place. Bounds must satisfy 0 <= start <= end <= length(); a negative or larger bound faults instead of counting from the end. An empty range changes nothing.

Manuscript
var fn fill(move value T, start Int, end Int) Void { ... }

List.filter#

Returns a new list of the values for which predicate is true, in their original order.

Manuscript
// Receiver: List[T]; T Clonable
fn filter(predicate fn(T) Bool) List[T]

List.find#

Returns the first element for which predicate is true as a view of this list, or null. Later elements are not tested after a match. Use .clone() to keep it.

Manuscript
fn find(predicate fn(T) Bool) T?

List.find_index#

Returns the zero-based index of the first element for which predicate is true, or null.

Manuscript
fn find_index(predicate fn(T) Bool) Int?

List.find_last#

Searches from the end and returns the last element for which predicate is true as a view of this list, or null.

Manuscript
fn find_last(predicate fn(T) Bool) T?

List.find_last_index#

Searches from the end and returns the last matching zero-based index, or null.

Manuscript
fn find_last_index(predicate fn(T) Bool) Int?

List.first#

Returns the first element, or null when the list is empty.

Manuscript
fn first() T?

List.flat_map#

Calls transform on each element in order and concatenates the returned lists into one new list; the receiver is unchanged.

Manuscript
fn flat_map[U](transform fn(T) List[U]) List[U]

List.fold#

Combines the values from left to right with step, starting with initial.

Manuscript
fn fold[A](move initial A, step fn(A, T) A) A

List.fold_right#

Combines the values from right to left with step, starting with initial.

Manuscript
fn fold_right[A](move initial A, step fn(A, T) A) A

List.for_each#

Calls operation(value) on each element in order. The traversal covers the list’s initial length, so an append during the loop does not extend it, while element writes can affect later calls. A callback that takes its parameter as var changes the element in place, and the receiver must then be var; a reading callback works on any list.

Manuscript
fn for_each(operation fn(var T) Void) Void

List.get_or#

Returns an element, or default when the index is out of range; negative indexes are relative to the end.

Manuscript
fn get_or(index Int, default T) T

List.group_by[K Hashable]#

Calls key once per element in order and returns a map from each distinct key to the elements that produced it. Keys appear in first-seen order, and each group keeps the original element order.

Manuscript
fn group_by[K Hashable](key fn(T) K) Map[K, List[T]] { ... }

List.index_of#

Returns the zero-based index of the first element equal to value, or null. Elements must implement Equal.

Manuscript
// Receiver: List[T]; T Equal
fn index_of(value T) Int?

List.insert#

Inserts value before index in place; negative indexes count from the end. Requires -length() <= index <= length(). An index of length() appends; any other invalid index faults.

Manuscript
var fn insert(index Int, move value T) Void { ... }

List.is_empty#

Reports whether the list has no elements.

Manuscript
fn is_empty() Bool { ... }

List.is_sorted#

Reports whether the list is in ascending natural order, the order sorted() produces; empty and one-element lists are. Example: [1, 2, 2, 5].is_sorted() is true.

Manuscript
// Receiver: List[T]; T Comparable
fn is_sorted() Bool

List.is_sorted_by#

Reports whether the list is already in the order compare defines, meaning no element sorts after its successor. Empty and one-element lists are sorted.

Manuscript
fn is_sorted_by(compare fn(T, T) Int) Bool

List.join#

Joins the elements’ interpolation text ("{value}") with separator between neighbors; an empty list returns an empty string. Strings join as they are and numbers as decimal text. A record or alternative joins in its structural form. Example: [1, 2, 3].join(",") is "1,2,3".

Manuscript
fn join(separator String) String

List.keys#

Returns a new list of the zero-based indexes 0 through length() - 1.

Manuscript
fn keys() List[Int] { ... }

List.last#

Returns the last element, or null when the list is empty.

Manuscript
fn last() T?

List.last_index_of#

Returns the zero-based index of the last element equal to value, or null. Elements must implement Equal.

Manuscript
// Receiver: List[T]; T Equal
fn last_index_of(value T) Int?

List.length#

Returns the number of elements.

Manuscript
fn length() Int { ... }

List.map#

Returns a new list holding transform applied to each element in order; the receiver is unchanged.

Manuscript
fn map[U](transform fn(T) U) List[U]

List.max#

Returns the greatest element as a view of this list, or null for an empty list. The first of equal elements wins. Example: [3, 1, 2].max() is 3.

Manuscript
// Receiver: List[T]; T Comparable
fn max() T?

List.max_by#

Returns a view of the element whose key is greatest, or null when the list is empty. key is called once per element in order, and ties keep the earlier element. Example: ["bb", "a", "ccc"].max_by(w => w.length()) is "ccc".

Manuscript
fn max_by[K Comparable](key fn(T) K) T?

List.min#

Returns the least element as a view of this list, or null for an empty list. The first of equal elements wins. Example: [3, 1, 2].min() is 1; List[Int]().min() is null.

Manuscript
// Receiver: List[T]; T Comparable
fn min() T?

List.min_by#

Returns a view of the element whose key is least, or null when the list is empty. key is called once per element in order, and ties keep the earlier element. Example: ["bb", "a", "ccc"].min_by(w => w.length()) is "a".

Manuscript
fn min_by[K Comparable](key fn(T) K) T?

List.partition#

Calls predicate once per element in order and splits the elements into those that matched and the rest, each in the original order.

Manuscript
// Receiver: List[T]; T Clonable
fn partition(predicate fn(T) Bool) Partition[T]

List.pop#

Removes and returns the last element in place, or null for an empty list.

Manuscript
var fn pop() T? { ... }

List.prepend#

Inserts value at index 0 in place, shifting existing elements one position later.

Manuscript
var fn prepend(move value T) Void { ... }

List.remove#

Removes the element at index in place; negative indexes count from the end. Invalid indexes fault. Later elements shift down. Values left in spare backing capacity are not cleared.

Manuscript
var fn remove(index Int) Void { ... }

List.repeated#

Returns a new list holding the elements count times over, in order. A count of zero or below gives an empty list. Example: [1, 2].repeated(2) is [1, 2, 1, 2].

Manuscript
fn repeated(count Int) List[T] { ... }

List.replace#

Stores value at index in place and returns the element that was there. Both move without copying. Negative indexes count from the end; invalid indexes fault.

Manuscript
var fn replace(index Int, move value T) T { ... }

List.retain#

Keeps only the elements for which keep is true, in place and in their original order. keep is called once per element, in order. Dropped elements are closed when they are resources; kept ones are moved, not copied. Example: var xs = [1, 2, 3, 4] then xs.retain(x => x % 2 == 0) leaves [2, 4].

Manuscript
var fn retain(keep fn(T) Bool) Void

List.reverse#

Reverses this list in place.

Manuscript
var fn reverse() Void { ... }

List.reversed#

Returns an independent reversed copy, including nested values.

Manuscript
// Receiver: List[T]; T Clonable
fn reversed() List[T]

List.rotate#

Moves every element by places toward the front in place, wrapping the first ones around to the end. A negative by rotates toward the back, and any magnitude is reduced modulo the length. An empty list is unchanged. Example: var xs = [1, 2, 3, 4] then xs.rotate(1) leaves [2, 3, 4, 1].

Manuscript
var fn rotate(by Int) Void

List.set#

Replaces an element in place; negative indexes count from the end. Invalid indexes fault.

Manuscript
var fn set(index Int, move value T) Void { ... }

List.slice#

Returns the elements in [start, end) as a view of this list: it keeps the list unchangeable until its last use, and nothing is copied. Use .clone() to keep it. Negative bounds are relative to the end; bounds outside 0 <= start <= end <= length() return an Error of kind ERANGE.

Manuscript
fn slice(start Int, end Int) Result[List[T], Error] { ... }

List.sort#

Sorts the list in place, stably, in the order compare defines, as sorted does. Comparable elements also have sort() without a comparator. Example: var xs = [3, 1, 2] then xs.sort((a, b) => b - a) leaves [3, 2, 1].

Manuscript
var fn sort(compare fn(T, T) Int) Void { ... }

List.sort#

Sorts the list in place, stably, in the same order as sorted(). Example: var xs = [3, 1, 2] then xs.sort() leaves [1, 2, 3].

Manuscript
// Receiver: List[T]; T Comparable
var fn sort() Void

List.sorted#

Returns a new list ordered by compare; the receiver is unchanged. The sort is stable: equal elements keep their order. A negative, zero or positive result puts the first argument before, level with or after the second. Comparable elements also have sorted() without a comparator. Example: names.sorted((a, b) => a.length() - b.length()) orders by length.

Manuscript
fn sorted(compare fn(T, T) Int) List[T] { ... }

List.sorted#

Returns a new list in ascending natural order; the receiver is unchanged. The sort is stable: equal elements keep their order. Float orders NaN above every other value. Example: [3, 1, 2].sorted() is [1, 2, 3].

Manuscript
// Receiver: List[T]; T Comparable & Clonable
fn sorted() List[T]

List.sorted_by_key#

Returns a new list ordered by the natural order of key(element). The receiver is unchanged and the sort is stable. key runs on every comparison, so keep it cheap. Example: people.sorted_by_key(p => p.age).

Manuscript
// Receiver: List[T]; T Clonable
fn sorted_by_key[K Comparable](key fn(T) K) List[T]

List.splice#

Replaces delete_count elements starting at start in place with the elements of replacement, which is consumed. Requires 0 <= start <= length and 0 <= delete_count <= length - start; invalid bounds fault and are not clamped. Removed elements are dropped, and replacement elements move into the receiver. The receiver and the replacement cannot be the same list.

Manuscript
var fn splice(start Int, delete_count Int, move replacement List[T]) Void { ... }

List.sum#

Adds the elements from left to right with + in the element type’s own arithmetic: integer overflow faults and floats follow their width. An empty list sums to zero. Example: [1, 2, 3].sum() is 6; [1.5, 2.5].sum() is 4.0.

Manuscript
// Receiver: List[T]; T Numeric
fn sum() T

List.swap#

Exchanges the elements at i and j in place without copying them; equal indexes change nothing. Negative indexes count from the end; invalid indexes fault.

Manuscript
var fn swap(i Int, j Int) Void { ... }

List.take#

Returns a new list with copies of the first count elements, or of all of them when count exceeds the length. The receiver is unchanged; a count of zero or below gives an empty list.

Manuscript
fn take(count Int) List[T] { ... }

List.take_while#

Copies the leading elements for which predicate holds, stopping at the first one that fails it. Example: [1, 2, 5, 1].take_while(x => x < 3) is [1, 2].

Manuscript
// Receiver: List[T]; T Clonable
fn take_while(predicate fn(T) Bool) List[T]

List.to_set#

Returns a new set of the distinct elements, using Hashable equality. The first of equal elements is kept, in insertion order.

Manuscript
// Receiver: List[T]; T Hashable & Clonable
fn to_set() Set[T]

List.truncate#

Keeps the first length elements and drops the rest in place; the capacity stays. A length at or above the current length changes nothing; a negative length faults.

Manuscript
var fn truncate(length Int) Void { ... }

List.windows#

Returns each run of size consecutive elements as an overlapping copy, in order. A list shorter than size, or a size of zero or less, gives an empty list. Windows are copies; slice and take do not borrow.

Manuscript
fn windows(size Int) List[List[T]] { ... }

List.zip#

Pairs elements by position into fresh Pair records, stopping at the shorter list; both lists are unchanged.

Manuscript
// Receiver: List[T]; T Clonable
fn zip[U Clonable](other List[U]) List[Pair[T, U]]

ListEntry Type#

One list index and the value stored there.

Manuscript
type ListEntry[T] {
    index Int
    value T
}

ListEntry.index#

Zero-based position of the element in the list that produced this entry.

Manuscript
index Int

ListEntry.value#

The element found at index.

Manuscript
value T

Map Native type#

A mutable key-value collection that remembers insertion order. Keys use their Hashable implementation to decide equality.

Manuscript
type Map[T Hashable, U] {
}

fn var Map[T, U].reserve(extra Int) Void { ... }
fn var Map[T, U].add_default(move key T, move value U) Void { ... }
fn var Map[T, U].clear() Void { ... }
fn Map[T, U].keys() List[T] { ... }
fn Map[T, U].contains(key T) Bool { ... }
fn Map[T, U].get(key T) U? { ... }
fn Map[T, U].length() Int { ... }
fn var Map[T, U].add(move key T, move value U) Void { ... }
fn var Map[T, U].remove(key T) Void { ... }
fn Map[T, U].values() List[U] { ... }
fn var Map[T, U].merge(other Map[T, U]) Void { ... }
fn var Map[T, U].update(key T, move initial U, change fn(U) U) Void { ... }

Map.add#

Inserts or replaces a value; replacement keeps the original key and insertion position.

Manuscript
var fn add(move key T, move value U) Void { ... }

Map.add_default#

Inserts value only when the key is absent. The argument is evaluated even when the key already exists.

Manuscript
var fn add_default(move key T, move value U) Void { ... }

Map.add_default_from#

Inserts create(key) only when the key is absent, calling create once. An existing key keeps its value and position, and create is not called.

Manuscript
var fn add_default_from(move key T, create fn(T) U) Void

Map.all#

Reports whether every entry satisfies predicate, stopping at the first entry that does not. An empty map returns true.

Manuscript
fn all(predicate fn(T, U) Bool) Bool

Map.any#

Reports whether any entry satisfies predicate, stopping at the first match. An empty map returns false.

Manuscript
fn any(predicate fn(T, U) Bool) Bool

Map.clear#

Removes every entry in place.

Manuscript
var fn clear() Void { ... }

Map.clone#

Returns a deep copy with independent map and nested value storage.

Manuscript
// Receiver: Map[T, U]; T Hashable & Clonable, U Clonable
fn clone() Map[T, U]

Map.contains#

Reports whether an equal key is present, using the key type’s Hashable implementation.

Manuscript
fn contains(key T) Bool { ... }

Map.entries#

Returns a new list of MapEntry records in insertion order. Each record holds a copy of its key and value.

Manuscript
// Receiver: Map[T, U]; T Hashable & Clonable, U Clonable
fn entries() List[MapEntry[T, U]]

Map.filter#

Returns a new map of copies of the entries for which predicate is true, in insertion order. The callback borrows the receiver, so changing the map during the traversal is rejected.

Manuscript
// Receiver: Map[T, U]; T Hashable & Clonable, U Clonable
fn filter(predicate fn(T, U) Bool) Map[T, U]

Map.find#

Returns the first entry for which predicate is true as a new MapEntry holding copies of the key and value, or null.

Manuscript
// Receiver: Map[T, U]; T Hashable & Clonable, U Clonable
fn find(predicate fn(T, U) Bool) MapEntry[T, U]?

Map.find_last#

Searches from the end and returns the last entry for which predicate is true as a new MapEntry holding copies of the key and value, or null.

Manuscript
// Receiver: Map[T, U]; T Hashable & Clonable, U Clonable
fn find_last(predicate fn(T, U) Bool) MapEntry[T, U]?

Map.fold#

Combines the entries in insertion order with step, starting with initial.

Manuscript
fn fold[A](move initial A, step fn(A, T, U) A) A

Map.fold_right#

Combines the entries in reverse insertion order with step, starting with initial.

Manuscript
fn fold_right[A](move initial A, step fn(A, T, U) A) A

Map.for_each#

Calls operation(key, value) for each entry in insertion order. A callback that takes value as var changes it in place, and the receiver must then be var.

Manuscript
// Receiver: Map[T, U]; T Hashable
fn for_each(operation fn(T, var U) Void) Void

Map.get#

Returns the value stored for an equal key, or null when the key is absent.

Manuscript
fn get(key T) U? { ... }

Map.get_or#

Returns the stored value, or fallback when the key is absent, as a view of whichever it is. The fallback is always evaluated, and the map is not changed. Use .clone() to keep the result.

Manuscript
// Receiver: Map[T, U]; T Hashable
fn get_or(key T, fallback U) U

Map.is_empty#

Reports whether this map has no entries.

Manuscript
fn is_empty() Bool

Map.keys#

Returns the keys in insertion order as a view of this map: it keeps the map unchangeable until its last use. Use .clone() to keep the keys.

Manuscript
fn keys() List[T] { ... }

Map.length#

Returns the number of entries.

Manuscript
fn length() Int { ... }

Map.map#

Returns a new map with the same keys, each paired with transform(key, value), in insertion order. Keys are copied into the new map.

Manuscript
// Receiver: Map[T, U]; T Clonable
fn map[W](transform fn(T, U) W) Map[T, W]

Map.map_keys#

Returns a new map with each key replaced by transform(key, value), in insertion order, and the values copied. When two entries produce equal keys, the result keeps the first position and the last value.

Manuscript
// Receiver: Map[T, U]; T Hashable & Clonable, U Clonable
fn map_keys[W Hashable](transform fn(T, U) W) Map[W, U]

Map.merge#

Copies every entry of other into this map in place. Existing keys keep their position and key but take the value from other; new keys append in other order. other is unchanged.

Manuscript
var fn merge(other Map[T, U]) Void { ... }

Map.remove#

Removes an equal key in place; the remaining entries keep their insertion order. An absent key changes nothing.

Manuscript
var fn remove(key T) Void { ... }

Map.reserve#

Makes room for extra more entries beyond the current length, so adding them does not rehash. The entries are unchanged; extra of zero or below does nothing.

Manuscript
var fn reserve(extra Int) Void { ... }

Map.retain#

Keeps only the entries for which keep(key, value) is true, in place, like List.retain. The rest keep their insertion order. keep is called once per entry in insertion order, before any removal. Example: cache.retain((key, hits) => hits > 0) evicts unused entries.

Manuscript
// Receiver: Map[T, U]; T Hashable & Clonable
var fn retain(keep fn(T, U) Bool) Void

Map.update#

Stores change applied to the value for key, or to initial when the key is absent. The key is probed once, initial is always evaluated, and change runs once and must not use this map. The key is copied only when it is absent. Example: counts.update(word, 0, n => n + 1) counts occurrences.

Manuscript
var fn update(key T, move initial U, change fn(U) U) Void { ... }

Map.values#

Returns the values in insertion order as a view of this map: it keeps the map unchangeable until its last use. Use .clone() to keep the values.

Manuscript
fn values() List[U] { ... }

MapEntry Type#

One key-value pair returned by Map.entries.

Manuscript
type MapEntry[T Hashable, U] {
    key T
    value U
}

MapEntry.key#

The key; unique within its map under Hashable equality.

Manuscript
key T

MapEntry.value#

The value stored for key. Reading this field borrows from the entry.

Manuscript
value U

Never Type#

The return type of computations that cannot return a value, such as panic.

Manuscript
type Never { ... }

Optional Enum#

Represents a value that may be absent: a T or null; a plain T converts where a T? is expected.

Manuscript
enum Optional[T] {
    some(value T)
    null
}

Optional.null#

An absent value with no payload; no T needs to be constructed.

Manuscript
null

Optional.some#

A present payload, retained by reference when T is mutable.

Manuscript
some(value T)

Optional.some.value#

The contained value; unwrap and matching return this original payload.

Manuscript
value T

Optional.clone#

An Optional copies its payload; null stays null.

Manuscript
// Receiver: T?; T Clonable
fn clone() T?

Result Enum#

Holds either a successful value (ok) or an expected failure (error).

Manuscript
enum Result[T, E] {
    ok(value T)
    error(cause E)
}

Result.error#

An expected failure value; it is distinct from faults and cancellation.

Manuscript
error(cause E)

Result.ok#

A successful result, retaining its payload without a deep copy.

Manuscript
ok(value T)

Result.error.cause#

The original domain error, retained through compatible Result propagation.

Manuscript
cause E

Result.ok.value#

The successful value returned by unwrap, matching, or propagation.

Manuscript
value T

Result.and_then#

Calls transform only on success and returns the Result it produces; an error passes through. The error type stays the same.

Manuscript
move fn and_then[U](transform fn(move T) Result[U, E]) Result[U, E]

Result.err#

Returns the error payload; check is_error() first, because a successful result raises a fault.

Manuscript
fn err() E

Result.get#

Returns the successful payload; an error raises a fault, so use it only when failure is a bug. Prefer ?, if value := result: or get_or(default).

Manuscript
fn get() T

Result.get_or#

Returns the successful payload, or default when this is an error. The default is always evaluated; use get_or_else when it costs work.

Manuscript
move fn get_or(move default T) T

Result.get_or_else#

Returns the successful payload; for an error, calls create once with that error and returns its value.

Manuscript
move fn get_or_else(create fn(move E) T) T

Result.is_error#

Reports whether this result contains an expected error.

Manuscript
fn is_error() Bool

Result.is_ok#

Reports whether this result contains a successful value.

Manuscript
fn is_ok() Bool

Result.map#

Transforms only a successful payload, preserving an error unchanged.

Manuscript
move fn map[U](transform fn(move T) U) Result[U, E]

Result.map_error#

Transforms only an error, preserving a successful payload unchanged.

Manuscript
move fn map_error[F](transform fn(move E) F) Result[T, F]

Result.or_else#

Returns this result when it is successful; for an error, calls create once with that error and returns the Result it produces.

Manuscript
move fn or_else(create fn(move E) Result[T, E]) Result[T, E]

Result.to_optional#

Returns some with the original success payload, or null for an error.

Manuscript
move fn to_optional() T?

Set Native type#

A mutable collection of unique values that remembers insertion order. Values use their Hashable implementation to decide equality.

Manuscript
type Set[T Hashable] {
}

fn Set[T].union(other Set[T]) Set[T] { ... }
fn Set[T].intersection(other Set[T]) Set[T] { ... }
fn Set[T].difference(other Set[T]) Set[T] { ... }
fn Set[T].symmetric_difference(other Set[T]) Set[T] { ... }
fn Set[T].is_subset_of(other Set[T]) Bool { ... }
fn Set[T].is_superset_of(other Set[T]) Bool { ... }
fn Set[T].is_disjoint_from(other Set[T]) Bool { ... }
fn var Set[T].clear() Void { ... }
fn var Set[T].reserve(extra Int) Void { ... }
fn Set[T].values() List[T] { ... }
fn Set[T].contains(value T) Bool { ... }
fn Set[T].length() Int { ... }
fn var Set[T].add(move value T) Void { ... }
fn var Set[T].remove(value T) Void { ... }

Set.add#

Adds a value in place. If an equal value is already present, it keeps its original value and position.

Manuscript
var fn add(move value T) Void { ... }

Set.all#

Reports whether every element satisfies predicate, stopping at the first one that does not. An empty set returns true.

Manuscript
fn all(predicate fn(T) Bool) Bool

Set.any#

Reports whether any element satisfies predicate, stopping at the first match. An empty set returns false.

Manuscript
fn any(predicate fn(T) Bool) Bool

Set.clear#

Removes all values in place.

Manuscript
var fn clear() Void { ... }

Set.clone#

Returns a deep copy with independent storage, in the same insertion order.

Manuscript
// Receiver: Set[T]; T Hashable & Clonable
fn clone() Set[T]

Set.contains#

Reports whether an equal value is present, using the element’s Hashable implementation.

Manuscript
fn contains(value T) Bool { ... }

Set.difference#

Returns a new set of this set’s values that are not in other, in this set’s insertion order.

Manuscript
fn difference(other Set[T]) Set[T] { ... }

Set.filter#

Returns a new set of copies of the elements for which predicate is true, in insertion order. The callback borrows the receiver, so changing the set during the traversal is rejected.

Manuscript
// Receiver: Set[T]; T Hashable & Clonable
fn filter(predicate fn(T) Bool) Set[T]

Set.find#

Returns a copy of the first element for which predicate is true, or null.

Manuscript
// Receiver: Set[T]; T Hashable & Clonable
fn find(predicate fn(T) Bool) T?

Set.find_last#

Searches from the end and returns a copy of the last element for which predicate is true, or null.

Manuscript
// Receiver: Set[T]; T Hashable & Clonable
fn find_last(predicate fn(T) Bool) T?

Set.fold#

Combines the elements in insertion order with step, starting with initial.

Manuscript
fn fold[A](move initial A, step fn(A, T) A) A

Set.fold_right#

Combines the elements in reverse insertion order with step, starting with initial.

Manuscript
fn fold_right[A](move initial A, step fn(A, T) A) A

Set.for_each#

Calls operation(value) for each value in insertion order.

Manuscript
fn for_each(operation fn(T) Void) Void

Set.intersection#

Returns a new set of this set’s values that are also in other, in this set’s insertion order.

Manuscript
fn intersection(other Set[T]) Set[T] { ... }

Set.is_disjoint_from#

Reports whether the two sets have no value in common.

Manuscript
fn is_disjoint_from(other Set[T]) Bool { ... }

Set.is_empty#

Reports whether this set has no elements.

Manuscript
fn is_empty() Bool

Set.is_subset_of#

Reports whether every value of this set is also in other.

Manuscript
fn is_subset_of(other Set[T]) Bool { ... }

Set.is_superset_of#

Reports whether every value of other is also in this set.

Manuscript
fn is_superset_of(other Set[T]) Bool { ... }

Set.length#

Returns the number of distinct values currently stored.

Manuscript
fn length() Int { ... }

Set.map#

Returns a new set of transform(element) for each element; when results are equal, the first is kept.

Manuscript
fn map[U Hashable](transform fn(T) U) Set[U]

Set.remove#

Removes an equal value in place; an absent value changes nothing.

Manuscript
var fn remove(value T) Void { ... }

Set.reserve#

Makes room for extra more values beyond the current length, so adding them does not rehash. The values are unchanged; extra of zero or below does nothing.

Manuscript
var fn reserve(extra Int) Void { ... }

Set.retain#

Keeps only the values for which keep is true, in place, like List.retain. The rest keep their insertion order. Example: seen.retain(n => n >= 0).

Manuscript
// Receiver: Set[T]; T Hashable & Clonable
var fn retain(keep fn(T) Bool) Void

Set.symmetric_difference#

Returns a new set of the values that are in exactly one of the two sets. Neither set changes.

Manuscript
fn symmetric_difference(other Set[T]) Set[T] { ... }

Set.union#

Returns a new set with this set’s values followed by the values only in other, in insertion order.

Manuscript
fn union(other Set[T]) Set[T] { ... }

Set.values#

Returns a new list of copies of the values in insertion order.

Manuscript
fn values() List[T] { ... }

String Type#

UTF-8 text addressed by byte offsets; length is bytes, scalar_length counts Unicode scalars, and chars() walks scalars.

Manuscript
type String { ... }

String.as_bytes#

The UTF-8 encoding of the text.

Manuscript
fn as_bytes() Bytes

String.capitalize#

Converts the first scalar to its titlecase form (dž becomes Dž, ß becomes Ss) and leaves the rest unchanged.

Manuscript
fn capitalize() String

String.chars#

Returns a list with one String for each Unicode scalar, in order. The result borrows the receiver: use it in place, or .clone() it to keep it.

Manuscript
fn chars() List[String]

String.compare#

Returns -1, 0 or 1 in lexical scalar order, without locale or normalization.

Manuscript
fn compare(other String) Int

String.concat#

Concatenates text without changing either operand.

Manuscript
fn concat(other String) String

String.contains#

Tests whether the exact text occurs, without normalization.

Manuscript
fn contains(value String) Bool

String.contains_any#

Reports whether any scalar of set occurs in the text.

Manuscript
fn contains_any(set String) Bool

String.count#

Counts non-overlapping occurrences; an empty part counts the scalars plus one.

Manuscript
fn count(part String) Int

String.cut_prefix#

Returns the text without prefix as a view, or null when the text does not start with it. An empty prefix succeeds and returns the text unchanged.

Manuscript
fn cut_prefix(prefix String) String?

String.cut_suffix#

Returns the text without suffix as a view, or null when the text does not end with it. An empty suffix succeeds and returns the text unchanged.

Manuscript
fn cut_suffix(suffix String) String?

String.display_width#

Returns the number of terminal columns the text occupies. Combining marks add nothing, ambiguous-width characters count as narrow, and wide characters and supported emoji sequences count two. This is an estimate, not a promise for every font or terminal. Controls (tabs, CR/LF, ESC, C1), U+2028 and U+2029 return EBADMSG.

Manuscript
fn display_width() Result[Int, Error]

String.ends_with#

Tests whether the receiver ends with this exact suffix.

Manuscript
fn ends_with(suffix String) Bool

String.equal_fold#

Compares text ignoring case. Both sides are uppercased and then lowercased with Unicode full case mapping, without locale or normalization, so “Straße” equals “STRASSE”. This is not Unicode default case folding: the dotless “ı” (U+0131) uppercases to “I”, so it compares equal to “i” and “I”.

Manuscript
fn equal_fold(other String) Bool

String.fields#

Splits on runs of Unicode White_Space and omits empty fields, so empty or all-whitespace text gives an empty list. Field text is kept exactly, without normalization. The byte-order mark and zero-width space are not separators. The fields borrow the receiver, as split pieces do: use them in place, or .clone() the result.

Manuscript
fn fields() List[String]

String.fields_by#

Splits around runs of characters (one-scalar strings) for which is_separator returns true. The result has no empty items.

Manuscript
fn fields_by(is_separator fn(String) Bool) List[String]

String.find_char#

Returns the byte offset of the first scalar (passed as a one-scalar string) for which predicate returns true, or null.

Manuscript
fn find_char(predicate fn(String) Bool) Int?

String.index_any#

Returns the byte offset of the first scalar that occurs in set, or null.

Manuscript
fn index_any(set String) Int?

String.index_of#

Returns the byte offset of the first match, or null. An empty value matches at zero.

Manuscript
fn index_of(value String) Int?

String.into_bytes#

Returns the UTF-8 bytes and consumes the text. A heap string hands over its buffer without a copy; as_bytes borrows and copies instead.

Manuscript
move fn into_bytes() Bytes

String.is_empty#

Reports whether the text contains no bytes.

Manuscript
fn is_empty() Bool

String.last_index_of#

Returns the byte offset of the last match, or null. An empty value matches at length().

Manuscript
fn last_index_of(value String) Int?

String.length#

The UTF-8 byte length, in constant time.

Manuscript
fn length() Int

String.lines#

Splits at LF and CRLF, keeping interior empty lines and any standalone CR. Text that ends in a newline yields no extra empty item, and empty text returns an empty list. The result borrows the receiver: use it in place, or .clone() it to keep it.

Manuscript
fn lines() List[String]

String.lower#

Returns the text in full Unicode lowercase, independent of locale. The scalar length can change.

Manuscript
fn lower() String

String.map_chars#

Replaces each scalar (a one-scalar string) with the result of transform; an empty result deletes it.

Manuscript
fn map_chars(transform fn(String) String) String

String.normalize#

Normalizes to the form named by form, which must be exactly "NFC", "NFD", "NFKC" or "NFKD". max_bytes optionally bounds the UTF-8 output. An invalid form or negative bound returns EINVAL; exceeding the bound returns EOVERFLOW.

Manuscript
fn normalize(form String, max_bytes Int? = null) Result[String, Error]

String.pad_end#

Pads on the right until the scalar length reaches target_length; see pad_start.

Manuscript
fn pad_end(target_length Int, padding String = " ") String

String.pad_start#

Pads on the left (pad_start) or the right (pad_end) until the scalar length reaches target_length, repeating padding and cutting its last copy.

Manuscript
fn pad_start(target_length Int, padding String = " ") String

String.parse_bool#

Parses a boolean after trimming whitespace and ignoring case. true, t, 1, yes and on give true; false, f, 0, no and off give false. Anything else is null.

Manuscript
fn parse_bool() Bool?

String.parse_float#

Parses a decimal floating-point number with the syntax of math.parse_float; invalid or out-of-range text returns null.

Manuscript
fn parse_float() Float?

String.parse_int#

Parses signed ASCII decimal digits; invalid text or Int overflow returns null.

Manuscript
fn parse_int() Int?

String.repeat#

Repeats the text count times. A count of zero or below, or empty text, gives empty text. Output beyond the string limit faults, as concat does.

Manuscript
fn repeat(count Int) String

String.replace#

Replaces every nonoverlapping occurrence of old, scanning left to right; inserted text is not rescanned. An empty old matches at each scalar boundary, so "ab".replace("", "-") is "-a-b-". Output beyond the string limit faults, as concat does; use Regex.replace_all for a bounded replacement.

Manuscript
fn replace(old String, new String) String

String.replace_each#

Replaces many patterns in one pass. At each position the first pair, in map order, whose key matches wins, and its replacement is not rescanned. Empty keys are ignored.

Manuscript
fn replace_each(pairs Map[String, String]) String

String.replace_first#

Replaces the first occurrence of old; text without a match is unchanged. An empty old matches at the start, so new is inserted there.

Manuscript
fn replace_first(old String, new String) String

String.reserve#

Preallocates room for at least bytes total UTF-8 bytes so subsequent += appends avoid repeated reallocations. The text is unchanged; a non-positive or small count does nothing, and large hints are capped like List(reserve:).

Manuscript
var fn reserve(bytes Int) Void

String.reverse#

Reverses the order of Unicode scalars, so a combining sequence or grapheme cluster can come out reordered.

Manuscript
fn reverse() String

String.rsplit_once#

Splits at the last exact separator. Returns null when the separator is empty or does not occur. Example: "a/b/c".rsplit_once("/") is before: "a/b", after: "c".

Manuscript
fn rsplit_once(separator String) SplitParts?

String.scalar_at#

Returns the Unicode scalar value that starts at byte offset. An offset outside the text or inside a scalar returns default, and without one raises a fault.

Manuscript
fn scalar_at(offset Int, default Int? = null) Int

String.scalar_length#

Counts the Unicode scalar values by scanning the text.

Manuscript
fn scalar_length() Int

String.scalar_values#

Returns each Unicode scalar value as an integer.

Manuscript
fn scalar_values() List[Int]

String.slice#

Copies the bytes [start, end); negative bounds are relative to the end. Bounds outside the text clamp to it, and a start at or past the end gives "". A bound inside a scalar moves inward (start forward, end backward), so the result is always whole characters. The call never fails and leaves the receiver unchanged.

Manuscript
fn slice(start Int, end Int) String

String.split#

Splits at every exact separator, keeping empty pieces. Empty text with a nonempty separator yields [""]; an empty separator splits into scalars. The pieces borrow the receiver: use them in place, or .clone() the result to keep it.

Manuscript
fn split(separator String) List[String]

String.split_after#

Splits after each separator and keeps the separator at the end of each piece. An empty separator splits into scalars.

Manuscript
fn split_after(separator String) List[String]

String.split_once#

Splits at the first exact separator. Returns null when the separator is empty or does not occur. Example: "key=a=b".split_once("=") is before: "key", after: "a=b".

Manuscript
fn split_once(separator String) SplitParts?

String.starts_with#

Tests whether the receiver begins with this exact prefix.

Manuscript
fn starts_with(prefix String) Bool

String.title#

Titlecases the first letter of each word and lowercases the rest. A word is a run of letters, digits and apostrophes. Each word is lowercased as a whole, so a final sigma stays final (ΑΣ becomes Ας).

Manuscript
fn title() String

String.to_bytes#

Encodes the string as UTF-8 bytes.

Manuscript
fn to_bytes() Bytes

String.to_string#

A String is its own text.

Manuscript
fn to_string() String

String.trim#

Removes Unicode whitespace at both ends. The exact set is listed in the text guide. The result borrows the receiver, as view does: use it in place, or .clone() it to keep the text.

Manuscript
fn trim() String

String.trim_chars#

Removes every leading and trailing scalar that occurs in set.

Manuscript
fn trim_chars(set String) String

String.trim_end#

Removes Unicode whitespace at the end; borrows the receiver.

Manuscript
fn trim_end() String

String.trim_end_chars#

Removes every trailing scalar that occurs in set.

Manuscript
fn trim_end_chars(set String) String

String.trim_start#

Removes Unicode whitespace at the start; borrows the receiver.

Manuscript
fn trim_start() String

String.trim_start_chars#

Removes every leading scalar that occurs in set.

Manuscript
fn trim_start_chars(set String) String

String.upper#

Returns the text in full Unicode uppercase, independent of locale. The scalar length can change.

Manuscript
fn upper() String

String.view#

Borrows the bytes [start, end) of the receiver without copying; negative bounds are relative to the end. Bounds outside 0 <= start <= end <= length(), or inside a scalar, raise a fault. Like Bytes.view, the result borrows the receiver, which cannot change while the view is used; .clone() keeps the text. Use slice for a copy.

Manuscript
fn view(start Int, end Int) String

String.view_bytes#

Borrows the UTF-8 bytes of the text without copying. Like view, the result borrows the receiver, which cannot change while the bytes are used; .clone() keeps them. Use to_bytes for a copy.

Manuscript
fn view_bytes() Bytes

Stringable Interface#

A type with its own text form. f"{value}", print and a container’s text use to_string when a record or alternative has one; the operation must return a String. Every standard type with a text form meets this interface the same way, by declaring to_string.

Manuscript
interface Stringable {
    fn to_string() String
}

Stringable.to_string#

Returns this value as text.

Manuscript
fn to_string() String

UInt16 Type#

Unsigned 16-bit whole numbers (0 to 65535); arithmetic faults when the result leaves the range.

Manuscript
type UInt16 { ... }

UInt16.clone#

Returns the value itself: a UInt16 copies by value.

Manuscript
fn clone() UInt16

UInt16.compare#

Returns -1, 0 or 1 as this value is less than, equal to or greater than other.

Manuscript
fn compare(other UInt16) Int

UInt16.to_binary#

Formats the integer in base 2 with a leading - for negatives, as to_string_radix(2) does; it cannot fail.

Manuscript
fn to_binary() String

UInt16.to_decimal#

Converts to the exactly equal Decimal; no rounding occurs.

Manuscript
fn to_decimal() Decimal

UInt16.to_float#

Converts to the nearest Float; integers beyond 2^53 in magnitude can lose low-order digits.

Manuscript
fn to_float() Float

UInt16.to_float32#

Converts to Float32, rounding to the nearest binary32 value.

Manuscript
fn to_float32() Float32

UInt16.to_hex#

Formats the integer in base 16 using lowercase digits and a leading - for negatives, as to_string_radix(16) does; it cannot fail.

Manuscript
fn to_hex() String

UInt16.to_int#

Converts to Int; every value fits, so no check is needed.

Manuscript
fn to_int() Int

UInt16.to_string_radix#

Formats the integer in a radix from 2 through 36 using lowercase digits and a leading - for negatives, or null when the radix is outside 2 through 36.

Manuscript
fn to_string_radix(radix Int) String?

UInt16.to_uint8#

Converts to UInt8, or returns null when the value is outside UInt8’s range.

Manuscript
fn to_uint8() UInt8?

UInt32 Type#

Unsigned 32-bit whole numbers (0 to 4294967295); arithmetic faults when the result leaves the range.

Manuscript
type UInt32 { ... }

UInt32.clone#

Returns the value itself: a UInt32 copies by value.

Manuscript
fn clone() UInt32

UInt32.compare#

Returns -1, 0 or 1 as this value is less than, equal to or greater than other.

Manuscript
fn compare(other UInt32) Int

UInt32.to_binary#

Formats the integer in base 2 with a leading - for negatives, as to_string_radix(2) does; it cannot fail.

Manuscript
fn to_binary() String

UInt32.to_decimal#

Converts to the exactly equal Decimal; no rounding occurs.

Manuscript
fn to_decimal() Decimal

UInt32.to_float#

Converts to the nearest Float; integers beyond 2^53 in magnitude can lose low-order digits.

Manuscript
fn to_float() Float

UInt32.to_float32#

Converts to Float32, rounding to the nearest binary32 value.

Manuscript
fn to_float32() Float32

UInt32.to_hex#

Formats the integer in base 16 using lowercase digits and a leading - for negatives, as to_string_radix(16) does; it cannot fail.

Manuscript
fn to_hex() String

UInt32.to_int#

Converts to Int; every value fits, so no check is needed.

Manuscript
fn to_int() Int

UInt32.to_int32#

Converts to Int32, or returns null when the value is outside Int32’s range.

Manuscript
fn to_int32() Int32?

UInt32.to_int64#

Converts to Int64; every value fits, so no check is needed.

Manuscript
fn to_int64() Int64

UInt32.to_string_radix#

Formats the integer in a radix from 2 through 36 using lowercase digits and a leading - for negatives, or null when the radix is outside 2 through 36.

Manuscript
fn to_string_radix(radix Int) String?

UInt64 Type#

Unsigned 64-bit whole numbers (0 to 18446744073709551615); arithmetic faults when the result leaves the range.

Manuscript
type UInt64 { ... }

UInt64.clone#

Returns the value itself: a UInt64 copies by value.

Manuscript
fn clone() UInt64

UInt64.compare#

Returns -1, 0 or 1 as this value is less than, equal to or greater than other.

Manuscript
fn compare(other UInt64) Int

UInt64.to_binary#

Formats the integer in base 2 with a leading - for negatives, as to_string_radix(2) does; it cannot fail.

Manuscript
fn to_binary() String

UInt64.to_decimal#

Converts to the exactly equal Decimal; no rounding occurs.

Manuscript
fn to_decimal() Decimal

UInt64.to_float#

Converts to the nearest Float; integers beyond 2^53 in magnitude can lose low-order digits.

Manuscript
fn to_float() Float

UInt64.to_float32#

Converts to Float32, rounding to the nearest binary32 value.

Manuscript
fn to_float32() Float32

UInt64.to_hex#

Formats the integer in base 16 using lowercase digits and a leading - for negatives, as to_string_radix(16) does; it cannot fail.

Manuscript
fn to_hex() String

UInt64.to_int#

Converts to Int, or returns null when the value is above Int’s maximum.

Manuscript
fn to_int() Int?

UInt64.to_string_radix#

Formats the integer in a radix from 2 through 36 using lowercase digits and a leading - for negatives, or null when the radix is outside 2 through 36.

Manuscript
fn to_string_radix(radix Int) String?

UInt64.to_uint32#

Converts to UInt32, or returns null when the value is outside UInt32’s range.

Manuscript
fn to_uint32() UInt32?

UInt64.to_uint8#

Converts to UInt8, or returns null when the value is outside UInt8’s range.

Manuscript
fn to_uint8() UInt8?

UInt8 Type#

Unsigned 8-bit whole numbers (0 to 255); arithmetic faults when the result leaves the range.

Manuscript
type UInt8 { ... }

UInt8.clone#

Returns the value itself: a UInt8 copies by value.

Manuscript
fn clone() UInt8

UInt8.compare#

Returns -1, 0 or 1 as this value is less than, equal to or greater than other.

Manuscript
fn compare(other UInt8) Int

UInt8.to_binary#

Formats the integer in base 2 with a leading - for negatives, as to_string_radix(2) does; it cannot fail.

Manuscript
fn to_binary() String

UInt8.to_decimal#

Converts to the exactly equal Decimal; no rounding occurs.

Manuscript
fn to_decimal() Decimal

UInt8.to_float#

Converts to the nearest Float; integers beyond 2^53 in magnitude can lose low-order digits.

Manuscript
fn to_float() Float

UInt8.to_float32#

Converts to Float32, rounding to the nearest binary32 value.

Manuscript
fn to_float32() Float32

UInt8.to_hex#

Formats the integer in base 16 using lowercase digits and a leading - for negatives, as to_string_radix(16) does; it cannot fail.

Manuscript
fn to_hex() String

UInt8.to_int#

Converts to Int; every value fits, so no check is needed.

Manuscript
fn to_int() Int

UInt8.to_string_radix#

Formats the integer in a radix from 2 through 36 using lowercase digits and a leading - for negatives, or null when the radix is outside 2 through 36.

Manuscript
fn to_string_radix(radix Int) String?

Void Type#

The single value void, used when an operation returns no useful payload.

Manuscript
type Void { ... }