Module 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
File-level privilege flag for the pragma(...) builtin. Declared
at the top of a Yo file (e.g. pragma(Pragma.AllowUnsafe);) to
opt the file into compiler-recognized behaviors. See
plans/MEMORY_SAFETY.md.
Variants
| Variant | Fields | Description |
|---|---|---|
AllowUnsafe | File is permitted to use raw pointer ops, | |
SkipPrelude | Disable the auto-import of | |
SkipWasm | Test-runner directive: skip this test file on ALL WASM targets. | |
SkipWasm32Emscripten | Test-runner directive: skip when target is wasm32-emscripten. | |
SkipWasm32Wasi | Test-runner directive: skip when target is wasm32-wasi. |
Half-open range start..end (excludes end).
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
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())
Inclusive range start..=end (includes end).
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
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 — result of a comparison.
Variants
| Variant | Fields | Description |
|---|---|---|
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. |
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
Trait Implementations
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
| Name | Type | Description |
|---|---|---|
bytes | [u8] | The underlying byte slice. |
Trait Implementations
impl(str, ...)
from_raw_parts : (str) fn(ptr : *(u8), length : usize) -> strConstruct a str from a raw pointer and length.
Parameters
| Name | Type | Notes |
|---|---|---|
ptr | *(u8) | |
length | usize |
Returns: str
len : (str) fn(self : str) -> usizeReturn the length in bytes.
Parameters
| Name | Type | Notes |
|---|---|---|
self | str |
Returns: usize
ptr : (str) fn(self : str) -> *(u8)Parameters
| Name | Type | Notes |
|---|---|---|
self | str |
Returns: *(u8)
impl(str, Eq(str)(...))
impl(str, Ord(str)(...))
ExprList
Type reflection metadata structs — used by Type.get_info().
StructKind — discriminant for struct flavors.
Variants
| Variant | Fields | Description |
|---|---|---|
Struct | Regular value struct. | |
Object | Reference-counted object. | |
AtomicObject | Atomic reference-counted object. | |
NewType | Single-field newtype wrapper. |
Trait Implementations
impl(StructKind, Comptime())
TypeFieldInfo — metadata for a single struct/object field.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_string | Variant name. |
field_type | Type | Field type. |
Trait Implementations
impl(TypeFieldInfo, Comptime())
impl(TypeFieldInfo, ...)
to_expr : (TypeFieldInfo) fn(comptime(self) : TypeFieldInfo) -> (comptime(fn_return_yocd6da6f3_id_20637) : Expr)Convert the field name to a quoted expression.
Parameters
| Name | Type | Notes |
|---|---|---|
self | TypeFieldInfo | comptime |
Returns: Expr
ParamInfo — metadata for a function parameter.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_string | Variant name. |
param_type | Type | Parameter type. |
is_comptime | bool |
|
is_quote | bool |
|
is_variadic | bool |
|
Trait Implementations
impl(ParamInfo, Comptime())
FunctionInfo — metadata for a function type.
Fields
| Name | Type | Description |
|---|---|---|
params | ComptimeList(ParamInfo) | Regular parameters. |
return_type | Type | Return type. |
forall_params | ComptimeList(ForallParamInfo) | Optional forall parameters for generic types. |
implicit_params | ComptimeList(ImplicitParamInfo) | Implicit |
is_closure | bool |
|
Trait Implementations
impl(FunctionInfo, Comptime())
TraitKind — discriminant for different trait flavors.
Variants
| Variant | Fields | Description |
|---|---|---|
Future | child: Type, effects: ComptimeList(TraitInfo) | A Future trait with child type and effects. |
Fn | call: FunctionInfo | A callable |
Normal | A normal user-defined trait. |
Trait Implementations
impl(TraitKind, Comptime())
VariantInfo — metadata for an enum variant.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_string | Variant name. |
fields | ComptimeList(TypeFieldInfo) | Variant fields (may be empty for unit variants). |
_enum_type | Type | |
_variant_index | usize |
Trait Implementations
impl(VariantInfo, Comptime())
TypeInfo — compile-time enum representing rich type metadata.
Returned by Type.get_info() for compile-time type reflection.
Variants
| Variant | Fields | Description |
|---|---|---|
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 | ||
Array | element: Type, length: comptime_int | |
Slice | element: Type | |
Tuple | fields: ComptimeList(TypeFieldInfo) | |
Struct | fields: ComptimeList(TypeFieldInfo), kind: StructKind | Regular value struct. |
Enum | variants: ComptimeList(VariantInfo) | |
Union | fields: ComptimeList(TypeFieldInfo) | |
Function | info: FunctionInfo | |
Ptr | pointee: Type | |
Iso | child: Type | |
Dyn | required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo) | |
Trait | fields: ComptimeList(TraitFieldInfo), kind: TraitKind | |
Type | level: comptime_int | |
Some | name: comptime_string, required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo), resolved_type: Type | |
ComptimeInt | ||
ComptimeFloat | ||
ComptimeString | ||
ComptimeList | element: Type | |
Expr | ||
EffectsRow | ||
TypeApplication |
Trait Implementations
impl(TypeInfo, Comptime())
impl(TypeInfo, ...)
is_struct : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20767) : bool)is_enum : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20770) : bool)is_union : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20773) : bool)is_tuple : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20776) : bool)is_array : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20779) : bool)is_slice : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20782) : bool)is_function : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20785) : bool)is_pointer : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20788) : bool)is_trait : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20791) : bool)is_void : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20794) : bool)is_primitive : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20797) : bool)is_integer : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20800) : bool)is_float : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20803) : bool)is_comptime : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20806) : bool)true if the parameter is compile-time (comptime).
Parameters
| Name | Type | Notes |
|---|---|---|
self | TypeInfo | comptime |
Returns: bool
is_numeric : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_20809) : bool)FieldInfo — compile-time struct field metadata for derive rules (legacy alias).
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_string | Variant name. |
field_type | Type | Field type. |
Trait Implementations
impl(FieldInfo, Comptime())
Option — a value that may or may not be present.
Option(T) has two variants:
.Some(value)— contains a value of typeT.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
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
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))Transform each element with f, producing an IterMap iterator.
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))Keep only elements for which pred returns true, producing an IterFilter iterator.
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)
impl(forall(T : Type), where(T <: Clone), Option(T), Clone(...))
impl(forall(T : Type), where(T <: Eq(T)), Option(T), Eq(Option(T)))
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
Type Parameters
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
DeriveContext — context passed to derive rule functions (needs Option).
Used by the derive macro to generate trait implementations.
Fields
| Name | Type | Description |
|---|---|---|
target | Expr | The AST expression for the target type. |
forall_params | Option(Expr) | Optional forall parameters for generic types. |
where_clause | Option(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_21891) : Expr)Result — a value that is either success (Ok) or failure (Err).
Result(OkType, ErrorType) has two variants:
.Ok(value)— contains a success value of typeOkType.Err(error)— contains an error value of typeErrorType
Example
(r : Result(i32, str)) = .Ok(i32(42));
assert(r.is_ok(), "expected Ok");
Type Parameters
| Name | Type | Notes |
|---|---|---|
OkType | Type | comptime |
ErrorType | Type | comptime |
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))Transform each element with f, producing an IterMap iterator.
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)
impl(forall(T : Type, E : Type), where(T <: Clone, E <: Clone), Result(T, E), Clone(...))
impl(forall(T : Type, E : Type), where(T <: Eq(T), E <: Eq(E)), Result(T, E), Eq(Result(T, E)))
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
| Name | Type | Notes |
|---|---|---|
V | Type | comptime |
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)))
impl(forall(T : Type), where(T <: Clone), Box(T), Clone(...))
clone : ((self) -> box(self.*.clone()))=== 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
| Name | Type | Notes |
|---|---|---|
V | Type | comptime |
Trait Implementations
impl(forall(T : Type), where(T <: (Send, Acyclic)), Arc(T), Send())
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
| Name | Type | Notes |
|---|---|---|
BaseType | Type | comptime |
impl(forall(BaseType : Type), MaybeUninit(BaseType), ...)
new : (fn() -> Self)Create a new uninitialized value.
Returns: Self
as_ptr : (fn(ref(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
Lazy iterator that maps each element through a function F.
Created by calling .map(f) on any iterator.
I is the source iterator type, B is the output element type,
F is the mapper closure type satisfying Fn(item : A) -> B.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
B | Type | comptime |
F | Type | comptime |
Trait Implementations
impl(forall(I : Type, A : Type, B : Type, F : Type), where(I <: Iterator(Item := A), F <: (Fn(item : A) -> B)), IterMap(I, B, F), Iterator(...))
Item : Bnext : (fn(ref(self) : Self) -> Option(B))Returns: Option(B)
Lazy iterator that skips elements for which the predicate returns false.
Created by calling .filter(pred) on any iterator.
I is the source iterator type, F is the predicate closure type
satisfying Fn(item : *(A)) -> bool.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
F | Type | comptime |
Trait Implementations
impl(forall(I : Type, A : Type, F : Type), where(I <: Iterator(Item := A), F <: (Fn(item : *(A)) -> bool)), IterFilter(I, F), Iterator(...))
Item : Anext : (fn(ref(self) : Self) -> Option(A))Returns: Option(A)
Lazy iterator that yields at most n elements from the source.
Created by calling .take(n) on any iterator.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
Trait Implementations
impl(forall(I : Type, A : Type), where(I <: Iterator(Item := A)), IterTake(I), Iterator(...))
Item : Anext : (fn(ref(self) : Self) -> Option(A))Returns: Option(A)
Lazy iterator that skips the first n elements of the source, then yields
all remaining elements.
Created by calling .skip(n) on any iterator.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
Trait Implementations
impl(forall(I : Type, A : Type), where(I <: Iterator(Item := A)), IterSkip(I), Iterator(...))
Item : Anext : (fn(ref(self) : Self) -> Option(A))Returns: Option(A)
Lazy iterator that pairs each element with its zero-based index.
Created by calling .enumerate() on any iterator.
Yields IterPair(usize, A) values where _0 is the index and _1 is
the original element.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
Trait Implementations
Lazy iterator that combines two iterators element-by-element into pairs. Stops as soon as either iterator is exhausted.
Created by calling .zip(other) on any iterator.
Yields IterPair(A, B) values.
Type Parameters
| Name | Type | Notes |
|---|---|---|
I | Type | comptime |
J | Type | comptime |
Trait Implementations
FutureState — the state of an async Future.
Variants
| Variant | Fields | Description |
|---|---|---|
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 |
Trait Implementations
impl(FutureState, Acyclic())
impl(FutureState, Runtime())
impl(FutureState, Send())
impl(FutureState, Eq(FutureState))
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
| Name | Type | Notes |
|---|---|---|
T | Type | comptime |
impl(forall(T : Type), JoinHandle(T), ...)
await : __yo_join_handle_awaitAwait a Future, suspending until its result is ready.
Returns: unknown
Io module — the async runtime effect.
Provides io.async, io.await, io.spawn, and io.state operations.
Automatically injected into main when declared with io : Io.
Fields
| Name | Type | Description |
|---|---|---|
async | (Io) fn(forall(comptime(T) : Type, comptime(E) : Type), action : Impl(Fn(e : E) -> T)) -> Impl(Future(T, E)) | Create a new |
await | (Io) fn(forall(comptime(T) : Type, comptime(E) : Type), fut : Impl(Future(T, E)), e : E) -> T | Await a |
state | (Io) fn(forall(comptime(T) : Type, comptime(E) : Type), fut : Impl(Future(T, E))) -> FutureState | Inspect the current state of a |
spawn | (Io) fn(forall(comptime(T) : Type, comptime(E) : Type), fut : Impl(Future(T, E)), e : E) -> JoinHandle(T) | Spawn a |
Traits / Modules
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 — 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
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
The Rc trait means the type is reference counted object type.
Dispose trait - defines a dispose method for cleaning up resources.
Methods
dispose : fn(self : Self) -> unitParameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: unit
Implementors
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
| Name | Type | Notes |
|---|---|---|
Idx | Type | comptime |
Implementors
Indexable trait — projection-style indexing yielding a borrow.
Companion to Index, but instead of returning a raw *(T) the
project method returns a ref(Element) — a second-class
reference that flows through Yo's flowability rule (R1–R4) and
can be received by a ref(name) := coll.project(pos); local
binding. The for-loop macro lowers iteration through this trait
so user code never sees a raw pointer. See
plans/ITERATOR_REDESIGN.md.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Idx | Type | comptime |
Implementors
ComptimeIndex — compile-time indexing trait for constant expressions.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Idx | Type | comptime |
Implementors
RangeInclusiveOp trait — enables start..=end operator syntax.
Methods
..= : fn(start : Self, end : Self) -> RangeInclusive(Self)Implementors
Methods
.. : fn(comptime(start) : Self, comptime(end) : Self) -> (comptime(fn_return_yocd6da6f3_id_1396) : Range(Self))Implementors
Methods
..= : fn(comptime(start) : Self, comptime(end) : Self) -> (comptime(fn_return_yocd6da6f3_id_1429) : RangeInclusive(Self))Implementors
Add trait — enables lhs + rhs operator. Parameterized by Rhs type.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
Exponentiation trait — enables lhs ** rhs operator.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Negate trait — enables unary -value operator.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
neg : fn(self : Self) -> OutputImplementors
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
neg : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2219) : Output(Comptime))Implementors
Methods
! : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2241) : bool)Parameters
| Name | Type | Notes |
|---|---|---|
self | Self | comptime |
Returns: bool
Implementors
BitNot trait — enables ~value bitwise complement.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
~ : fn(self : Self) -> OutputImplementors
Associated Types
| Name | Constraint | Description |
|---|---|---|
Output | Type | The output type of the addition. |
Methods
~ : fn(comptime(self) : Self) -> (comptime(fn_return_yocd6da6f3_id_2295) : Output(Comptime))Implementors
BitAnd trait — enables lhs & rhs bitwise AND.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
BitXor trait — enables lhs ^ rhs bitwise XOR.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
Eq trait — enables == and != comparison operators.
The != method has a default implementation that negates ==.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
Ord trait — enables <, <=, >, >= comparison operators.
Requires the type to also implement Eq.
Type Parameters
| Name | Type | Notes |
|---|---|---|
Rhs | Type | comptime |
Implementors
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:
- Deterministic: The same value always produces the same hash
- 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) -> u64Compute the hash of a value Returns a u64 hash value
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: u64
Implementors
Clone trait — deep-copy a value.
Methods
clone : fn(self : Self) -> SelfCreate an independent clone of self.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: Self
Implementors
Isolation trait — runtime check whether a value can be safely transferred.
Methods
can_isolate : fn(self : Self) -> boolParameters
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: bool
Implementors
Iterator trait — lazy, pull-based sequence traversal.
Associated Types
| Name | Constraint | Description |
|---|---|---|
Item | Type | 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
| Name | Type | Notes |
|---|---|---|
self | Self |
Returns: Option(Item)
Implementors
Functions
Parameters
| Name | Type | Notes |
|---|---|---|
flag | bool | |
msg | str | default: [object Object] |
Returns: unit
if macro — expands to cond(condition => then, true => else).
Example
if(x > 0, println("positive"), println("non-positive"));
Parameters
| Name | Type | Notes |
|---|---|---|
condition | Expr | comptime |
then | Expr | comptime |
else | Expr | comptime, default: [object Object] |
Returns: Expr
for macro — iterate over a collection. The lambda's binding shape
dictates whether the iteration borrows or consumes:
for(coll, ref(x) => body) — borrow form. Calls coll.iter()
(must yield positions) + coll.project(pos) for each. x is
ref-bound to the element; reads auto-deref, writes propagate
back to the collection; coll survives the loop.
for(coll, (x) => body) — value form. Calls coll.into_iter()
and binds x to each yielded value. The collection is moved
into the iterator and consumed.
Combinator chains (coll.iter().map(f), etc.) only support the
value form — they yield computed values, not borrows. A blanket
into_iter impl on Iterator (below) makes the value form work
transparently on iterator chains.
See plans/ITERATOR_REDESIGN.md.
Examples
// Borrow form — mutate elements in place.
for(arr, ref(x) => {
x = (x + i32(1));
});
// Value form — consume the collection.
for(list.into_iter(), (x) => print(x));
Parameters
| Name | Type | Notes |
|---|---|---|
coll | Expr | comptime |
handle | Expr | comptime |
Returns: Expr
Constants
The unsafe module — provides low-level unwind hatches.
Value: unsafe(drop: <fn drop>, cast: __yo_as)
Value: !(Call: (<fn not>, <fn comptime_not>))
Value: !(Call: (<fn not>, <fn comptime_not>))
Value: ~(Call: (<fn bit_not>, <fn comptime_bit_not>))
Value: -(Call: (<fn neg>, <fn comptime_neg>))
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>)