functionalscript 0.18.0 → 0.20.0

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.
Files changed (242) hide show
  1. package/fs/asn.1/module.f.js +7 -8
  2. package/fs/asn.1/{test.f.d.ts → proof.f.d.ts} +1 -2
  3. package/fs/asn.1/{test.f.js → proof.f.js} +12 -13
  4. package/fs/base128/proof.f.d.ts +1 -0
  5. package/fs/base128/{test.f.js → proof.f.js} +1 -1
  6. package/fs/bnf/data/{test.f.d.ts → proof.f.d.ts} +1 -2
  7. package/fs/bnf/data/{test.f.js → proof.f.js} +1 -1
  8. package/fs/bnf/proof.f.d.ts +3 -0
  9. package/fs/bnf/{test.f.js → proof.f.js} +1 -1
  10. package/fs/cas/module.f.js +2 -12
  11. package/fs/cas/proof.f.d.ts +1 -0
  12. package/fs/cas/proof.f.js +1 -0
  13. package/fs/cbase32/{test.f.d.ts → proof.f.d.ts} +1 -2
  14. package/fs/cbase32/{test.f.js → proof.f.js} +1 -1
  15. package/fs/ci/config/module.f.d.ts +4 -4
  16. package/fs/ci/config/module.f.js +4 -4
  17. package/fs/ci/node/module.f.js +12 -7
  18. package/fs/ci/{test.f.d.ts → proof.f.d.ts} +1 -2
  19. package/fs/ci/{test.f.js → proof.f.js} +1 -1
  20. package/fs/crypto/hmac/{test.f.d.ts → proof.f.d.ts} +1 -2
  21. package/fs/crypto/hmac/{test.f.js → proof.f.js} +1 -1
  22. package/fs/crypto/secp/{test.f.d.ts → proof.f.d.ts} +1 -2
  23. package/fs/crypto/secp/{test.f.js → proof.f.js} +1 -1
  24. package/fs/crypto/sha2/{test.f.d.ts → proof.f.d.ts} +1 -2
  25. package/fs/crypto/sha2/{test.f.js → proof.f.js} +1 -1
  26. package/fs/crypto/sign/module.f.js +3 -3
  27. package/fs/crypto/sign/{test.f.d.ts → proof.f.d.ts} +1 -2
  28. package/fs/crypto/sign/{test.f.js → proof.f.js} +1 -1
  29. package/fs/dev/module.f.d.ts +28 -2
  30. package/fs/dev/module.f.js +38 -22
  31. package/fs/dev/{test.f.d.ts → proof.f.d.ts} +5 -2
  32. package/fs/dev/{test.f.js → proof.f.js} +25 -2
  33. package/fs/dev/tf/module.d.ts +1 -2
  34. package/fs/dev/tf/module.f.d.ts +70 -7
  35. package/fs/dev/tf/module.f.js +115 -27
  36. package/fs/dev/tf/module.js +4 -103
  37. package/fs/dev/tf/{test.f.d.ts → proof.f.d.ts} +26 -0
  38. package/fs/dev/tf/{test.f.js → proof.f.js} +85 -38
  39. package/fs/dev/tf/scenarios/all.d.ts +1 -0
  40. package/fs/dev/tf/scenarios/all.js +3 -0
  41. package/fs/dev/tf/scenarios/async-subtests.fail.d.ts +4 -0
  42. package/fs/dev/tf/scenarios/async-subtests.fail.js +7 -0
  43. package/fs/dev/tf/scenarios/async-subtests.pass.d.ts +4 -0
  44. package/fs/dev/tf/scenarios/async-subtests.pass.js +7 -0
  45. package/fs/dev/tf/scenarios/async.fail.d.ts +1 -0
  46. package/fs/dev/tf/scenarios/async.fail.js +4 -0
  47. package/fs/dev/tf/scenarios/async.pass.d.ts +1 -0
  48. package/fs/dev/tf/scenarios/async.pass.js +3 -0
  49. package/fs/dev/tf/scenarios/fail.fail.f.d.ts +1 -0
  50. package/fs/dev/tf/scenarios/fail.fail.f.js +1 -0
  51. package/fs/dev/tf/scenarios/return-value.pass.f.d.ts +1 -0
  52. package/fs/dev/tf/scenarios/return-value.pass.f.js +2 -0
  53. package/fs/dev/tf/scenarios/thenable.pass.d.ts +3 -0
  54. package/fs/dev/tf/scenarios/thenable.pass.js +9 -0
  55. package/fs/dev/tf/scenarios/thenable2.pass.f.d.ts +3 -0
  56. package/fs/dev/tf/scenarios/thenable2.pass.f.js +3 -0
  57. package/fs/{bnf/test.f.d.ts → dev/tf/scenarios/throw.pass.f.d.ts} +3 -1
  58. package/fs/dev/tf/scenarios/throw.pass.f.js +3 -0
  59. package/fs/dev/version/proof.f.d.ts +3 -0
  60. package/fs/dev/version/{test.f.js → proof.f.js} +1 -1
  61. package/fs/djs/ast/{test.f.d.ts → proof.f.d.ts} +1 -2
  62. package/fs/djs/ast/{test.f.js → proof.f.js} +1 -1
  63. package/fs/djs/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
  64. package/fs/djs/parser/{test.f.js → proof.f.js} +1 -1
  65. package/fs/djs/{test.f.d.ts → proof.f.d.ts} +1 -2
  66. package/fs/djs/{test.f.js → proof.f.js} +1 -1
  67. package/fs/djs/serializer/module.f.d.ts +2 -2
  68. package/fs/djs/serializer/module.f.js +47 -79
  69. package/fs/djs/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
  70. package/fs/djs/serializer/{test.f.js → proof.f.js} +8 -8
  71. package/fs/djs/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  72. package/fs/djs/tokenizer/{test.f.js → proof.f.js} +1 -1
  73. package/fs/djs/tokenizer-new/{test.f.d.ts → proof.f.d.ts} +1 -2
  74. package/fs/djs/tokenizer-new/{test.f.js → proof.f.js} +1 -1
  75. package/fs/djs/transpiler/module.f.d.ts +15 -0
  76. package/fs/djs/transpiler/module.f.js +10 -2
  77. package/fs/djs/transpiler/{test.f.d.ts → proof.f.d.ts} +1 -2
  78. package/fs/djs/transpiler/{test.f.js → proof.f.js} +1 -1
  79. package/fs/fsc/{test.f.d.ts → proof.f.d.ts} +1 -2
  80. package/fs/fsc/{test.f.js → proof.f.js} +1 -1
  81. package/fs/fsm/proof.f.d.ts +4 -0
  82. package/fs/fsm/{test.f.js → proof.f.js} +1 -1
  83. package/fs/html/{test.f.d.ts → proof.f.d.ts} +1 -2
  84. package/fs/html/{test.f.js → proof.f.js} +1 -1
  85. package/fs/io/module.d.ts +1 -1
  86. package/fs/io/module.f.d.ts +8 -3
  87. package/fs/io/module.f.js +12 -12
  88. package/fs/io/module.js +43 -5
  89. package/fs/js/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  90. package/fs/js/tokenizer/{test.f.js → proof.f.js} +1 -1
  91. package/fs/json/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
  92. package/fs/json/parser/{test.f.js → proof.f.js} +1 -1
  93. package/fs/json/{test.f.d.ts → proof.f.d.ts} +1 -2
  94. package/fs/json/{test.f.js → proof.f.js} +1 -1
  95. package/fs/json/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
  96. package/fs/json/serializer/{test.f.js → proof.f.js} +1 -1
  97. package/fs/json/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  98. package/fs/json/tokenizer/{test.f.js → proof.f.js} +1 -1
  99. package/fs/path/proof.f.d.ts +5 -0
  100. package/fs/path/{test.f.js → proof.f.js} +4 -3
  101. package/fs/sul/id/module.f.js +3 -4
  102. package/fs/sul/id/{test.f.d.ts → proof.f.d.ts} +1 -2
  103. package/fs/sul/id/{test.f.js → proof.f.js} +1 -1
  104. package/fs/sul/level/hash/{test.f.d.ts → proof.f.d.ts} +1 -2
  105. package/fs/sul/level/hash/{test.f.js → proof.f.js} +1 -1
  106. package/fs/sul/level/literal/module.f.js +3 -3
  107. package/fs/sul/level/literal/{test.f.d.ts → proof.f.d.ts} +1 -2
  108. package/fs/sul/level/literal/{test.f.js → proof.f.js} +1 -1
  109. package/fs/sul/{test.f.d.ts → proof.f.d.ts} +1 -2
  110. package/fs/sul/{test.f.js → proof.f.js} +1 -1
  111. package/fs/text/ascii/proof.f.d.ts +3 -0
  112. package/fs/text/ascii/{test.f.js → proof.f.js} +1 -1
  113. package/fs/text/code_point/module.f.d.ts +28 -0
  114. package/fs/text/code_point/module.f.js +31 -0
  115. package/fs/text/{test.f.d.ts → proof.f.d.ts} +1 -2
  116. package/fs/text/{test.f.js → proof.f.js} +1 -1
  117. package/fs/text/sgr/proof.f.d.ts +1 -0
  118. package/fs/text/sgr/proof.f.js +23 -0
  119. package/fs/text/utf16/module.f.js +3 -53
  120. package/fs/text/utf16/{test.f.d.ts → proof.f.d.ts} +1 -2
  121. package/fs/text/utf16/{test.f.js → proof.f.js} +1 -1
  122. package/fs/text/utf8/module.f.js +3 -25
  123. package/fs/text/utf8/{test.f.d.ts → proof.f.d.ts} +1 -2
  124. package/fs/text/utf8/{test.f.js → proof.f.js} +1 -1
  125. package/fs/types/array/{test.f.d.ts → proof.f.d.ts} +1 -2
  126. package/fs/types/array/{test.f.js → proof.f.js} +1 -1
  127. package/fs/types/bigfloat/{test.f.d.ts → proof.f.d.ts} +1 -2
  128. package/fs/types/bigfloat/{test.f.js → proof.f.js} +1 -1
  129. package/fs/types/bigint/{test.f.d.ts → proof.f.d.ts} +1 -2
  130. package/fs/types/bigint/{test.f.js → proof.f.js} +1 -1
  131. package/fs/types/bit_vec/module.f.d.ts +9 -4
  132. package/fs/types/bit_vec/module.f.js +7 -9
  133. package/fs/types/bit_vec/{test.f.d.ts → proof.f.d.ts} +1 -2
  134. package/fs/types/bit_vec/{test.f.js → proof.f.js} +1 -1
  135. package/fs/types/btree/find/proof.f.d.ts +1 -0
  136. package/fs/types/btree/find/{test.f.js → proof.f.js} +1 -1
  137. package/fs/types/btree/{test.f.d.ts → proof.f.d.ts} +1 -2
  138. package/fs/types/btree/{test.f.js → proof.f.js} +1 -1
  139. package/fs/types/btree/remove/module.f.d.ts +1 -1
  140. package/fs/types/btree/remove/module.f.js +7 -2
  141. package/fs/types/btree/remove/proof.f.d.ts +4 -0
  142. package/fs/types/btree/remove/{test.f.js → proof.f.js} +1 -1
  143. package/fs/types/btree/set/module.f.d.ts +1 -1
  144. package/fs/types/btree/set/module.f.js +7 -2
  145. package/fs/types/btree/set/proof.f.d.ts +1 -0
  146. package/fs/types/btree/set/{test.f.js → proof.f.js} +1 -1
  147. package/fs/types/btree/types/module.f.d.ts +9 -0
  148. package/fs/types/btree/types/module.f.js +9 -1
  149. package/fs/types/byte_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  150. package/fs/types/byte_set/{test.f.js → proof.f.js} +1 -1
  151. package/fs/types/effects/module.f.d.ts +17 -0
  152. package/fs/types/effects/module.f.js +17 -0
  153. package/fs/types/effects/node/module.f.d.ts +66 -4
  154. package/fs/types/effects/node/module.f.js +5 -1
  155. package/fs/types/effects/node/{test.f.d.ts → proof.f.d.ts} +1 -2
  156. package/fs/types/effects/node/{test.f.js → proof.f.js} +1 -1
  157. package/fs/types/effects/node/virtual/module.f.d.ts +2 -1
  158. package/fs/types/effects/node/virtual/module.f.js +2 -0
  159. package/fs/types/effects/proof.f.d.ts +11 -0
  160. package/fs/types/effects/proof.f.js +57 -0
  161. package/fs/types/function/compare/proof.f.d.ts +1 -0
  162. package/fs/types/function/compare/{test.f.js → proof.f.js} +1 -1
  163. package/fs/types/function/operator/proof.f.d.ts +12 -0
  164. package/fs/types/function/operator/{test.f.js → proof.f.js} +11 -10
  165. package/fs/types/function/proof.f.d.ts +1 -0
  166. package/fs/types/function/{test.f.js → proof.f.js} +1 -1
  167. package/fs/types/list/{test.f.d.ts → proof.f.d.ts} +1 -2
  168. package/fs/types/list/{test.f.js → proof.f.js} +1 -1
  169. package/fs/types/map/proof.f.d.ts +4 -0
  170. package/fs/types/map/{test.f.js → proof.f.js} +1 -1
  171. package/fs/types/monoid/{test.f.d.ts → proof.f.d.ts} +1 -2
  172. package/fs/types/monoid/{test.f.js → proof.f.js} +1 -1
  173. package/fs/types/nibble_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  174. package/fs/types/nibble_set/{test.f.js → proof.f.js} +1 -1
  175. package/fs/types/nominal/proof.f.d.ts +4 -0
  176. package/fs/types/nominal/{test.f.js → proof.f.js} +1 -1
  177. package/fs/types/nullable/proof.f.d.ts +1 -0
  178. package/fs/types/nullable/{test.f.js → proof.f.js} +11 -2
  179. package/fs/types/number/{test.f.d.ts → proof.f.d.ts} +1 -2
  180. package/fs/types/number/{test.f.js → proof.f.js} +1 -1
  181. package/fs/types/object/{test.f.d.ts → proof.f.d.ts} +1 -2
  182. package/fs/types/object/{test.f.js → proof.f.js} +1 -1
  183. package/fs/types/ordered_map/{test.f.d.ts → proof.f.d.ts} +1 -2
  184. package/fs/types/ordered_map/{test.f.js → proof.f.js} +1 -1
  185. package/fs/types/patricia_trie/{test.f.d.ts → proof.f.d.ts} +1 -2
  186. package/fs/types/patricia_trie/{test.f.js → proof.f.js} +1 -1
  187. package/fs/types/prime_field/{test.f.d.ts → proof.f.d.ts} +1 -2
  188. package/fs/types/prime_field/{test.f.js → proof.f.js} +1 -1
  189. package/fs/types/range/proof.f.d.ts +1 -0
  190. package/fs/types/range/{test.f.js → proof.f.js} +1 -1
  191. package/fs/types/range_map/{test.f.d.ts → proof.f.d.ts} +1 -2
  192. package/fs/types/range_map/{test.f.js → proof.f.js} +1 -1
  193. package/fs/types/result/proof.f.d.ts +5 -0
  194. package/fs/types/result/{test.f.js → proof.f.js} +18 -2
  195. package/fs/types/rtti/parse/{test.f.d.ts → proof.f.d.ts} +1 -2
  196. package/fs/types/rtti/parse/{test.f.js → proof.f.js} +1 -1
  197. package/fs/types/rtti/{test.f.d.ts → proof.f.d.ts} +1 -2
  198. package/fs/types/rtti/{test.f.js → proof.f.js} +1 -1
  199. package/fs/types/rtti/ts/{test.f.d.ts → proof.f.d.ts} +1 -2
  200. package/fs/types/rtti/ts/{test.f.js → proof.f.js} +1 -1
  201. package/fs/types/rtti/validate/{test.f.d.ts → proof.f.d.ts} +1 -2
  202. package/fs/types/rtti/validate/{test.f.js → proof.f.js} +1 -1
  203. package/fs/types/sorted_list/{test.f.d.ts → proof.f.d.ts} +1 -2
  204. package/fs/types/sorted_list/{test.f.js → proof.f.js} +1 -1
  205. package/fs/types/sorted_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  206. package/fs/types/sorted_set/{test.f.js → proof.f.js} +1 -1
  207. package/fs/types/string/{test.f.d.ts → proof.f.d.ts} +1 -2
  208. package/fs/types/string/{test.f.js → proof.f.js} +1 -1
  209. package/fs/types/string_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  210. package/fs/types/string_set/{test.f.js → proof.f.js} +1 -1
  211. package/fs/types/ts/{test.f.d.ts → proof.f.d.ts} +20 -0
  212. package/fs/types/ts/{test.f.js → proof.f.js} +1 -0
  213. package/fs/types/uint8array/{test.f.d.ts → proof.f.d.ts} +1 -2
  214. package/fs/types/uint8array/{test.f.js → proof.f.js} +1 -1
  215. package/issues/demo/sample/{test.f.js → proof.f.js} +1 -1
  216. package/issues/{test.f.d.ts → proof.f.d.ts} +1 -2
  217. package/issues/{test.f.js → proof.f.js} +1 -1
  218. package/nanvm-lib/tests/{test.f.d.ts → proof.f.d.ts} +1 -2
  219. package/nanvm-lib/tests/{test.f.js → proof.f.js} +1 -1
  220. package/nanvm-lib/tests/vm/{test.f.d.ts → proof.f.d.ts} +1 -2
  221. package/nanvm-lib/tests/vm/{test.f.js → proof.f.js} +1 -1
  222. package/package.json +5 -5
  223. package/fs/base128/test.f.d.ts +0 -2
  224. package/fs/cas/test.f.d.ts +0 -2
  225. package/fs/cas/test.f.js +0 -1
  226. package/fs/dev/version/test.f.d.ts +0 -4
  227. package/fs/fsm/test.f.d.ts +0 -5
  228. package/fs/path/test.f.d.ts +0 -3
  229. package/fs/text/ascii/test.f.d.ts +0 -4
  230. package/fs/text/sgr/test.f.d.ts +0 -2
  231. package/fs/text/sgr/test.f.js +0 -8
  232. package/fs/types/btree/find/test.f.d.ts +0 -2
  233. package/fs/types/btree/remove/test.f.d.ts +0 -5
  234. package/fs/types/btree/set/test.f.d.ts +0 -2
  235. package/fs/types/function/compare/test.f.d.ts +0 -2
  236. package/fs/types/function/operator/test.f.d.ts +0 -10
  237. package/fs/types/function/test.f.d.ts +0 -2
  238. package/fs/types/map/test.f.d.ts +0 -5
  239. package/fs/types/nominal/test.f.d.ts +0 -5
  240. package/fs/types/nullable/test.f.d.ts +0 -2
  241. package/fs/types/range/test.f.d.ts +0 -2
  242. package/fs/types/result/test.f.d.ts +0 -2
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  has: (() => void)[];
3
3
  setRange: () => void;
4
4
  unset: (() => void)[];
@@ -9,4 +9,3 @@ declare const _default: {
9
9
  };
10
10
  toRangeMap: (() => void)[];
11
11
  };
12
- export default _default;
@@ -3,7 +3,7 @@ import { every, countdown, map, toArray } from "../list/module.f.js";
3
3
  import { stringify as jsonStringify } from "../../json/module.f.js";
4
4
  import { sort } from "../object/module.f.js";
5
5
  const stringify = jsonStringify(sort);
6
- export default {
6
+ export const proof = {
7
7
  has: [
8
8
  () => {
9
9
  if (has(0)(empty)) {
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
+ import { type List } from '../list/module.f.ts';
6
7
  export type Operation = readonly [string, (..._: readonly never[]) => unknown];
7
8
  export type Effect<O extends Operation, T> = {
8
9
  value: Value<O, T>;
@@ -20,6 +21,22 @@ export type Param<O extends Operation> = F<O>[0];
20
21
  export type Return<O extends Operation> = F<O>[1];
21
22
  export declare const do_: <O extends Operation>(cmd: O[0]) => (...param: Param<O>) => Effect<O, Return<O>>;
22
23
  export declare const begin: Effect<never, void>;
24
+ /**
25
+ * Sequentially threads a state value through an effect for each item in `items`.
26
+ *
27
+ * Given `f: item => state => Effect<O, state>`, `init: S`, and `items: [x₀, x₁, …]`,
28
+ * builds `f(x₀)(init).step(f(x₁)).step(f(x₂)).…` and yields a single
29
+ * `Effect<O, S>` that produces the final state.
30
+ *
31
+ * Sequential — each step depends on the previous state. Compare to `all`,
32
+ * which fans out independent effects.
33
+ */
34
+ export declare const foldStep: <O extends Operation, T, S>(f: (item: T) => (state: S) => Effect<O, S>) => (init: S) => (items: List<T>) => Effect<O, S>;
35
+ /**
36
+ * Sequentially runs `f(item)` for each item in `items`, discarding intermediate
37
+ * results. The `void` accumulator sibling of `foldStep`.
38
+ */
39
+ export declare const forEachStep: <O extends Operation, T>(f: (item: T) => Effect<O, void>) => (items: List<T>) => Effect<O, void>;
23
40
  export type ToAsyncOperationMap<O extends Operation> = {
24
41
  readonly [K in O[0]]: (...payload: Pr<O, K>[0]) => Promise<Pr<O, K>[1]>;
25
42
  };
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
+ import { fold } from "../list/module.f.js";
6
7
  export const pure = (v) => ({
7
8
  value: [v],
8
9
  step: f => f(v)
@@ -13,3 +14,19 @@ export const doFull = (cmd, param, cont) => ({
13
14
  });
14
15
  export const do_ = (cmd) => (...param) => doFull(cmd, param, pure);
15
16
  export const begin = pure(undefined);
17
+ /**
18
+ * Sequentially threads a state value through an effect for each item in `items`.
19
+ *
20
+ * Given `f: item => state => Effect<O, state>`, `init: S`, and `items: [x₀, x₁, …]`,
21
+ * builds `f(x₀)(init).step(f(x₁)).step(f(x₂)).…` and yields a single
22
+ * `Effect<O, S>` that produces the final state.
23
+ *
24
+ * Sequential — each step depends on the previous state. Compare to `all`,
25
+ * which fans out independent effects.
26
+ */
27
+ export const foldStep = (f) => (init) => (items) => fold(item => acc => acc.step(f(item)))(pure(init))(items);
28
+ /**
29
+ * Sequentially runs `f(item)` for each item in `items`, discarding intermediate
30
+ * results. The `void` accumulator sibling of `foldStep`.
31
+ */
32
+ export const forEachStep = (f) => (items) => foldStep((item) => () => f(item))(undefined)(items);
@@ -77,8 +77,15 @@ export type Module = {
77
77
  };
78
78
  export type Import = ['import', (path: string) => IoResult<Module>];
79
79
  export declare const import_: Func<Import>;
80
+ /** Named output streams accepted by the `Write` effect. */
80
81
  export type WriteConsoles = 'stdout' | 'stderr';
82
+ /**
83
+ * Raw byte write to a named output stream. Encoding-agnostic — callers supply
84
+ * a `Vec`. The Node runner maps each stream name to the appropriate fd and
85
+ * delegates to the OS via `stream.write()` with backpressure handling.
86
+ */
81
87
  export type Write = readonly ['write', (stream: WriteConsoles, data: Vec) => void];
88
+ /** Emits a `Write` effect to the given named stream. */
82
89
  export declare const write: Func<Write>;
83
90
  export type Console = (s: string) => Effect<Write, void>;
84
91
  /** Writes a line to `stdout`. Replaces the retired `Log` effect. */
@@ -87,12 +94,19 @@ export declare const log: Console;
87
94
  export declare const error: Console;
88
95
  export type Now = readonly ['now', () => number];
89
96
  export declare const now: Func<Now>;
97
+ /**
98
+ * The outcome of a `Sandbox` operation.
99
+ *
100
+ * `result` carries either `['ok', value]` or `['error', thrown]`. `duration`
101
+ * is a floating-point millisecond count with up to microsecond precision,
102
+ * matching `performance.now()` directly. Additional fields (allocated memory,
103
+ * max stack depth, coverage) may be added in future without breaking consumers.
104
+ */
90
105
  export type SandboxResult<T> = {
91
106
  readonly result: Result<T, unknown>;
92
107
  /**
93
- * Measured milliseconds but it's not limited to that.
94
- * Instead, they represent times as floating-point numbers
95
- * with up to microsecond precision.
108
+ * Elapsed time in milliseconds (microsecond precision via `performance.now()`).
109
+ * The virtual runner returns `0` for deterministic tests.
96
110
  */
97
111
  readonly duration: number;
98
112
  };
@@ -116,7 +130,36 @@ export type Sandbox = readonly ['sandbox', <T>(f: () => T) => SandboxResult<T>];
116
130
  * @see {@link SandboxResult}
117
131
  */
118
132
  export declare const sandbox: Func<Sandbox>;
119
- export type NodeOp = All | Fetch | Fs | Http | Forever | Import | Now | Sandbox | Write;
133
+ /**
134
+ * Resolves the return value of a test function inside the effect runner.
135
+ * If `p` is a real `Promise`, it is awaited and rejections propagate as
136
+ * throws. If `p` is any other value it is returned as-is. Plain thenables
137
+ * (objects with a `.then` method that are not `instanceof Promise`) are
138
+ * treated as ordinary values — not awaited. See `fs/dev/tf/README.md`.
139
+ */
140
+ export type Await = readonly ['await', (p: unknown) => readonly [unknown]];
141
+ export declare const awaitIfPromise: (p: unknown) => Effect<Await, unknown>;
142
+ /**
143
+ * Signature of a framework test-registration function (e.g. `nodeTest.test`,
144
+ * `bunTest.test`, `pwTest`). Returns `Promise<void>` so async sub-tests can
145
+ * be awaited.
146
+ */
147
+ export type TestFn = (name: string, options: {
148
+ readonly expectFailure: boolean;
149
+ }, fn: (t: TestContext) => Promise<void>) => Promise<void>;
150
+ /**
151
+ * A thin wrapper around a framework's `test` function. Passed through
152
+ * `registerModule` so nested test registration uses the appropriate context
153
+ * (e.g. `inlineContext` on Bun and Playwright, which do not support nested
154
+ * `test()` calls inside a callback).
155
+ */
156
+ export type TestContext = {
157
+ readonly test: TestFn;
158
+ };
159
+ /** Effect operation that registers a named test with the active `TestContext`. */
160
+ export type Test = readonly ['test', (ctx: TestContext, name: string, expectFailure: boolean, test: (t: TestContext) => Effect<Test | All | Await, void>) => void];
161
+ export declare const test: Func<Test>;
162
+ export type NodeOp = All | Await | Fetch | Fs | Http | Forever | Import | Now | Sandbox | Write | Test;
120
163
  export type NodeEffect<T> = Effect<NodeOp, T>;
121
164
  export type NodeOperationMap = ToAsyncOperationMap<NodeOp>;
122
165
  /**
@@ -125,6 +168,21 @@ export type NodeOperationMap = ToAsyncOperationMap<NodeOp>;
125
168
  export type Env = {
126
169
  readonly [k: string]: string | undefined;
127
170
  };
171
+ /** Identifies the JavaScript runtime detected at startup. */
172
+ export type Engine = 'node' | 'bun' | 'playwright';
173
+ /**
174
+ * Runtime options passed to every `NodeProgram`.
175
+ *
176
+ * - `args`: command-line arguments (equivalent to `process.argv.slice(2)`).
177
+ * - `env`: process environment variables.
178
+ * - `std`: TTY flags for `stdout` and `stderr`, known at startup and used by
179
+ * `csiWrite` to decide whether to strip ANSI SGR sequences.
180
+ * - `testContext`: Node `--test` context; used by `register` on Node.
181
+ * - `bunTestContext`: Bun-compatible context that flattens nested tests inline,
182
+ * working around Bun's lack of nested `test()` support.
183
+ * - `playwrightTestContext`: Playwright context using the same inline strategy.
184
+ * - `engine`: runtime detected at startup; controls which context `register` selects.
185
+ */
128
186
  export type NodeProgramOptions = {
129
187
  readonly args: readonly string[];
130
188
  readonly env: Env;
@@ -133,6 +191,10 @@ export type NodeProgramOptions = {
133
191
  readonly isTTY: boolean;
134
192
  };
135
193
  };
194
+ readonly testContext: TestContext;
195
+ readonly bunTestContext: TestContext;
196
+ readonly playwrightTestContext: TestContext;
197
+ readonly engine: Engine;
136
198
  };
137
199
  export type Program<O extends Operation> = (options: NodeProgramOptions) => Effect<O, number>;
138
200
  export type NodeProgram = Program<NodeOp>;
@@ -8,7 +8,7 @@
8
8
  * @module
9
9
  */
10
10
  import { utf8 } from "../../../text/module.f.js";
11
- import { do_ } from "../module.f.js";
11
+ import { do_, pure } from "../module.f.js";
12
12
  const doAll = do_('all');
13
13
  /**
14
14
  * To run the operation `O` should be known by the runner/engine.
@@ -31,6 +31,7 @@ export const createServer = do_('createServer');
31
31
  export const listen = do_('listen');
32
32
  export const forever = do_('forever');
33
33
  export const import_ = do_('import');
34
+ /** Emits a `Write` effect to the given named stream. */
34
35
  export const write = do_('write');
35
36
  /**
36
37
  * Encodes `s + '\n'` as UTF-8 and emits a `Write` effect to `stream`.
@@ -61,3 +62,6 @@ export const now = do_('now');
61
62
  * @see {@link SandboxResult}
62
63
  */
63
64
  export const sandbox = do_('sandbox');
65
+ const awaitPromise = do_('await');
66
+ export const awaitIfPromise = (p) => awaitPromise(p).step(([x]) => pure(x));
67
+ export const test = do_('test');
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  map: () => void;
3
3
  fetch: () => void;
4
4
  mkdir: {
@@ -36,4 +36,3 @@ declare const _default: {
36
36
  error: () => void;
37
37
  };
38
38
  };
39
- export default _default;
@@ -2,7 +2,7 @@ import { empty, isVec, uint, vec8 } from "../../bit_vec/module.f.js";
2
2
  import { pure } from "../module.f.js";
3
3
  import { fetch, mkdir, now, readdir, readFile, rm, sandbox, writeFile } from "./module.f.js";
4
4
  import { emptyState, virtual } from "./virtual/module.f.js";
5
- export default {
5
+ export const proof = {
6
6
  map: () => {
7
7
  let e = readFile('hello').step(([k, v]) => {
8
8
  if (k === 'error') {
@@ -10,8 +10,9 @@ import type { Module, NodeOp } from '../module.f.ts';
10
10
  * each import for closures/state.
11
11
  */
12
12
  export type JsModule = () => Module;
13
+ export type Entity = Vec | Dir | JsModule;
13
14
  export type Dir = {
14
- readonly [name in string]?: Dir | Vec | JsModule;
15
+ readonly [name in string]?: Entity;
15
16
  };
16
17
  export type State = {
17
18
  stdout: string;
@@ -167,6 +167,8 @@ const map = {
167
167
  // exception in a fixture propagates loudly as a bug in the fixture.
168
168
  // See: issues/156-tf-virtual-tests.md
169
169
  sandbox: (state, f) => [state, f()],
170
+ await: (state, p) => [state, [p]],
171
+ test: todo,
170
172
  write: (state, stream, data) => {
171
173
  const s = utf8ToString(data);
172
174
  return [{ ...state, [stream]: `${state[stream]}${s}` }, undefined];
@@ -0,0 +1,11 @@
1
+ export declare const proof: {
2
+ foldStep: {
3
+ empty: () => void;
4
+ threadsState: () => void;
5
+ order: () => void;
6
+ };
7
+ forEachStep: {
8
+ empty: () => void;
9
+ runs: () => void;
10
+ };
11
+ };
@@ -0,0 +1,57 @@
1
+ import { foldStep, forEachStep, pure } from "./module.f.js";
2
+ export const proof = {
3
+ foldStep: {
4
+ empty: () => {
5
+ const e = foldStep((x) => (s) => pure(s + x))(10)([]);
6
+ const { value } = e;
7
+ if (value.length !== 1) {
8
+ throw value;
9
+ }
10
+ if (value[0] !== 10) {
11
+ throw value[0];
12
+ }
13
+ },
14
+ threadsState: () => {
15
+ const e = foldStep((x) => (s) => pure(s + x))(0)([1, 2, 3, 4]);
16
+ const { value } = e;
17
+ if (value.length !== 1) {
18
+ throw value;
19
+ }
20
+ if (value[0] !== 10) {
21
+ throw value[0];
22
+ }
23
+ },
24
+ order: () => {
25
+ const e = foldStep((x) => (s) => pure(s + x))('')(['a', 'b', 'c']);
26
+ const { value } = e;
27
+ if (value.length !== 1) {
28
+ throw value;
29
+ }
30
+ if (value[0] !== 'abc') {
31
+ throw value[0];
32
+ }
33
+ },
34
+ },
35
+ forEachStep: {
36
+ empty: () => {
37
+ const e = forEachStep(() => pure(undefined))([]);
38
+ const { value } = e;
39
+ if (value.length !== 1) {
40
+ throw value;
41
+ }
42
+ if (value[0] !== undefined) {
43
+ throw value[0];
44
+ }
45
+ },
46
+ runs: () => {
47
+ const e = forEachStep(() => pure(undefined))([1, 2, 3]);
48
+ const { value } = e;
49
+ if (value.length !== 1) {
50
+ throw value;
51
+ }
52
+ if (value[0] !== undefined) {
53
+ throw value[0];
54
+ }
55
+ },
56
+ },
57
+ };
@@ -0,0 +1 @@
1
+ export declare const proof: () => void;
@@ -1,5 +1,5 @@
1
1
  import { cmp } from "./module.f.js";
2
- export default () => {
2
+ export const proof = () => {
3
3
  {
4
4
  const result = cmp(true)(false);
5
5
  if (result !== 1) {
@@ -0,0 +1,12 @@
1
+ export declare const proof: {
2
+ joinTest: () => void;
3
+ concatTest: () => void;
4
+ logicalNotTest: () => void;
5
+ strictEqualTest: () => void;
6
+ additionTest: () => void;
7
+ minTest: () => void;
8
+ maxTest: () => void;
9
+ incrementTest: () => void;
10
+ foldToScanTest: () => void;
11
+ reduceToScanTest: () => void;
12
+ };
@@ -1,17 +1,17 @@
1
1
  import { join, concat, logicalNot, strictEqual, addition, min, max, increment, foldToScan, reduceToScan, } from "./module.f.js";
2
- export const joinTest = () => {
2
+ const joinTest = () => {
3
3
  const result = join(', ')('world')('hello');
4
4
  if (result !== 'hello, world') {
5
5
  throw result;
6
6
  }
7
7
  };
8
- export const concatTest = () => {
8
+ const concatTest = () => {
9
9
  const result = concat('world')('hello');
10
10
  if (result !== 'helloworld') {
11
11
  throw result;
12
12
  }
13
13
  };
14
- export const logicalNotTest = () => {
14
+ const logicalNotTest = () => {
15
15
  if (logicalNot(true) !== false) {
16
16
  throw 'expected false';
17
17
  }
@@ -19,7 +19,7 @@ export const logicalNotTest = () => {
19
19
  throw 'expected true';
20
20
  }
21
21
  };
22
- export const strictEqualTest = () => {
22
+ const strictEqualTest = () => {
23
23
  if (!strictEqual(1)(1)) {
24
24
  throw 'expected true';
25
25
  }
@@ -27,13 +27,13 @@ export const strictEqualTest = () => {
27
27
  throw 'expected false';
28
28
  }
29
29
  };
30
- export const additionTest = () => {
30
+ const additionTest = () => {
31
31
  const result = addition(3)(4);
32
32
  if (result !== 7) {
33
33
  throw result;
34
34
  }
35
35
  };
36
- export const minTest = () => {
36
+ const minTest = () => {
37
37
  if (min(3)(5) !== 3) {
38
38
  throw 'min(3)(5)';
39
39
  }
@@ -41,7 +41,7 @@ export const minTest = () => {
41
41
  throw 'min(7)(2)';
42
42
  }
43
43
  };
44
- export const maxTest = () => {
44
+ const maxTest = () => {
45
45
  if (max(3)(5) !== 5) {
46
46
  throw 'max(3)(5)';
47
47
  }
@@ -49,7 +49,7 @@ export const maxTest = () => {
49
49
  throw 'max(7)(2)';
50
50
  }
51
51
  };
52
- export const incrementTest = () => {
52
+ const incrementTest = () => {
53
53
  if (increment(4) !== 5) {
54
54
  throw 'increment(4)';
55
55
  }
@@ -57,7 +57,7 @@ export const incrementTest = () => {
57
57
  throw 'increment(0)';
58
58
  }
59
59
  };
60
- export const foldToScanTest = () => {
60
+ const foldToScanTest = () => {
61
61
  const scan = foldToScan(addition)(0);
62
62
  const [v1, scan2] = scan(3);
63
63
  if (v1 !== 3) {
@@ -68,7 +68,7 @@ export const foldToScanTest = () => {
68
68
  throw v2;
69
69
  }
70
70
  };
71
- export const reduceToScanTest = () => {
71
+ const reduceToScanTest = () => {
72
72
  const scan = reduceToScan(addition);
73
73
  const [v0, scan2] = scan(10);
74
74
  if (v0 !== 10) {
@@ -79,3 +79,4 @@ export const reduceToScanTest = () => {
79
79
  throw v1;
80
80
  }
81
81
  };
82
+ export const proof = { joinTest, concatTest, logicalNotTest, strictEqualTest, additionTest, minTest, maxTest, incrementTest, foldToScanTest, reduceToScanTest };
@@ -0,0 +1 @@
1
+ export declare const proof: () => void;
@@ -1,5 +1,5 @@
1
1
  import { fn } from "./module.f.js";
2
- export default () => {
2
+ export const proof = () => {
3
3
  const f = x => [x];
4
4
  const g = ([x]) => [x.length];
5
5
  const w = ([x]) => x;
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  stringifyTest: () => void;
3
3
  cycle: () => void;
4
4
  countdown: () => void;
@@ -19,4 +19,3 @@ declare const _default: {
19
19
  isEmpty: (() => void)[];
20
20
  length: () => void;
21
21
  };
22
- export default _default;
@@ -321,7 +321,7 @@ const stress = () => ({
321
321
  }
322
322
  }
323
323
  });
324
- export default {
324
+ export const proof = {
325
325
  stringifyTest,
326
326
  cycle: cycleTest,
327
327
  countdown: countdownTest,
@@ -0,0 +1,4 @@
1
+ export declare const proof: {
2
+ set: () => void;
3
+ delete: () => void;
4
+ };
@@ -1,5 +1,5 @@
1
1
  import { mapSet, mapDelete } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  set: () => {
4
4
  const map = mapSet(new Map(), 'a', 'b');
5
5
  if (map.get('a') !== 'b') {
@@ -1,5 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  numberAdd: () => void;
3
3
  stringConcat: () => void;
4
4
  };
5
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { repeat } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  numberAdd: () => {
4
4
  const add = {
5
5
  identity: 0,
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  has: () => void;
3
3
  set: (() => void)[];
4
4
  unset: () => (() => void)[];
@@ -9,4 +9,3 @@ declare const _default: {
9
9
  universe: () => void;
10
10
  };
11
11
  };
12
- export default _default;
@@ -1,6 +1,6 @@
1
1
  import { every, map, countdown } from "../list/module.f.js";
2
2
  import { empty, has, set, setRange, unset, universe, complement } from "./module.f.js";
3
- export default {
3
+ export const proof = {
4
4
  has: () => {
5
5
  if (has(0)(empty)) {
6
6
  throw empty;
@@ -0,0 +1,4 @@
1
+ export declare const proof: {
2
+ pre: () => void;
3
+ nominal: () => void;
4
+ };
@@ -1,5 +1,5 @@
1
1
  import { asBase, asNominal } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  pre: () => {
4
4
  const strA = asNominal(7560413859n); // "¢£"
5
5
  const strB = asNominal(7560413860n); // "¢¤"
@@ -0,0 +1 @@
1
+ export declare const proof: (() => void)[];
@@ -1,5 +1,5 @@
1
- import { map, toOption } from "./module.f.js";
2
- export default [
1
+ import { map, match, toOption } from "./module.f.js";
2
+ export const proof = [
3
3
  () => {
4
4
  const optionSq = map((v) => v * v);
5
5
  const sq3 = optionSq(3);
@@ -20,5 +20,14 @@ export default [
20
20
  if (opt2.length !== 0) {
21
21
  throw opt2;
22
22
  }
23
+ },
24
+ () => {
25
+ const double = match((v) => v * 2)(() => -1);
26
+ if (double(3) !== 6) {
27
+ throw double(3);
28
+ }
29
+ if (double(null) !== -1) {
30
+ throw double(null);
31
+ }
23
32
  }
24
33
  ];
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  sum: () => void;
3
3
  min: {
4
4
  empty: () => void;
@@ -9,4 +9,3 @@ declare const _default: {
9
9
  standard: () => void;
10
10
  countOnes: (() => void)[];
11
11
  };
12
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { sum, min, max, cmp, countOnes } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  sum: () => {
4
4
  const result = sum([2, 3, 4, 5]);
5
5
  if (result !== 14) {
@@ -1,5 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  ctor: () => void;
3
3
  property: () => void;
4
4
  };
5
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { at } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  ctor: () => {
4
4
  const a = {};
5
5
  const value = at('constructor')(a);
@@ -1,5 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  main: (() => void)[];
3
3
  stress: () => void;
4
4
  };
5
- export default _default;
@@ -1,6 +1,6 @@
1
1
  import { at, setReplace, setReduce, empty, entries, remove } from "./module.f.js";
2
2
  import { toArray } from "../list/module.f.js";
3
- export default {
3
+ export const proof = {
4
4
  main: [
5
5
  () => {
6
6
  let m = setReplace('a')(1)(null);
@@ -1,8 +1,7 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  empty: () => void;
3
3
  singleLeaf: () => void;
4
4
  twoLeaves: () => void;
5
5
  descending: () => void;
6
6
  ascending: () => void;
7
7
  };
8
- export default _default;
@@ -112,7 +112,7 @@ const ascending = () => runExample([
112
112
  [119n, 179n, 200n, 227n, 242n],
113
113
  [119n, 179n, 200n, 227n, 242n, 249n],
114
114
  ], [0, 0, 0, 2, 1, 0, 1, 0, 3, 0, 0, 1, 2, 0, 0, 0]);
115
- export default {
115
+ export const proof = {
116
116
  empty,
117
117
  singleLeaf,
118
118
  twoLeaves,
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  prime_field_test: () => {
3
3
  neg: () => void;
4
4
  sub: () => void;
@@ -10,4 +10,3 @@ declare const _default: {
10
10
  sqrt: () => void;
11
11
  };
12
12
  };
13
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { prime_field, sqrt } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  prime_field_test: () => {
4
4
  const p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;
5
5
  const f = prime_field(p);