@calcit/procs 0.13.35 → 0.13.37

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.
Binary file
@@ -0,0 +1,72 @@
1
+ # Option / Result 顺序绑定宏 RFC
2
+
3
+ 状态:Experimental
4
+ 日期:2026-08-23
5
+
6
+ ## 目标
7
+
8
+ 在不增加 parser syntax、提前返回控制流或隐式 unwrap 的前提下,简化连续的
9
+ `Option` / `Result` 计算。实验能力完全由 core macro 提供,并展开为已有的
10
+ `.and-then` 方法调用。
11
+
12
+ 本 RFC 不继续推进 labelled arguments。label 会同时进入参数声明、函数类型、
13
+ 调用绑定、偏函数与各 codegen 后端,现阶段复杂度高于收益。
14
+
15
+ ## API
16
+
17
+ ```cirru.no-check
18
+ option:let
19
+ user $ get users user-id
20
+ profile $ get user :profile
21
+ %some $ render profile
22
+
23
+ result:let
24
+ content $ read-file path
25
+ data $ parse-data content
26
+ save-data data
27
+ ```
28
+
29
+ 两个宏沿用现有 `let` 的 binding pair 结构。每个右侧表达式必须返回对应容器,
30
+ body 也必须显式返回对应容器;宏不会自动添加 `%some` / `%ok`。
31
+
32
+ `result:let` 展开为:
33
+
34
+ ```cirru.no-check
35
+ (read-file path) .and-then $ fn (content)
36
+ (parse-data content) .and-then $ fn (data)
37
+ save-data data
38
+ ```
39
+
40
+ `option:let` 同样展开为嵌套的 `.and-then`。因此每个表达式只求值一次,
41
+ `:none` / `:err` 由现有方法原样短路传播,错误类型不同仍需显式 `.map-err`。
42
+
43
+ ## 方法优先的公开边界
44
+
45
+ 普通函数能力优先通过 Option / Result 的 method bag 暴露。用户代码应写
46
+ `.map`、`.and-then`、`.or-else`、`.map-err` 和 `.unwrap-or`,命名空间函数
47
+ `option:*` / `result:*` 保留为 core lowering 与动态边界。
48
+
49
+ `option:let` / `result:let` 自身是控制代码展开的宏,不能通过运行时 method
50
+ dispatch 调用,因此保留命名空间形式;它们生成的组合代码仍使用 `.and-then`。
51
+ 后续若增加 `fold`、lazy fallback、`flatten` 等普通函数,必须同步注册到对应
52
+ method bag,并以接收者方法作为文档主用法。
53
+
54
+ ## 诊断与边界
55
+
56
+ - bindings 必须是由二元 pair 组成的 list;左侧必须是 symbol;
57
+ - body 至少包含一个表达式;
58
+ - 不提供 Rust `?` 式外围函数 early return;macro 只控制自己包裹的 continuation;
59
+ - 不在 Option 与 Result 之间隐式转换;
60
+ - 不接受 nil / JsNullish 作为容器替代;
61
+ - macro schema 本身保持 Dynamic AST 边界,展开结果继续接受普通方法 schema 检查。
62
+
63
+ ## 验收
64
+
65
+ 1. 多个 `:some` / `:ok` 绑定按顺序进入 body;
66
+ 2. `:none` / `:err` 在后续表达式执行前短路;
67
+ 3. body 返回裸值、容器混用和 Result 错误类型不一致时产生类型诊断;
68
+ 4. macro expansion 只包含现有 `fn`、`do` 和 `.and-then` 调用;
69
+ 5. Native 与 JS 构建和现有 core 测试全部通过。
70
+
71
+ 实验阶段先在真实 Calcit 项目替换少量嵌套 `.and-then`。只有在类型诊断、错误位置
72
+ 和生成代码都稳定后再移除 `:experimental`,不为缩短字符数增加新 parser syntax。
@@ -0,0 +1,5 @@
1
+ # Callable schema wrapper 兼容修复
2
+
3
+ - 跟进 PR #391 的异步审查,允许零 payload 的 `:: 'Fn` / `:: 'Macro` 进入 canonical symbol parser。
4
+ - `Fn` 稳定往返为动态函数 schema;无签名信息的 `Macro` 也解析为动态函数并 canonicalize 为 `Fn`。
5
+ - 仅继续拒绝必须携带内部类型的 `Optional`、`JsNullish`、`Variadic` 零 payload 包装。
@@ -0,0 +1,5 @@
1
+ # 发布 0.13.36
2
+
3
+ - 跟进 Snapshot schema 往返审查,补齐零 payload `Fn` / `Macro` wrapper 的兼容解析。
4
+ - 保留 0.13.35 的 `StructDef` / `EnumDef` 往返修复及完整回归覆盖。
5
+ - 发布前已通过 Clippy、targeted tests 与 `yarn check-all`。
@@ -0,0 +1,9 @@
1
+ # Option / Result 顺序绑定宏
2
+
3
+ - 放弃 labelled arguments 方向,避免参数声明、函数类型、偏函数和 codegen 同时增加语法与绑定规则。
4
+ - 在 core 中实验性增加 `option:let` / `result:let`,复用普通 `let` binding pair,并完全展开为接收者 `.and-then` 调用。
5
+ - 宏不自动添加 `%some` / `%ok`,不提供外围函数 early return,也不在 Option、Result、nil 与 JsNullish 之间隐式转换。
6
+ - 方法调用预处理现在会先用 receiver 绑定泛型,再把专门化后的 Fn 参数契约注入匿名 callback;callback 的返回类型因此能检查容器外层和 Result 错误类型。
7
+ - 泛型函数返回检查不再因包含 type variable 而整体跳过,而是允许绑定 payload,同时继续验证 `Option` / `Result` 等外层结构。
8
+ - 普通 Option/Result 能力保持 method-first:公开代码优先 `.map`、`.and-then`、`.or-else`、`.map-err`、`.unwrap-or`;命名空间函数主要服务 core lowering。
9
+ - type-fail Snapshot 恢复普通文本 diff,不再通过目录级 `.gitattributes` 隐藏 Calcit 源码。
@@ -0,0 +1,4 @@
1
+ # PR #393 review follow-up
2
+
3
+ - `expected_method_argument_types` 现在要求 receiver 与方法签名的 receiver 类型成功匹配后才注入 callback 契约。
4
+ - receiver 绑定失败时直接回退,不使用空的或部分泛型 bindings 生成错误的 `EXPECTED_FN_TYPE`。
@@ -0,0 +1,5 @@
1
+ # Release 0.13.37
2
+
3
+ - 发布实验性 `option:let` / `result:let` 顺序绑定宏,保持展开到接收者 `.and-then` 的 method-first 公开风格。
4
+ - 发布方法 callback 泛型专门化与容器返回类型检查修复,阻断裸 payload、Option/Result 混用和已知错误类型不一致。
5
+ - 版本同步更新 Cargo 与 npm 包,并按发布流程更新 lockfile、提交 main、创建 `0.13.37` tag 和 GitHub Release。
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.13.35",
3
+ "version": "0.13.37",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.13.35",
3
+ "version": "0.13.37",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",