Package Tree

builtin
cbindgen
core
main
runtime
simd

package core

Pair :: struct (First_Type: type_expr, Second_Type: type_expr) {
    first: First_Type;
    second: Second_Type;
}

A Pair represents a pair of values of heterogenous types. This structure does not do much on its own; however, it is useful because provides overloads for formatting, hashing and equality. This means you can use a Pair(T, R) as a key for a Map or Set out of the box, provided T and R are hashable and equatable.

Methods
_format :: (output: &conv.Format_Output, format: &conv.Format, p: &Pair($First_Type, $Second_Type)) -> void
make :: macro (x: $X, y: $Y) -> #auto
cptr :: struct (T: type_expr) {
    data: u64;
}
Methods
as_unsafe :: (this: cptr($T), $new_type: type_expr) -> cptr(new_type)
at :: (this: cptr($T), index: i32) -> T
extract_str :: (this: cptr(u8), dest: [] u8) -> u32
format :: (output: &conv.Format_Output, format: &conv.Format, p: &cptr($T)) -> void
make :: macro (ptr: &$T) -> cptr(T)
read :: (this: cptr(void)) -> void
read :: (this: cptr($T)) -> T
read :: (this: cptr($T), buffer: [] u8) -> void
read_i16 :: (this: cptr(i16)) -> i16
read_i32 :: (this: cptr(i32)) -> i32
read_i64 :: (this: cptr(i64)) -> i64
read_i8 :: (this: cptr(i8)) -> i8
read_u16 :: (this: cptr(u16)) -> u16
read_u32 :: (this: cptr(u32)) -> u32
read_u64 :: (this: cptr(u64)) -> u64
read_u8 :: (this: cptr(u8)) -> u8
to_rawptr :: (this: cptr($T)) -> &T
Result :: union (Ok_Type: type_expr, Err_Type: type_expr) {
    Err: Err_Type;
    Ok: Ok_Type;
}

Result(T, E) is a structure that represents either an Ok value of type T, or an Err value of type E. status contains either .Ok, or .Err depending on which is currently held.

Methods
and_then :: (r: Result, f: (r.Ok_Type) -> Result($R, r.Err_Type)) -> Result(R, r.Err_Type)

Monadic chaining operation.

catch :: macro (r: Result($T, $E), on_err: Code) -> T

If result contains Err, the given code is run. This code is expected to either:

  • Return a good value with return
  • Return an error value with return return

This procedure is subject to change.

err :: (r: Result) -> Optional(r.Err_Type)

Returns an Optional of the Err type.

expect :: (r: Result, msg: [] u8) -> r.Ok_Type

Tries to extract the Ok value out of the Result. If the result contains an Err, a custom assertion message is thrown.

forward_err :: macro (r: Result($T, $E)) -> T

If result contains Err, the error is returned from the enclosing procedure. Otherwise, the Ok value is returned.

f :: () -> Result(i32, str) {
    return .{ Err = "Oh no..." };
}

g :: () -> Result(str, str) {
    // This returns from g with the error returned from f.
    v := f()->forward_err();
    println(v);
    
    return .{ Ok = "Success!" };
}
is_err :: (r: Result) -> bool

Returns true if the result contains an Err value.

is_ok :: (r: Result) -> bool

Returns true if the result contains an Ok value.

ok :: (r: Result) -> Optional(r.Ok_Type)

Returns an Optional of the Ok type.

or_else :: (r: Result, generate: () -> unknown) -> #auto

If the Result contains Err, generate is called to make a value

or_return :: macro (r: Result($T, $E), v: $V) -> T

If result contains Err, the given value is returned from the enclosing procedure. Otherwise, the Ok value is returned.

transform :: (r: Result($T, $E), f: (T) -> $R) -> Result(R, E)

Returns a new result defined by:

Ok(n)  => Ok(f(n))
Err(e) => Err(e)
unwrap :: (r: Result) -> r.Ok_Type

Forcefully extracts the Ok value out of the Result. If the result contains an Err, an assertion is thrown.

unwrap_or_default :: (r: Result) -> r.Ok_Type

Tries to extract the Ok value out of the Result. If the result contains an Err, the empty .{} value is returned.

__byte_dump :: (ptr: rawptr, byte_count: u32, bytes_per_line: i32) -> void
__flush_stdio :: () -> void
__stdio_init :: () -> void
aprintf :: (format: [] u8, va: ..any) -> [] u8
eprintf :: (format: [] u8, va: ..any) -> [] u8
print :: (x: [] u8) -> void
print :: (x: $__type_x) -> #auto
print :: (x: $__type_x, y: $__type_y) -> #auto
printf :: (format: [] u8, va: ..any) -> void
println :: (x: $__type_x) -> #auto
tprintf :: (format: [] u8, va: ..any) -> [] u8