@shd101wyy/yo 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/skills/yo-async-effects/async-effects-recipes.md +6 -6
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +4 -0
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +5 -0
- package/out/cjs/index.cjs +545 -547
- package/out/cjs/yo-cli.cjs +605 -606
- package/out/cjs/yo-lsp.cjs +552 -554
- package/out/esm/index.mjs +503 -505
- package/out/types/src/codegen/codegen-c.d.ts +2 -2
- package/out/types/src/codegen/functions/collection.d.ts +2 -2
- package/out/types/src/codegen/functions/context.d.ts +3 -2
- package/out/types/src/codegen/types/collection.d.ts +2 -2
- package/out/types/src/codegen/utils/index.d.ts +3 -1
- package/out/types/src/doc/builder.d.ts +2 -2
- package/out/types/src/evaluator/calls/closure-type.d.ts +2 -2
- package/out/types/src/evaluator/calls/record-type.d.ts +11 -0
- package/out/types/src/evaluator/context.d.ts +8 -9
- package/out/types/src/evaluator/index.d.ts +3 -3
- package/out/types/src/evaluator/types/record.d.ts +14 -0
- package/out/types/src/evaluator/types/validation.d.ts +2 -2
- package/out/types/src/evaluator/values/anonymous-module.d.ts +5 -5
- package/out/types/src/evaluator/values/impl.d.ts +1 -1
- package/out/types/src/expr.d.ts +1 -4
- package/out/types/src/function-value.d.ts +1 -1
- package/out/types/src/lsp/document-manager.d.ts +1 -1
- package/out/types/src/module-manager.d.ts +3 -3
- package/out/types/src/types/creators.d.ts +3 -4
- package/out/types/src/types/definitions.d.ts +8 -19
- package/out/types/src/types/guards.d.ts +3 -3
- package/out/types/src/types/tags.d.ts +0 -1
- package/out/types/src/types/utils.d.ts +1 -1
- package/out/types/src/value-tag.d.ts +0 -1
- package/out/types/src/value.d.ts +6 -13
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/error.yo +6 -6
- package/std/prelude.yo +1 -7
- package/out/types/src/evaluator/calls/module-type.d.ts +0 -11
- package/out/types/src/evaluator/types/module.d.ts +0 -19
|
@@ -186,7 +186,7 @@ process_dir :: (fn(root: Path, using(io: IO, exn: Exception)) -> Impl(Future(uni
|
|
|
186
186
|
|
|
187
187
|
## Exception (non-resumable)
|
|
188
188
|
|
|
189
|
-
`Exception` is a built-in
|
|
189
|
+
`Exception` is a built-in struct-record effect for non-resumable error handling. When the handler calls `escape`, the continuation is discarded:
|
|
190
190
|
|
|
191
191
|
```rust
|
|
192
192
|
open import "std/error";
|
|
@@ -251,7 +251,7 @@ Key: the `return` inside the handler resumes the _effect invocation site_ with t
|
|
|
251
251
|
|
|
252
252
|
**`escape T_value` constraint**: `escape T_value` inside an `Exception` handler requires that the enclosing `io.async` closure's return type matches `T_value`. Due to forward type inference, the evaluator may not know the closure's return type at the point where `given` is declared. This causes a "Expected: unit" error when `escape non_unit` is used in a handler declared before the final return expression. Prefer `return fallback_value` (resume) when possible.
|
|
253
253
|
|
|
254
|
-
`ResumableException(ResumeType)` is a
|
|
254
|
+
`ResumableException(ResumeType)` is a struct-record effect for resumable error handling. The handler uses `return` to resume with a recovery value:
|
|
255
255
|
|
|
256
256
|
```rust
|
|
257
257
|
open import "std/error";
|
|
@@ -282,19 +282,19 @@ export main;
|
|
|
282
282
|
- Handler uses `return value` to resume the continuation with the recovery value
|
|
283
283
|
- The call site receives the returned value and continues normally
|
|
284
284
|
|
|
285
|
-
##
|
|
285
|
+
## Struct-record effects vs function-type effects
|
|
286
286
|
|
|
287
|
-
Effects in Yo can be plain function types or
|
|
287
|
+
Effects in Yo can be plain function types or struct-record types:
|
|
288
288
|
|
|
289
289
|
```rust
|
|
290
290
|
Raise :: (fn(msg : String) -> i32);
|
|
291
291
|
|
|
292
|
-
Logger ::
|
|
292
|
+
Logger :: struct(
|
|
293
293
|
log : (fn(level : i32, msg : String) -> unit)
|
|
294
294
|
);
|
|
295
295
|
```
|
|
296
296
|
|
|
297
|
-
Both kinds use `using(...)` / `given(...)` with the same semantics — they compile to evidence passing (function pointers as implicit C parameters).
|
|
297
|
+
Both kinds use `using(...)` / `given(...)` with the same semantics — they compile to evidence passing (function pointers as implicit C parameters). Struct-record effects group related operations under a single nominal type.
|
|
298
298
|
|
|
299
299
|
## Async with effects
|
|
300
300
|
|
|
@@ -190,6 +190,10 @@ TcpStream :: object(fd : i32, buffer : ArrayList(u8));
|
|
|
190
190
|
|
|
191
191
|
- Use `newtype(...)` when the type has exactly one field
|
|
192
192
|
- Use `object(...)` for types that need shared ownership
|
|
193
|
+
- Source-file imports are namespace structs. The old `module(...)`, `Module`,
|
|
194
|
+
and `SelfModule` syntax is gone; use `struct(...)`, `Type`, and normal `Self`.
|
|
195
|
+
- Fields written as `name :: value` or `comptime(name) : Type` are compile-time-only static fields/methods and have no runtime layout
|
|
196
|
+
- A normal field with a compile-time-only type, such as `x : comptime_int`, is still a data field and makes the struct comptime-only
|
|
193
197
|
|
|
194
198
|
## Impl blocks and generics
|
|
195
199
|
|
|
@@ -129,6 +129,11 @@ impl(Counter,
|
|
|
129
129
|
- No space between a function type and its body: `(fn(...) -> T)(...)`
|
|
130
130
|
- Use `Self` in method signatures and in type definitions for recursive references (the type name is not available during its own definition)
|
|
131
131
|
- `Self` also works inside generic type constructors — it refers to the current instantiation (e.g., `Tree(T)` inside `Tree`). Use `recur(args)` only when type arguments differ from the current instantiation.
|
|
132
|
+
- Use `struct(...)` for record and effect-record types. The legacy `module(...)`,
|
|
133
|
+
`Module`, and `SelfModule` syntax has been removed; imported files are
|
|
134
|
+
represented as namespace structs, and recursive references use normal `Self`.
|
|
135
|
+
- Bare `Module` is not a type alias. Use `Type` for comptime type values; type
|
|
136
|
+
reflection reports source-module namespaces as `TypeInfo.Struct(...)`.
|
|
132
137
|
- Wrap `fn` types in parentheses when they appear after `:`
|
|
133
138
|
- **Forward references between methods in the same `impl` block are supported.** A method defined later in the block can be called by a method defined earlier. Both `self.method()` and `Self.method(...)` dispatch work. Only the canonical `name : (fn(...) -> R)(body)` method shape participates; bare lambdas do not get forward-ref shells.
|
|
134
139
|
- **Module-level `::` function definitions are processed in order.** A function body that calls another function declared later in the same file will fail with "Variable not found". Always define leaf helpers first (bottom-up order): `eval_identifier` → `eval_atom` → `evaluate`.
|