green(reify): RecvResult/TryResult channel result types over reify

REIFY Phase 3.1. Add RecvResult($T) and TryResult($T) to meta.sx as
type-fns over reify (value-or-closed; value-or-empty-or-closed). They
need NO new compiler machinery — reify-of-a-literal in a type-fn body is
exactly the Phase 1 path — so the channel result types are pure sx
library code. examples/0617 green (both construct + match, incl.
payload-less .closed / .empty). Suite green (673 examples, 447 unit).

make_enum(variants) (3.2) and type_info (2.2) remain — both blocked on a
generalized reify reader (reifyType currently AST-walks a literal
TypeInfo). Plan/checkpoint updated.
This commit is contained in:
agra
2026-06-16 19:15:26 +03:00
parent 6627f7348b
commit 9306ad570d
6 changed files with 71 additions and 4 deletions

View File

@@ -36,3 +36,29 @@ TypeInfo :: enum {
reify :: (info: TypeInfo) -> Type #builtin;
type_info :: ($T: Type) -> TypeInfo #builtin;
field_type :: ($T: Type, idx: i64) -> Type #builtin;
// --- Reify'd shapes built in sx library code (no new compiler machinery) ---
//
// The channel result types, expressed as type-fns over `reify`. They are the
// canonical demonstration that `reify` carries a full enum through codegen:
// `RecvResult(i64)` constructs and matches like any hand-written enum, and is
// one nominal type across sites (the type-fn mangled-name identity path). The
// channel library (N3) consumes these once it lands.
// A blocking recv: a value, or the channel was closed (drained).
RecvResult :: ($T: Type) -> Type {
return reify(.enum(.{ variants = .[
EnumVariant.{ name = "value", payload = T },
EnumVariant.{ name = "closed", payload = void },
] }));
}
// A non-blocking try-recv: a value, currently empty, or closed — three states
// a bool can't express.
TryResult :: ($T: Type) -> Type {
return reify(.enum(.{ variants = .[
EnumVariant.{ name = "value", payload = T },
EnumVariant.{ name = "empty", payload = void },
EnumVariant.{ name = "closed", payload = void },
] }));
}