Module prelude

prelude

Prelude — automatically imported into every Yo source file.

Provides core language primitives: traits (Comptime, Runtime, Clone, Eq, Ord, Hash, …), fundamental types (Option, Result, Box, Slice, Range, String, …), operator traits (Add, Sub, …), type reflection (TypeInfo), conversion (Into, From), the async runtime (IO, Future, JoinHandle), and derive rules.

Do NOT import std/prelude — it is loaded automatically and an explicit import will produce a compile error.

Types

Range type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_847) : Type)

Half-open range start..end (excludes end).

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(forall(T : Type), Range(T), Acyclic())
impl(forall(T : Type), where(T <: Comptime), Range(T), Comptime())
impl(forall(T : Type), where(T <: Runtime), Range(T), Runtime())
RangeInclusive type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_880) : Type)

Inclusive range start..=end (includes end).

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(forall(T : Type), RangeInclusive(T), Acyclic())
impl(forall(T : Type), where(T <: Comptime), RangeInclusive(T), Comptime())
impl(forall(T : Type), where(T <: Runtime), RangeInclusive(T), Runtime())
Ordering enum
Ordering

Ordering — result of a comparison.

Variants

VariantFieldsDescription
Less

Left-hand side is less than right-hand side.

Equal

Both sides are equal.

Greater

Left-hand side is greater than right-hand side.

comptime_float type-alias
comptime_float

Trait Implementations

comptime_string type-alias
comptime_string

Trait Implementations

bool type-alias
bool

Trait Implementations

str newtype
str

str — an immutable UTF-8 byte string view (newtype over Slice(u8)).

String literals "hello" produce str at runtime. For heap-allocated growable strings, see String.

Fields

NameTypeDescription
bytes[u8]

The underlying byte slice.

Trait Implementations

impl(str, ...)
from_raw_parts : (str) fn(ptr : *(u8), length : usize) -> str

Construct a str from a raw pointer and length.

Parameters

NameTypeNotes
ptr*(u8)
lengthusize

Returns: str

len : (str) fn(self : str) -> usize

Return the length in bytes.

Parameters

NameTypeNotes
selfstr

Returns: usize

ptr : (str) fn(self : str) -> *(u8)

Parameters

NameTypeNotes
selfstr

Returns: *(u8)

impl(str, Eq(str)(...))
impl(str, Ord(str)(...))
ExprList type-alias
ComptimeList(Expr)

ExprList

Expr type-alias
Expr

Trait Implementations

Comptime Acyclic ComptimeEq ComptimeToString
Type type-alias
Type

Trait Implementations

StructKind enum
StructKind

Type reflection metadata structs — used by Type.get_info(). StructKind — discriminant for struct flavors.

Variants

VariantFieldsDescription
Struct

Regular value struct.

Object

Reference-counted object.

AtomicObject

Atomic reference-counted object.

NewType

Single-field newtype wrapper.

Trait Implementations

impl(StructKind, Comptime())
TypeFieldInfo struct
TypeFieldInfo

TypeFieldInfo — metadata for a single struct/object field.

Fields

NameTypeDescription
namecomptime_string

Variant name.

field_typeType

Field type.

Trait Implementations

impl(TypeFieldInfo, Comptime())
impl(TypeFieldInfo, ...)
to_expr : (TypeFieldInfo) fn(comptime(self) : TypeFieldInfo) -> (comptime(fn_return_yocd6da6f3_id_20215) : Expr)

Convert the field name to a quoted expression.

Parameters

NameTypeNotes
selfTypeFieldInfocomptime

Returns: Expr

TraitInfo struct
TraitInfo

TraitInfo — lightweight reference to a trait type.

Fields

NameTypeDescription
trait_typeType

The trait's Type value.

Trait Implementations

impl(TraitInfo, Comptime())
TraitFieldInfo

TraitFieldInfo — metadata for a single trait field.

Fields

NameTypeDescription
namecomptime_string

Variant name.

field_typeType

Field type.

is_associated_typebool

true if this field is an associated type (not a method).

Trait Implementations

impl(TraitFieldInfo, Comptime())
ParamInfo struct
ParamInfo

ParamInfo — metadata for a function parameter.

Fields

NameTypeDescription
namecomptime_string

Variant name.

param_typeType

Parameter type.

is_comptimebool

true if the parameter is compile-time (comptime).

is_quotebool

true if the parameter uses quote.

is_variadicbool

true if the parameter is variadic.

Trait Implementations

impl(ParamInfo, Comptime())
ForallParamInfo

ForallParamInfo — metadata for a forall type parameter.

Fields

NameTypeDescription
namecomptime_string

Variant name.

param_typeType

Parameter type.

Trait Implementations

impl(ForallParamInfo, Comptime())
ImplicitParamInfo

ImplicitParamInfo — metadata for a using/effect parameter.

Fields

NameTypeDescription
namecomptime_string

Variant name.

param_typeType

Parameter type.

Trait Implementations

impl(ImplicitParamInfo, Comptime())
FunctionInfo struct
FunctionInfo

FunctionInfo — metadata for a function type.

Fields

NameTypeDescription
paramsComptimeList(ParamInfo)

Regular parameters.

return_typeType

Return type.

forall_paramsComptimeList(ForallParamInfo)

Optional forall parameters for generic types.

implicit_paramsComptimeList(ImplicitParamInfo)

Implicit using parameters.

is_closurebool

true if this is a closure type.

Trait Implementations

impl(FunctionInfo, Comptime())
TraitKind enum
TraitKind

TraitKind — discriminant for different trait flavors.

Variants

VariantFieldsDescription
Futurechild: Type, effects: ComptimeList(TraitInfo)

A Future trait with child type and effects.

Fncall: FunctionInfo

A callable Fn trait with function info.

Normal

A normal user-defined trait.

Trait Implementations

impl(TraitKind, Comptime())
VariantInfo struct
VariantInfo

VariantInfo — metadata for an enum variant.

Fields

NameTypeDescription
namecomptime_string

Variant name.

fieldsComptimeList(TypeFieldInfo)

Variant fields (may be empty for unit variants).

_enum_typeType
_variant_indexusize

Trait Implementations

impl(VariantInfo, Comptime())
TypeInfo enum
TypeInfo

TypeInfo — compile-time enum representing rich type metadata. Returned by Type.get_info() for compile-time type reflection.

Variants

VariantFieldsDescription
Unit
Bool
Usize
Isize
U8
I8
U16
I16
U32
I32
U64
I64
F32
F64
Char
Short
UShort
Int
UInt
Long
ULong
LongLong
ULongLong
LongDouble
Void
Arrayelement: Type, length: comptime_int
Sliceelement: Type
Tuplefields: ComptimeList(TypeFieldInfo)
Structfields: ComptimeList(TypeFieldInfo), kind: StructKind

Regular value struct.

Enumvariants: ComptimeList(VariantInfo)
Unionfields: ComptimeList(TypeFieldInfo)
Functioninfo: FunctionInfo
Ptrpointee: Type
Isochild: Type
Dynrequired_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo)
Modulefields: ComptimeList(TypeFieldInfo)
Traitfields: ComptimeList(TraitFieldInfo), kind: TraitKind
Typelevel: comptime_int
Somename: comptime_string, required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo), resolved_type: Type
ComptimeInt
ComptimeFloat
ComptimeString
ComptimeListelement: Type
Expr
EffectsRow
TypeApplication

Trait Implementations

impl(TypeInfo, Comptime())
impl(TypeInfo, ...)
is_struct : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20300) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_enum : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20303) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_union : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20306) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_tuple : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20309) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_array : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20312) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_slice : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20315) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_function : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20318) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_pointer : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20321) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_trait : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20324) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_module : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20327) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_void : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20330) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_primitive : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20333) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_integer : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20336) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_float : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20339) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_comptime : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20342) : bool)

true if the parameter is compile-time (comptime).

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_numeric : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20345) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

FieldInfo struct
FieldInfo

FieldInfo — compile-time struct field metadata for derive rules (legacy alias).

Fields

NameTypeDescription
namecomptime_string

Variant name.

field_typeType

Field type.

Trait Implementations

impl(FieldInfo, Comptime())
impl(FieldInfo, ...)
to_expr : (FieldInfo) fn(comptime(self) : FieldInfo) -> (comptime(fn_return_yocd6da6f3_id_20416) : Expr)

Convert the field name to a quoted expression.

Parameters

NameTypeNotes
selfFieldInfocomptime

Returns: Expr

Option type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_20488) : Type)

Option — a value that may or may not be present.

Option(T) has two variants:

  • .Some(value) — contains a value of type T
  • .None — contains no value

Example

(x : Option(i32)) = .Some(i32(42));
assert(x.is_some(), "expected Some");
assert((x.unwrap() == i32(42)), "expected 42");

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(forall(T : Type), Option(T), ...)
unwrap : (fn(self : Self) -> T)

Extract the Ok value, panicking if Err.

Returns: T

unwrap_or : (fn(self : Self, or_value : T) -> T)

Extract the contained value, or return or_value if None.

Returns: T

is_some : (fn(self : Self) -> bool)

Return true if the option contains a value.

Returns: bool

is_none : (fn(self : Self) -> bool)

Return true if the option is None.

Returns: bool

impl(forall(T : Type), Option(T), ...)
map : (fn(forall(B : Type), self : Self, f : Impl(Fn(a : T) -> B)) -> Option(B))

Map the Ok value with f, leaving Err untouched.

Returns: Option(B)

and_then : (fn(forall(B : Type), self : Self, f : Impl(Fn(a : T) -> Option(B))) -> Option(B))

Chain a computation that may fail on the Ok value.

Returns: Option(B)

filter : (fn(self : Self, predicate : Impl(Fn(a : T) -> bool)) -> Option(T))

Return Some(value) if the predicate returns true, otherwise None.

Returns: Option(T)

or_else : (fn(self : Self, f : Impl(Fn() -> Option(T))) -> Option(T))

Chain a recovery computation on the Err value.

Returns: Option(T)

map_or : (fn(forall(B : Type), self : Self, default_val : B, f : Impl(Fn(a : T) -> B)) -> B)

Apply f if Ok, otherwise return default_val.

Returns: B

map_or_else : (fn(forall(B : Type), self : Self, default_fn : Impl(Fn() -> B), f : Impl(Fn(a : T) -> B)) -> B)

Apply f if Ok, otherwise call default_fn with the error.

Returns: B

and : (fn(forall(B : Type), self : Self, optb : Option(B)) -> Option(B))

Return res if Ok, otherwise propagate Err.

Returns: Option(B)

or : (fn(self : Self, optb : Option(T)) -> Option(T))

Return self if Ok, otherwise return res.

Returns: Option(T)

unwrap_or_else : (fn(self : Self, f : Impl(Fn() -> T)) -> T)

Extract the Ok value, or call f with the error to produce a fallback.

Returns: T

impl(forall(T : Type), Option(Option(T)), ...)
flatten : (fn(self : Self) -> Option(T))

Collapse one level of nesting.

Returns: Option(T)

impl(forall(T : Type), where(T <: Comptime), Option(T), Comptime())
impl(forall(T : Type), where(T <: Comptime), Option(T), ...)
comptime_unwrap : (fn(comptime(self) : Self) -> comptime(T))

Compile-time unwrap — panics at compile-time if Err.

Returns: comptime(T)

comptime_unwrap_or : (fn(comptime(self) : Self, comptime(or_value) : T) -> comptime(T))

Returns: comptime(T)

comptime_is_some : (fn(comptime(self) : Self) -> comptime(bool))

Returns: comptime(bool)

comptime_is_none : (fn(comptime(self) : Self) -> comptime(bool))

Returns: comptime(bool)

impl(forall(T : Type), Option(T), ...)
ok_or : (fn(forall(E : Type), self : Self, err : E) -> Result(T, E))

Convert Some(value) to Ok(value), or return Err(err) if None.

Returns: Result(T, E)

ok_or_else : (fn(forall(E : Type), self : Self, err_fn : Impl(Fn() -> E)) -> Result(T, E))

Convert Some(value) to Ok(value), or call err_fn to produce Err if None.

Returns: Result(T, E)

? type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_20488) : Type)

Type Parameters

NameTypeNotes
TTypecomptime
?* type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_20986) : Type)

Type Parameters

NameTypeNotes
TTypecomptime
DeriveContext struct
DeriveContext

DeriveContext — context passed to derive rule functions (needs Option). Used by the derive macro to generate trait implementations.

Fields

NameTypeDescription
targetExpr

The AST expression for the target type.

forall_paramsOption(Expr)

Optional forall parameters for generic types.

where_clauseOption(Expr)

Optional where clause for constrained generics.

Trait Implementations

impl(DeriveContext, Comptime())
impl(DeriveContext, ...)
make_impl : (DeriveContext) fn(comptime(self) : DeriveContext, comptime(trait_body) : Expr) -> (comptime(fn_return_yocd6da6f3_id_21037) : Expr)

Parameters

NameTypeNotes
selfDeriveContextcomptime
trait_bodyExprcomptime

Returns: Expr

Result type-function
fn(comptime(OkType) : Type, comptime(ErrorType) : Type) -> (comptime(fn_return_yocd6da6f3_id_23017) : Type)

Result — a value that is either success (Ok) or failure (Err).

Result(OkType, ErrorType) has two variants:

  • .Ok(value) — contains a success value of type OkType
  • .Err(error) — contains an error value of type ErrorType

Example

(r : Result(i32, str)) = .Ok(i32(42));
assert(r.is_ok(), "expected Ok");

Type Parameters

NameTypeNotes
OkTypeTypecomptime
ErrorTypeTypecomptime

Trait Implementations

impl(forall(OkType : Type, ErrorType : Type), Result(OkType, ErrorType), ...)
unwrap : (fn(self : Self) -> OkType)

Extract the Ok value, panicking if Err.

Returns: OkType

unwrap_err : (fn(self : Self) -> ErrorType)

Extract the Err value, panicking if Ok.

Returns: ErrorType

is_ok : (fn(self : Self) -> bool)

Return true if the result is Ok.

Returns: bool

is_err : (fn(self : Self) -> bool)

Return true if the result is Err.

Returns: bool

impl(forall(OkType : Type, ErrorType : Type), Result(OkType, ErrorType), ...)
map : (fn(forall(B : Type), self : Self, f : Impl(Fn(a : OkType) -> B)) -> Result(B, ErrorType))

Map the Ok value with f, leaving Err untouched.

Returns: Result(B, ErrorType)

map_err : (fn(forall(F : Type), self : Self, f : Impl(Fn(a : ErrorType) -> F)) -> Result(OkType, F))

Map the Err value with f, leaving Ok untouched.

Returns: Result(OkType, F)

and_then : (fn(forall(B : Type), self : Self, f : Impl(Fn(a : OkType) -> Result(B, ErrorType))) -> Result(B, ErrorType))

Chain a computation that may fail on the Ok value.

Returns: Result(B, ErrorType)

or_else : (fn(forall(F : Type), self : Self, f : Impl(Fn(a : ErrorType) -> Result(OkType, F))) -> Result(OkType, F))

Chain a recovery computation on the Err value.

Returns: Result(OkType, F)

and : (fn(forall(B : Type), self : Self, res : Result(B, ErrorType)) -> Result(B, ErrorType))

Return res if Ok, otherwise propagate Err.

Returns: Result(B, ErrorType)

or : (fn(forall(F : Type), self : Self, res : Result(OkType, F)) -> Result(OkType, F))

Return self if Ok, otherwise return res.

Returns: Result(OkType, F)

ok : (fn(self : Self) -> Option(OkType))

Convert to Option(OkType), discarding the error.

Returns: Option(OkType)

err : (fn(self : Self) -> Option(ErrorType))

Convert to Option(ErrorType), discarding the success value.

Returns: Option(ErrorType)

map_or : (fn(forall(B : Type), self : Self, default_val : B, f : Impl(Fn(a : OkType) -> B)) -> B)

Apply f if Ok, otherwise return default_val.

Returns: B

map_or_else : (fn(forall(B : Type), self : Self, default_fn : Impl(Fn(a : ErrorType) -> B), f : Impl(Fn(a : OkType) -> B)) -> B)

Apply f if Ok, otherwise call default_fn with the error.

Returns: B

unwrap_or_else : (fn(self : Self, f : Impl(Fn(a : ErrorType) -> OkType)) -> OkType)

Extract the Ok value, or call f with the error to produce a fallback.

Returns: OkType

impl(forall(OkType : Type, ErrorType : Type), where(OkType <: Comptime, ErrorType <: Comptime), Result(OkType, ErrorType), Comptime())
impl(forall(OkType : Type, ErrorType : Type), where(OkType <: Comptime, ErrorType <: Comptime), Result(OkType, ErrorType), ...)
comptime_unwrap : (fn(comptime(self) : Self) -> comptime(OkType))

Compile-time unwrap — panics at compile-time if Err.

Returns: comptime(OkType)

comptime_unwrap_err : (fn(comptime(self) : Self) -> comptime(ErrorType))

Returns: comptime(ErrorType)

comptime_is_ok : (fn(comptime(self) : Self) -> comptime(bool))

Returns: comptime(bool)

comptime_is_err : (fn(comptime(self) : Self) -> comptime(bool))

Returns: comptime(bool)

Box type-function
fn(comptime(V) : Type) -> (comptime(fn_return_yocd6da6f3_id_23779) : Type)

Box — a heap-allocated, reference-counted container for a single value.

Use box(value) to allocate. Access the inner value with b.*.

Example

b := box(i32(42));
assert((b.* == i32(42)), "inner value is 42");

Type Parameters

NameTypeNotes
VTypecomptime

Trait Implementations

impl(forall(T : Type), Box(T), Isolation(...))
can_isolate : ((self) -> (rc(self) == 1))
impl(forall(T : Type), where(T <: Hash), Box(T), Hash( (hash) : ((self) -> (self.*).*.hash()) ))
impl(forall(T : Type), where(T <: Eq(T)), Box(T), Eq(Box(T)))
Arc type-function
fn(comptime(V) : Type) -> (comptime(fn_return_yocd6da6f3_id_24073) : Type)

=== Arc === Arc — an atomically reference-counted, thread-safe container for a single value.

Use arc(value) to allocate. Access the inner value with a.*.

Example

a := arc(i32(42));
assert((a.* == i32(42)), "inner value is 42");

Type Parameters

NameTypeNotes
VTypecomptime

Trait Implementations

impl(forall(T : Type), where(T <: (Send, Acyclic)), Arc(T), Send())
MaybeUninit type-function
fn(comptime(BaseType) : Type) -> (comptime(fn_return_yocd6da6f3_id_24264) : Type)

MaybeUninit — a wrapper that allows holding an uninitialized value.

Useful for FFI or low-level patterns where a value must be allocated first and initialized later (e.g., by a C function).

Example

extern "C",
  time_t : Type,
  time : fn(timer: ?*(time_t)) -> time_t
;

uninitialized_timer := MaybeUninit(time_t).new();
ptr := uninitialized_timer.as_ptr();
time(.Some(ptr));
timer := uninitialized_timer.assume_init();

Type Parameters

NameTypeNotes
BaseTypeTypecomptime
impl(forall(BaseType : Type), MaybeUninit(BaseType), ...)
new : (fn() -> Self)

Create a new uninitialized value.

Returns: Self

as_ptr : (fn(self: *(Self)) -> *(BaseType))

Get a mutable pointer to the underlying value.

Returns: *(BaseType)

assume_init : (fn(own(self) : Self) -> BaseType)

Assume the value is initialized and extract it. Undefined behavior if not initialized.

Returns: BaseType

ArrayIterPtr type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_24429) : Type)

Pointer iterator for Array(T, N) - yields *(T) pointers to each element Used by Array.iter()

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(forall(T : Type), ArrayIterPtr(T), Iterator(...))
Item : *(T)
next : (fn(self : *(Self)) -> Option(*(T)))

Returns: Option(*(T))

SliceIterPtr type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_24554) : Type)

Pointer iterator for Slice(T) - yields *(T) pointers to each element Used by Slice.iter()

Type Parameters

NameTypeNotes
TTypecomptime

Trait Implementations

impl(forall(T : Type), SliceIterPtr(T), Iterator(...))
Item : *(T)
next : (fn(self : *(Self)) -> Option(*(T)))

Returns: Option(*(T))

FutureState

FutureState — the state of an async Future.

Variants

VariantFieldsDescription
Pending

The future has been created but not yet started.

Running

The future is actively running.

Completed

The future completed successfully.

Aborted

The future was aborted (e.g., via escape).

Trait Implementations

impl(FutureState, Acyclic())
impl(FutureState, Runtime())
impl(FutureState, Send())
impl(FutureState, Eq(FutureState))
JoinHandle type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_24954) : Type)

JoinHandle — a handle to a spawned async task. Wraps a raw pointer to the spawned future's state machine. Generic over T, the return type of the spawned task.

Type Parameters

NameTypeNotes
TTypecomptime
impl(forall(T : Type), JoinHandle(T), ...)
await : __yo_join_handle_await

Await a Future, suspending until its result is ready.

Returns: unknown

Traits / Modules

Comptime trait
Comptime

Comptime trait — indicates a type that can be used at compile-time. Examples: i32, bool, Type, comptime_int, comptime_float, comptime_string. Non-examples: int, ushort (runtime-only types).

Implementors

Runtime trait
Runtime

Runtime trait — indicates a type that can be used at runtime. Examples: i32, bool, *(i32), void. Non-examples: comptime_int, comptime_float, comptime_string, Type (compile-time-only types).

Implementors

Send trait
Send

Send trait — indicates a type that can be safely transferred between threads.

Implementors

Acyclic trait
Acyclic

Acyclic trait - indicates a type that cannot form reference cycles. Types that implement Acyclic don't need cycle collection tracking. Primitive types, value types without object fields, and objects that don't reference back to themselves (directly or indirectly) are Acyclic.

Implementors

Rc trait
Rc

The Rc trait means the type is reference counted object type.

Dispose trait
Dispose

Dispose trait - defines a dispose method for cleaning up resources.

Methods

dispose : fn(self : Self) -> unit

Parameters

NameTypeNotes
selfSelf

Returns: unit

Implementors

Index trait-function
fn(comptime(Idx) : Type) -> (comptime(fn_return_yocd6da6f3_id_755) : Type(1))

Index trait — enables container(idx) subscript syntax at runtime. The Idx parameter is the index type (e.g., usize, Range(usize)). Implementations must define an Output associated type and an index method.

Type Parameters

NameTypeNotes
IdxTypecomptime

Implementors

ComptimeIndex trait-function
fn(comptime(Idx) : Type) -> (comptime(fn_return_yocd6da6f3_id_801) : Type(1))

ComptimeIndex — compile-time indexing trait for constant expressions.

Type Parameters

NameTypeNotes
IdxTypecomptime

Implementors

RangeOp trait
RangeOp

RangeOp trait — enables start..end operator syntax.

Methods

.. : fn(start : Self, end : Self) -> Range(Self)

Parameters

NameTypeNotes
startSelf
endSelf

Returns: Range(Self)

Implementors

RangeInclusiveOp

RangeInclusiveOp trait — enables start..=end operator syntax.

Methods

..= : fn(start : Self, end : Self) -> RangeInclusive(Self)

Parameters

NameTypeNotes
startSelf
endSelf

Returns: RangeInclusive(Self)

Implementors

ComptimeRangeOp

Methods

.. : fn(comptime(start) : Self, comptime(end) : Self) -> (comptime(fn_return_yocd6da6f3_id_1328) : Range(Self))

Parameters

NameTypeNotes
startSelfcomptime
endSelfcomptime

Returns: Range(Self)

Implementors

ComptimeRangeInclusiveOp

Methods

..= : fn(comptime(start) : Self, comptime(end) : Self) -> (comptime(fn_return_yocd6da6f3_id_1361) : RangeInclusive(Self))

Parameters

NameTypeNotes
startSelfcomptime
endSelfcomptime

Returns: RangeInclusive(Self)

Implementors

Add trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1379) : Type(1))

Add trait — enables lhs + rhs operator. Parameterized by Rhs type.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeAdd trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1425) : Type(1))

Compile-time variant of Add.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Sub trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1471) : Type(1))

Sub trait — enables lhs - rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeSub trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1517) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Mul trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1563) : Type(1))

Mul trait — enables lhs * rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeMul trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1609) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Div trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1655) : Type(1))

Div trait — enables lhs / rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeDiv trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1701) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Mod trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1747) : Type(1))

Mod trait — enables lhs % rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeMod trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1793) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitLeftShift trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1839) : Type(1))

BitLeftShift trait — enables lhs << rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitLeftShift trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1885) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitRightShift trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1931) : Type(1))

BitRightShift trait — enables lhs >> rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitRightShift trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1977) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Exponentiation trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2023) : Type(1))

Exponentiation trait — enables lhs ** rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime
ComptimeExponentiation trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2069) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime
Negate trait
Negate

Negate trait — enables unary -value operator.

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

neg : fn(self : Self) -> Output

Parameters

NameTypeNotes
selfSelf

Returns: Output

Implementors

ComptimeNegate

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

neg : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2151) : Output(Comptime))

Parameters

NameTypeNotes
selfSelfcomptime

Returns: Output(Comptime)

Implementors

LogicalNot trait
LogicalNot

LogicalNot trait — enables !value boolean negation.

Methods

! : fn(self : Self) -> bool

Parameters

NameTypeNotes
selfSelf

Returns: bool

Implementors

ComptimeLogicalNot

Methods

! : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2173) : bool)

Parameters

NameTypeNotes
selfSelfcomptime

Returns: bool

Implementors

BitNot trait
BitNot

BitNot trait — enables ~value bitwise complement.

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

~ : fn(self : Self) -> Output

Parameters

NameTypeNotes
selfSelf

Returns: Output

Implementors

ComptimeBitNot

Associated Types

NameConstraintDescription
OutputType

The output type of the addition.

Methods

~ : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2227) : Output(Comptime))

Parameters

NameTypeNotes
selfSelfcomptime

Returns: Output(Comptime)

Implementors

BitAnd trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2245) : Type(1))

BitAnd trait — enables lhs & rhs bitwise AND.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitAnd trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2291) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitOr trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2337) : Type(1))

BitOr trait — enables lhs | rhs bitwise OR.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitOr trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2383) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitXor trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2429) : Type(1))

BitXor trait — enables lhs ^ rhs bitwise XOR.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeBitXor trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2475) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Eq trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2656) : Type(1))

Eq trait — enables == and != comparison operators. The != method has a default implementation that negates ==.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

ComptimeEq trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2689) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Ord trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2742) : Type(1))

Ord trait — enables <, <=, >, >= comparison operators. Requires the type to also implement Eq.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Hash trait
Hash

Hash trait - Similar to Rust's std:#️⃣:Hash

This trait defines the ability to hash a value into a u64. Types that implement Hash can be used as keys in HashMap and HashSet.

The hash function should satisfy:

  1. Deterministic: The same value always produces the same hash
  2. Consistent with Eq: If a == b, then hash(a) == hash(b)

Note: Unlike Rust which uses a Hasher trait for incremental hashing, we use a simpler approach where each type directly produces a u64 hash.

Methods

hash : fn(self : *(Self)) -> u64

Compute the hash of a value Returns a u64 hash value

Parameters

NameTypeNotes
self*(Self)

Returns: u64

Implementors

Clone trait
Clone

Clone trait — deep-copy a value.

Methods

clone : fn(self : *(Self)) -> Self

Create an independent clone of self.

Parameters

NameTypeNotes
self*(Self)

Returns: Self

Implementors

Isolation trait
Isolation

Isolation trait — runtime check whether a value can be safely transferred.

Methods

can_isolate : fn(self : Self) -> bool

Parameters

NameTypeNotes
selfSelf

Returns: bool

Implementors

Box
Iterator trait
Iterator

Iterator trait — lazy, pull-based sequence traversal.

Associated Types

NameConstraintDescription
ItemType

The type of elements yielded by this iterator.

Methods

next : fn(self : *(Self)) -> Option(Item)

Advance the iterator and return the next value, or None when exhausted.

Parameters

NameTypeNotes
self*(Self)

Returns: Option(Item)

Implementors

IntoIterator trait
IntoIterator

IntoIterator trait — convert a collection into an iterator.

Associated Types

NameConstraintDescription
ItemType

The type of elements yielded by this iterator.

IntoIterType

Methods

into_iter : fn(self : Self) -> IntoIter(Iterator)

Parameters

NameTypeNotes
selfSelf

Returns: IntoIter(Iterator)

TryFrom trait-function
fn(comptime(From) : Type) -> (comptime(fn_return_yocd6da6f3_id_24679) : Type(1))

TryFrom trait — fallible conversion from one type to another.

Type Parameters

NameTypeNotes
FromTypecomptime
TryInto trait-function
fn(comptime(To) : Type) -> (comptime(fn_return_yocd6da6f3_id_24747) : Type(1))

TryInto trait — fallible conversion of Self into another type.

Type Parameters

NameTypeNotes
ToTypecomptime
IO module
IO

IO module — the async runtime effect.

Provides io.async, io.await, io.spawn, and io.state operations. Automatically injected into main when declared with using(io : IO).

Methods

async : fn(forall(comptime(T) : Type, comptime(E) : Type(1)), action : Impl(Fn(using(...(E))) -> T)) -> Impl(Future(T, ...(E)))

Create a new Future from an async closure.

Parameters

NameTypeNotes
actionImpl(Fn(using(...(E))) -> T)

Returns: Impl(Future(T, ...(E)))

await : fn(forall(comptime(T) : Type, comptime(E) : Type(1)), fut : Impl(Future(T, ...(E))), using(...(E))) -> T

Await a Future, suspending until its result is ready.

Parameters

NameTypeNotes
futImpl(Future(T, ...(E)))

Returns: T

state : fn(forall(comptime(T) : Type, comptime(E) : Type(1)), fut : Impl(Future(T, ...(E)))) -> FutureState

Inspect the current state of a Future without blocking.

Parameters

NameTypeNotes
futImpl(Future(T, ...(E)))

Returns: FutureState

spawn : fn(forall(comptime(T) : Type, comptime(E) : Type(1)), fut : Impl(Future(T, ...(E))), using(...(E))) -> JoinHandle(T)

Spawn a Future as an independent task, returning a JoinHandle.

Parameters

NameTypeNotes
futImpl(Future(T, ...(E)))

Returns: JoinHandle(T)

Functions

assert function
fn(flag : bool, (msg : str) ?= "Assertion failed.") -> unit

Parameters

NameTypeNotes
flagbool
msgstrdefault: [object Object]

Returns: unit

box function
fn(forall(comptime(V) : Type), value : V) -> Box(V)

Allocate a value on the heap, returning a Box(V).

Type Parameters

NameTypeNotes
VTypecomptime

Parameters

NameTypeNotes
valueV

Returns: Box(V)

^ function
fn(quote(v) : Expr) -> (unquote(fn_return_yocd6da6f3_id_24052) : Expr)

Parameters

NameTypeNotes
vExprcomptime

Returns: Expr

arc function
fn(forall(comptime(V) : Type), value : V) -> Arc(V)

Allocate a value inside an Arc, returning an Arc(V).

Type Parameters

NameTypeNotes
VTypecomptime

Parameters

NameTypeNotes
valueV

Returns: Arc(V)

if function
fn(quote(condition) : Expr, quote(then) : Expr, (quote(else) : Expr) ?= quote(())) -> (unquote(fn_return_yocd6da6f3_id_24815) : Expr)

if macro — expands to cond(condition => then, true => else).

Example

if(x > 0, println("positive"), println("non-positive"));

Parameters

NameTypeNotes
conditionExprcomptime
thenExprcomptime
elseExprcomptime, default: [object Object]

Returns: Expr

try function
fn(quote(expr_to_try) : Expr) -> (unquote(fn_return_yocd6da6f3_id_24818) : Expr)

try macro — unwrap a Result, returning early on Err.

Example

value := try(might_fail());

Parameters

NameTypeNotes
expr_to_tryExprcomptime

Returns: Expr

for function
fn(quote(iter) : Expr, quote(handle) : Expr) -> (unquote(fn_return_yocd6da6f3_id_24822) : Expr)

for macro — iterate over a collection using the Iterator trait.

Example

for arr.iter(), (value) => {
  printf("value %d\n", value.*);
};

Parameters

NameTypeNotes
iterExprcomptime
handleExprcomptime

Returns: Expr

Constants

unsafe constant unsafe

The unsafe module — provides low-level escape hatches.

Value: unsafe(drop: <fn drop>, cast: __yo_as)

not constant !

Value: !(Call: (<fn not>, <fn comptime_not>))

! constant !

Value: !(Call: (<fn not>, <fn comptime_not>))

~ constant ~

Value: ~(Call: (<fn bit_not>, <fn comptime_bit_not>))

- constant -

Value: -(Call: (<fn neg>, <fn comptime_neg>))

Var constant Var

Var — compile-time variable introspection utilities.

Provides macros for querying metadata about a variable at compile-time, such as ownership status and alias information.

Value: Var(print_info: <fn print_info>, is_owning_the_rc_value: <fn is_owning_the_rc_value>, has_other_aliases: <fn has_other_aliases>)