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

Pragma enum
Pragma

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

VariantFieldsDescription
AllowUnsafe

File is permitted to use raw pointer ops, unsafe(...), asm(...), and extern(...). Without this, those constructs produce compile errors.

SkipPrelude

Disable the auto-import of std/prelude. Used by the prelude itself, and by any tool/test that wants to bootstrap manually. Recognized at the AST level before the prelude loads.

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.

Verify

Formal verification: contracts in this file are proof obligations. Phase 0 only registers the pragma; later phases will hook in verification. See plans/FORMAL_VERIFICATION.md.

VerifyOrAssert

Formal verification: try to prove, fall back to runtime assert when proof times out. The production mode for verified code.

NoContracts

Formal verification: erase contract clauses entirely (no proof, no runtime assert). For release/benchmark builds.

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

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

Type Parameters

NameTypeNotes
TTypecomptime
RangeInclusive type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_856) : Type)

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

Type Parameters

NameTypeNotes
TTypecomptime
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_str type-alias
comptime_str

Trait Implementations

bool type-alias
bool

Trait Implementations

RawSlice type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_18812) : Type)

RawSlice — a plain ptr+len pair for PRIVILEGED (pragma'd) code: C interop and std internals. Carries a raw pointer, so the existing raw-pointer gates apply: safe code cannot name or construct it. Replaces the builtin Slice(T) for internal plumbing (plans/SLICE_REWORK.md step 4).

Type Parameters

NameTypeNotes
TTypecomptime
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_str

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_19811) : 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_str

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_str

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_str

Variant name.

param_typeType

Parameter type.

Trait Implementations

impl(ForallParamInfo, Comptime())
ImplicitParamInfo

ImplicitParamInfo — metadata for a using/effect parameter.

Fields

NameTypeDescription
namecomptime_str

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_str

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
Str

str — static string view (fieldless)

Arrayelement: Type, length: comptime_int
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)
Traitfields: ComptimeList(TraitFieldInfo), kind: TraitKind
Typelevel: comptime_int
Somename: comptime_str, required_traits: ComptimeList(TraitInfo), negative_traits: ComptimeList(TraitInfo), resolved_type: Type
ComptimeInt
ComptimeFloat
ComptimeStr
ComptimeListelement: Type
Expr
EffectsRow
TypeApplication

Trait Implementations

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_str : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_19956) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

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

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

is_comptime : (TypeInfo) fn(comptime(self) : TypeInfo) -> (comptime(fn_return_yocd6da6f3_id_19980) : 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_19983) : bool)

Parameters

NameTypeNotes
selfTypeInfocomptime

Returns: bool

FieldInfo struct
FieldInfo

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

Fields

NameTypeDescription
namecomptime_str

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_20114) : 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_20225) : 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))

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(...))
clone : ( (self) -> match( self, .None => Option(T).None, .Some(v) => Option(T).Some(v.clone()) ) )
impl(forall(T : Type), where(T <: Eq(T)), Option(T), Eq(Option(T)))
? type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_20225) : Type)

Type Parameters

NameTypeNotes
TTypecomptime
?* type-function
fn(comptime(T) : Type) -> (comptime(fn_return_yocd6da6f3_id_21011) : 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_21065) : Expr)

Parameters

NameTypeNotes
selfDeriveContextcomptime
trait_bodyExprcomptime

Returns: Expr

Result type-function
fn(comptime(OkType) : Type, comptime(ErrorType) : Type) -> (comptime(fn_return_yocd6da6f3_id_23197) : 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))

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(...))
clone : ( (self) -> match( self, .Ok(v) => Result(T, E).Ok(v.clone()), .Err(e) => Result(T, E).Err(e.clone()) ) )
impl(forall(T : Type, E : Type), where(T <: Eq(T), E <: Eq(E)), Result(T, E), Eq(Result(T, E)))
Box type-function
fn(comptime(V) : Type) -> (comptime(fn_return_yocd6da6f3_id_24685) : 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)))
impl(forall(T : Type), where(T <: Clone), Box(T), Clone(...))
clone : ((self) -> box(self.*.clone()))
Arc type-function
fn(comptime(V) : Type) -> (comptime(fn_return_yocd6da6f3_id_25025) : 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_25216) : 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(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

IterPair type-function
fn(comptime(A) : Type, comptime(B) : Type) -> (comptime(fn_return_yocd6da6f3_id_25703) : Type)

IterPair — a two-element product type used by enumerate and zip.

Type Parameters

NameTypeNotes
ATypecomptime
BTypecomptime
IterMap type-function
fn(comptime(I) : Type, comptime(B) : Type, comptime(F) : Type) -> (comptime(fn_return_yocd6da6f3_id_25768) : Type)

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

NameTypeNotes
ITypecomptime
BTypecomptime
FTypecomptime

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 : B
next : (fn(ref(self) : Self) -> Option(B))

Returns: Option(B)

IterFilter type-function
fn(comptime(I) : Type, comptime(F) : Type) -> (comptime(fn_return_yocd6da6f3_id_25902) : Type)

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

NameTypeNotes
ITypecomptime
FTypecomptime

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 : A
next : (fn(ref(self) : Self) -> Option(A))

Returns: Option(A)

IterTake type-function
fn(comptime(I) : Type) -> (comptime(fn_return_yocd6da6f3_id_26012) : Type)

Lazy iterator that yields at most n elements from the source.

Created by calling .take(n) on any iterator.

Type Parameters

NameTypeNotes
ITypecomptime

Trait Implementations

impl(forall(I : Type, A : Type), where(I <: Iterator(Item := A)), IterTake(I), Iterator(...))
Item : A
next : (fn(ref(self) : Self) -> Option(A))

Returns: Option(A)

IterSkip type-function
fn(comptime(I) : Type) -> (comptime(fn_return_yocd6da6f3_id_26111) : Type)

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

NameTypeNotes
ITypecomptime

Trait Implementations

impl(forall(I : Type, A : Type), where(I <: Iterator(Item := A)), IterSkip(I), Iterator(...))
Item : A
next : (fn(ref(self) : Self) -> Option(A))

Returns: Option(A)

IterEnumerate type-function
fn(comptime(I) : Type) -> (comptime(fn_return_yocd6da6f3_id_26210) : Type)

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

NameTypeNotes
ITypecomptime

Trait Implementations

impl(forall(I : Type, A : Type), where(I <: Iterator(Item := A)), IterEnumerate(I), Iterator(...))
Item : IterPair(usize, A)
next : (fn(ref(self) : Self) -> Option(IterPair(usize, A)))

Returns: Option(IterPair(usize, A))

IterZip type-function
fn(comptime(I) : Type, comptime(J) : Type) -> (comptime(fn_return_yocd6da6f3_id_26347) : Type)

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

NameTypeNotes
ITypecomptime
JTypecomptime

Trait Implementations

impl(forall(I : Type, J : Type, A : Type, B : Type), where(I <: Iterator(Item := A), J <: Iterator(Item := B)), IterZip(I, J), Iterator(...))
Item : IterPair(A, B)
next : (fn(ref(self) : Self) -> Option(IterPair(A, B)))

Returns: Option(IterPair(A, B))

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 unwind).

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_27782) : 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

Io struct
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 io : Io.

Fields

NameTypeDescription
async(Io) fn(forall(comptime(T) : Type, comptime(E) : Type), action : Impl(Fn(e : E) -> T)) -> Impl(Future(T, E))

Create a new Future from an async closure.

await(Io) fn(forall(comptime(T) : Type, comptime(E) : Type), fut : Impl(Future(T, E)), e : E) -> T

Await a Future, suspending until its result is ready.

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

Inspect the current state of a Future without blocking.

spawn(Io) fn(forall(comptime(T) : Type, comptime(E) : Type), fut : Impl(Future(T, E)), e : E) -> JoinHandle(T)

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

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_str. 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_str, Type (compile-time-only types).

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_731) : 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_777) : 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_1142) : Range(Self))

Parameters

NameTypeNotes
startSelfcomptime
endSelfcomptime

Returns: Range(Self)

Implementors

ComptimeRangeInclusiveOp

Methods

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

Parameters

NameTypeNotes
startSelfcomptime
endSelfcomptime

Returns: RangeInclusive(Self)

Implementors

Add trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1193) : 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_1239) : Type(1))

Compile-time variant of Add.

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Sub trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1285) : 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_1331) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Mul trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1377) : 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_1423) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Div trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1469) : 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_1515) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Mod trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1561) : 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_1607) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitLeftShift trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1653) : 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_1699) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitRightShift trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1745) : 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_1791) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

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

Exponentiation trait — enables lhs ** rhs operator.

Type Parameters

NameTypeNotes
RhsTypecomptime
ComptimeExponentiation trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_1883) : 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_1965) : 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_1987) : 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_2041) : Output(Comptime))

Parameters

NameTypeNotes
selfSelfcomptime

Returns: Output(Comptime)

Implementors

BitAnd trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2059) : 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_2105) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitOr trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2151) : 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_2197) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

BitXor trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2243) : 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_2289) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Eq trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2473) : 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_2506) : Type(1))

Type Parameters

NameTypeNotes
RhsTypecomptime

Implementors

Ord trait-function
fn(comptime(Rhs) : Type) -> (comptime(fn_return_yocd6da6f3_id_2559) : 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
selfSelf

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
selfSelf

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
selfSelf

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_25518) : 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_25586) : Type(1))

TryInto trait — fallible conversion of Self into another type.

Type Parameters

NameTypeNotes
ToTypecomptime

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_25004) : 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_25654) : 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_25657) : 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(coll) : Expr, quote(handle) : Expr) -> (unquote(fn_return_yocd6da6f3_id_25661) : Expr)

for macro — iterate over a collection.

for(coll, (x) => body) — calls coll.into_iter() and binds x to each yielded value. The collection is moved into the iterator; object elements are handles, so mutating x in the body mutates the element in place.

The old borrow form for(coll, ref(x) => body) was REMOVED: it required refs into reallocatable storage, which is no longer expressible. Object elements mutate in place through the value handle; struct elements use an index loop with get/set.

Combinator chains (coll.into_iter().map(f), etc.) work transparently: a blanket into_iter impl on Iterator (below) makes every iterator its own IntoIterator.

Examples

// Object elements — mutate in place through the handle.
for(names, (s) => {
  s.push_str("!");
});

// Consume an iterator chain.
for(list.into_iter(), (x) => print(x));

Parameters

NameTypeNotes
collExprcomptime
handleExprcomptime

Returns: Expr

Constants

unsafe constant unsafe

The unsafe module — provides low-level unwind 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>)