functionalscript 0.45.0 → 0.46.1

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 (296) hide show
  1. package/README.md +5 -3
  2. package/fjs/asn.1/module.f.mjs +8 -1
  3. package/fjs/asn.1/proof.f.d.mts +10 -0
  4. package/fjs/asn.1/proof.f.mjs +16 -0
  5. package/fjs/basen/base128/module.f.mjs +22 -5
  6. package/fjs/bnf/data/module.f.d.mts +32 -6
  7. package/fjs/bnf/data/module.f.mjs +112 -7
  8. package/fjs/bnf/data/proof.f.d.mts +2 -0
  9. package/fjs/bnf/data/proof.f.mjs +74 -3
  10. package/fjs/bnf/data/types.d.ts +20 -2
  11. package/fjs/bnf/descent/module.f.d.mts +28 -14
  12. package/fjs/bnf/descent/module.f.mjs +122 -77
  13. package/fjs/bnf/descent/proof.f.d.mts +2 -0
  14. package/fjs/bnf/descent/proof.f.mjs +117 -31
  15. package/fjs/bnf/descent/types.d.ts +12 -14
  16. package/fjs/bnf/ll1/module.f.d.mts +64 -22
  17. package/fjs/bnf/ll1/module.f.mjs +214 -154
  18. package/fjs/bnf/ll1/proof.f.d.mts +15 -2
  19. package/fjs/bnf/ll1/proof.f.mjs +323 -149
  20. package/fjs/bnf/ll1/types.d.ts +16 -24
  21. package/fjs/bnf/matcher/module.f.d.mts +66 -0
  22. package/fjs/bnf/matcher/module.f.mjs +81 -0
  23. package/fjs/bnf/matcher/proof.f.d.mts +10 -0
  24. package/fjs/bnf/matcher/proof.f.mjs +79 -0
  25. package/fjs/bnf/matcher/types.d.ts +54 -0
  26. package/fjs/bnf/testlib.f.d.mts +31 -0
  27. package/fjs/bnf/testlib.f.mjs +80 -0
  28. package/fjs/cas/cli/module.f.d.mts +1 -1
  29. package/fjs/cas/cli/module.f.mjs +14 -20
  30. package/fjs/cas/cli/proof.f.d.mts +1 -3
  31. package/fjs/cas/cli/proof.f.mjs +44 -33
  32. package/fjs/cas/evo/module.f.d.mts +64 -18
  33. package/fjs/cas/evo/module.f.mjs +148 -70
  34. package/fjs/cas/evo/proof.f.d.mts +10 -1
  35. package/fjs/cas/evo/proof.f.mjs +305 -223
  36. package/fjs/cas/evo/types.d.ts +45 -9
  37. package/fjs/cas/module.f.d.mts +18 -32
  38. package/fjs/cas/module.f.mjs +129 -128
  39. package/fjs/cas/proof.f.d.mts +11 -8
  40. package/fjs/cas/proof.f.mjs +259 -147
  41. package/fjs/cas/types.d.ts +24 -10
  42. package/fjs/ci/config/module.f.d.mts +2 -2
  43. package/fjs/ci/config/module.f.mjs +2 -2
  44. package/fjs/ci/module.f.d.mts +5 -5
  45. package/fjs/ci/module.f.mjs +8 -7
  46. package/fjs/ci/nix/module.f.d.mts +7 -5
  47. package/fjs/ci/nix/module.f.mjs +13 -12
  48. package/fjs/ci/nix/proof.f.mjs +2 -2
  49. package/fjs/ci/proof.f.mjs +9 -5
  50. package/fjs/cli/module.f.d.mts +4 -6
  51. package/fjs/cli/module.f.mjs +4 -8
  52. package/fjs/cli/proof.f.mjs +17 -16
  53. package/fjs/cli/types.d.ts +2 -3
  54. package/fjs/common/monoid/types.d.ts +1 -1
  55. package/fjs/crypto/hmac/module.f.mjs +2 -2
  56. package/fjs/crypto/sha2/module.f.mjs +3 -1
  57. package/fjs/crypto/sha2/proof.f.d.mts +1 -0
  58. package/fjs/crypto/sha2/proof.f.mjs +24 -0
  59. package/fjs/crypto/sha2/types.d.ts +11 -0
  60. package/fjs/crypto/sign/module.f.mjs +2 -2
  61. package/fjs/dev/module.f.d.mts +13 -4
  62. package/fjs/dev/module.f.mjs +56 -27
  63. package/fjs/dev/update/module.f.d.mts +9 -4
  64. package/fjs/dev/update/module.f.mjs +14 -10
  65. package/fjs/dev/update/proof.f.d.mts +1 -3
  66. package/fjs/dev/update/proof.f.mjs +10 -5
  67. package/fjs/djs/module.f.d.mts +13 -5
  68. package/fjs/djs/module.f.mjs +31 -16
  69. package/fjs/djs/parser/module.f.d.mts +13 -3
  70. package/fjs/djs/parser/module.f.mjs +117 -16
  71. package/fjs/djs/parser/proof.f.d.mts +5 -1
  72. package/fjs/djs/parser/proof.f.mjs +274 -12
  73. package/fjs/djs/parser/types.d.ts +7 -1
  74. package/fjs/djs/proof.f.d.mts +18 -2
  75. package/fjs/djs/proof.f.mjs +187 -12
  76. package/fjs/djs/serializer/module.f.d.mts +25 -8
  77. package/fjs/djs/serializer/module.f.mjs +61 -15
  78. package/fjs/djs/serializer/proof.f.d.mts +5 -0
  79. package/fjs/djs/serializer/proof.f.mjs +23 -1
  80. package/fjs/djs/tokenizer/module.f.d.mts +17 -5
  81. package/fjs/djs/tokenizer/module.f.mjs +99 -60
  82. package/fjs/djs/tokenizer/proof.f.d.mts +1 -1
  83. package/fjs/djs/tokenizer/proof.f.mjs +74 -67
  84. package/fjs/djs/transpiler/module.f.d.mts +12 -7
  85. package/fjs/djs/transpiler/module.f.mjs +82 -56
  86. package/fjs/djs/transpiler/types.d.ts +7 -3
  87. package/fjs/djs/types.d.ts +7 -1
  88. package/fjs/effects/list/module.f.d.mts +14 -11
  89. package/fjs/effects/list/module.f.mjs +13 -11
  90. package/fjs/effects/list/types.d.ts +27 -7
  91. package/fjs/effects/memory/module.f.d.mts +2 -1
  92. package/fjs/effects/memory/module.f.mjs +3 -4
  93. package/fjs/effects/memory/proof.f.mjs +13 -7
  94. package/fjs/effects/memory/types.d.ts +4 -3
  95. package/fjs/effects/mock/module.f.d.mts +20 -4
  96. package/fjs/effects/mock/module.f.mjs +37 -5
  97. package/fjs/effects/mock/types.d.ts +10 -1
  98. package/fjs/effects/module.d.mts +4 -2
  99. package/fjs/effects/module.f.d.mts +466 -280
  100. package/fjs/effects/module.f.mjs +537 -299
  101. package/fjs/effects/module.mjs +2 -1
  102. package/fjs/effects/node/memory/module.d.mts +4 -2
  103. package/fjs/effects/node/memory/module.mjs +6 -3
  104. package/fjs/effects/node/memory/proof.mjs +10 -4
  105. package/fjs/effects/node/module.d.mts +4 -3
  106. package/fjs/effects/node/module.f.d.mts +168 -33
  107. package/fjs/effects/node/module.f.mjs +256 -52
  108. package/fjs/effects/node/module.mjs +57 -34
  109. package/fjs/effects/node/proof.f.d.mts +28 -2
  110. package/fjs/effects/node/proof.f.mjs +161 -42
  111. package/fjs/effects/node/types.d.ts +106 -18
  112. package/fjs/effects/node/virtual/module.f.d.mts +18 -4
  113. package/fjs/effects/node/virtual/module.f.mjs +110 -68
  114. package/fjs/effects/node/virtual/proof.f.d.mts +28 -2
  115. package/fjs/effects/node/virtual/proof.f.mjs +190 -9
  116. package/fjs/effects/proof.f.d.mts +69 -37
  117. package/fjs/effects/proof.f.mjs +410 -130
  118. package/fjs/effects/types.d.ts +161 -33
  119. package/fjs/emergent_testing/module.f.d.mts +19 -12
  120. package/fjs/emergent_testing/module.f.mjs +93 -33
  121. package/fjs/emergent_testing/proof.f.d.mts +21 -7
  122. package/fjs/emergent_testing/proof.f.mjs +166 -32
  123. package/fjs/emergent_testing/types.d.ts +22 -4
  124. package/fjs/fsm/module.f.d.mts +14 -4
  125. package/fjs/fsm/module.f.mjs +54 -37
  126. package/fjs/fsm/proof.f.d.mts +2 -0
  127. package/fjs/fsm/proof.f.mjs +83 -114
  128. package/fjs/js/keywords/module.f.d.mts +52 -0
  129. package/fjs/js/keywords/module.f.mjs +72 -0
  130. package/fjs/js/keywords/proof.f.d.mts +3 -0
  131. package/fjs/js/keywords/proof.f.mjs +13 -0
  132. package/fjs/js/tokenizer/module.f.d.mts +26 -6
  133. package/fjs/js/tokenizer/module.f.mjs +145 -159
  134. package/fjs/js/tokenizer/proof.f.d.mts +1 -0
  135. package/fjs/js/tokenizer/proof.f.mjs +54 -24
  136. package/fjs/js/tokenizer/types.d.ts +33 -24
  137. package/fjs/mcp/cas/module.f.d.mts +1 -6
  138. package/fjs/mcp/cas/module.f.mjs +55 -51
  139. package/fjs/mcp/cas/proof.f.d.mts +15 -0
  140. package/fjs/mcp/cas/proof.f.mjs +174 -0
  141. package/fjs/mcp/evo/module.f.d.mts +19 -10
  142. package/fjs/mcp/evo/module.f.mjs +48 -27
  143. package/fjs/mcp/evo/proof.f.d.mts +6 -1
  144. package/fjs/mcp/evo/proof.f.mjs +115 -31
  145. package/fjs/mcp/module.f.d.mts +4 -4
  146. package/fjs/mcp/module.f.mjs +6 -6
  147. package/fjs/mcp/proof.f.d.mts +5 -3
  148. package/fjs/mcp/proof.f.mjs +112 -46
  149. package/fjs/media/html/module.f.mjs +1 -1
  150. package/fjs/media/json/extended/module.f.d.mts +82 -0
  151. package/fjs/media/json/extended/module.f.mjs +153 -0
  152. package/fjs/media/json/extended/proof.f.d.mts +42 -0
  153. package/fjs/media/json/extended/proof.f.mjs +127 -0
  154. package/fjs/media/json/extended/types.d.ts +23 -0
  155. package/fjs/media/json/module.f.d.mts +8 -2
  156. package/fjs/media/json/module.f.mjs +43 -41
  157. package/fjs/media/json/number/module.f.d.mts +59 -0
  158. package/fjs/media/json/number/module.f.mjs +136 -0
  159. package/fjs/media/json/number/proof.f.d.mts +24 -0
  160. package/fjs/media/json/number/proof.f.mjs +86 -0
  161. package/fjs/media/json/number/types.d.ts +28 -0
  162. package/fjs/media/json/parser/module.f.d.mts +25 -13
  163. package/fjs/media/json/parser/module.f.mjs +114 -70
  164. package/fjs/media/json/parser/proof.f.d.mts +5 -0
  165. package/fjs/media/json/parser/proof.f.mjs +31 -1
  166. package/fjs/media/json/parser/types.d.ts +33 -14
  167. package/fjs/media/json/rtti/module.f.d.mts +1 -1
  168. package/fjs/media/json/rtti/module.f.mjs +1 -1
  169. package/fjs/media/json/rtti/proof.f.mjs +9 -9
  170. package/fjs/media/json/schema/module.f.mjs +3 -13
  171. package/fjs/media/json/schema/proof.f.d.mts +0 -1
  172. package/fjs/media/json/schema/proof.f.mjs +1 -2
  173. package/fjs/media/json/serializer/module.f.d.mts +32 -1
  174. package/fjs/media/json/serializer/module.f.mjs +64 -2
  175. package/fjs/media/json/tokenizer/module.f.mjs +7 -3
  176. package/fjs/media/json/tokenizer/proof.f.d.mts +6 -0
  177. package/fjs/media/json/tokenizer/proof.f.mjs +62 -21
  178. package/fjs/media/json/types.d.ts +36 -10
  179. package/fjs/media/lock/module.f.d.mts +100 -0
  180. package/fjs/media/lock/module.f.mjs +125 -0
  181. package/fjs/media/lock/proof.f.d.mts +33 -0
  182. package/fjs/media/lock/proof.f.mjs +196 -0
  183. package/fjs/media/lock/types.d.ts +15 -0
  184. package/fjs/media/module.f.d.mts +6 -5
  185. package/fjs/media/module.f.mjs +8 -7
  186. package/fjs/media/note/module.f.d.mts +121 -0
  187. package/fjs/media/note/module.f.mjs +131 -0
  188. package/fjs/media/note/proof.f.d.mts +29 -0
  189. package/fjs/media/note/proof.f.mjs +150 -0
  190. package/fjs/media/note/types.d.ts +10 -0
  191. package/fjs/media/proof.f.d.mts +4 -1
  192. package/fjs/media/proof.f.mjs +40 -21
  193. package/fjs/media/revision/module.f.d.mts +78 -7
  194. package/fjs/media/revision/module.f.mjs +119 -12
  195. package/fjs/media/revision/proof.f.d.mts +10 -0
  196. package/fjs/media/revision/proof.f.mjs +88 -0
  197. package/fjs/media/revision/types.d.ts +34 -5
  198. package/fjs/media/type/module.f.d.mts +33 -15
  199. package/fjs/media/type/module.f.mjs +35 -29
  200. package/fjs/media/type/proof.f.d.mts +2 -1
  201. package/fjs/media/type/proof.f.mjs +30 -10
  202. package/fjs/module.f.mjs +29 -8
  203. package/fjs/nanvm/proof.f.mjs +3 -3
  204. package/fjs/nanvm/rust/module.f.mjs +1 -1
  205. package/fjs/nanvm/update/module.f.d.mts +4 -4
  206. package/fjs/nanvm/update/module.f.mjs +8 -9
  207. package/fjs/nanvm/update/proof.f.mjs +4 -3
  208. package/fjs/proof.f.d.mts +3 -3
  209. package/fjs/proof.f.mjs +36 -10
  210. package/fjs/protocol/json_rpc/module.f.d.mts +2 -2
  211. package/fjs/protocol/json_rpc/module.f.mjs +3 -3
  212. package/fjs/protocol/json_rpc/proof.f.mjs +4 -4
  213. package/fjs/protocol/mcp/module.f.d.mts +10 -13
  214. package/fjs/protocol/mcp/module.f.mjs +74 -58
  215. package/fjs/protocol/mcp/proof.f.d.mts +13 -4
  216. package/fjs/protocol/mcp/proof.f.mjs +193 -61
  217. package/fjs/protocol/mcp/stdio/module.f.d.mts +15 -7
  218. package/fjs/protocol/mcp/stdio/module.f.mjs +38 -25
  219. package/fjs/protocol/mcp/stdio/proof.f.d.mts +4 -2
  220. package/fjs/protocol/mcp/stdio/proof.f.mjs +45 -12
  221. package/fjs/protocol/mcp/stdio/types.d.ts +1 -1
  222. package/fjs/protocol/mcp/types.d.ts +17 -6
  223. package/fjs/sul/id/module.f.d.mts +0 -1
  224. package/fjs/sul/id/module.f.mjs +2 -3
  225. package/fjs/sul/level/hash/module.f.mjs +2 -1
  226. package/fjs/sul/level/hash/proof.f.mjs +2 -2
  227. package/fjs/sul/module.f.mjs +18 -13
  228. package/fjs/text/code_point/module.f.d.mts +8 -0
  229. package/fjs/text/code_point/module.f.mjs +8 -1
  230. package/fjs/text/code_point/proof.f.d.mts +1 -0
  231. package/fjs/text/code_point/proof.f.mjs +11 -0
  232. package/fjs/text/sgr/module.f.d.mts +4 -6
  233. package/fjs/text/sgr/module.f.mjs +6 -7
  234. package/fjs/text/utf16/module.f.mjs +7 -2
  235. package/fjs/text/utf16/proof.f.mjs +3 -3
  236. package/fjs/text/utf8/module.f.mjs +4 -2
  237. package/fjs/types/array/module.f.mjs +14 -2
  238. package/fjs/types/bit_vec/module.f.d.mts +0 -2
  239. package/fjs/types/bit_vec/module.f.mjs +46 -32
  240. package/fjs/types/bit_vec/proof.f.mjs +2 -2
  241. package/fjs/types/btree/remove/module.f.mjs +1 -1
  242. package/fjs/types/btree/set/module.f.mjs +9 -11
  243. package/fjs/types/btree/set/proof.f.mjs +12 -0
  244. package/fjs/types/byte_set/module.f.d.mts +11 -4
  245. package/fjs/types/byte_set/module.f.mjs +14 -6
  246. package/fjs/types/byte_set/proof.f.mjs +7 -7
  247. package/fjs/types/function/compare/module.f.mjs +10 -3
  248. package/fjs/types/list/module.f.d.mts +1 -1
  249. package/fjs/types/list/module.f.mjs +1 -1
  250. package/fjs/types/nullable/module.f.d.mts +18 -4
  251. package/fjs/types/nullable/module.f.mjs +21 -4
  252. package/fjs/types/nullable/proof.f.d.mts +4 -0
  253. package/fjs/types/nullable/proof.f.mjs +15 -0
  254. package/fjs/types/object/module.f.d.mts +12 -2
  255. package/fjs/types/object/module.f.mjs +11 -1
  256. package/fjs/types/patricia_trie/module.f.mjs +26 -11
  257. package/fjs/types/result/module.f.d.mts +3 -3
  258. package/fjs/types/result/module.f.mjs +3 -3
  259. package/fjs/types/rtti/common/module.f.d.mts +25 -28
  260. package/fjs/types/rtti/common/module.f.mjs +36 -32
  261. package/fjs/types/rtti/common/proof.f.mjs +5 -5
  262. package/fjs/types/rtti/data/module.f.d.mts +14 -0
  263. package/fjs/types/rtti/data/module.f.mjs +25 -2
  264. package/fjs/types/rtti/data/proof.f.d.mts +1 -0
  265. package/fjs/types/rtti/data/proof.f.mjs +25 -2
  266. package/fjs/types/rtti/parse/module.f.d.mts +24 -14
  267. package/fjs/types/rtti/parse/module.f.mjs +37 -28
  268. package/fjs/types/rtti/parse/proof.f.d.mts +3 -2
  269. package/fjs/types/rtti/parse/proof.f.mjs +33 -14
  270. package/fjs/types/rtti/proof.f.mjs +3 -1
  271. package/fjs/types/rtti/ts/module.f.mjs +13 -17
  272. package/fjs/types/rtti/ts/types.d.ts +14 -1
  273. package/fjs/types/rtti/validate/module.f.d.mts +81 -19
  274. package/fjs/types/rtti/validate/module.f.mjs +107 -61
  275. package/fjs/types/rtti/validate/proof.f.d.mts +13 -10
  276. package/fjs/types/rtti/validate/proof.f.mjs +186 -197
  277. package/fjs/types/sorted_set/module.f.d.mts +18 -0
  278. package/fjs/types/sorted_set/module.f.mjs +22 -0
  279. package/fjs/types/sorted_set/proof.f.d.mts +1 -0
  280. package/fjs/types/sorted_set/proof.f.mjs +16 -1
  281. package/fjs/types/uint8array/module.f.d.mts +1 -1
  282. package/fjs/types/uint8array/module.f.mjs +1 -1
  283. package/fjs/website/module.f.d.mts +3 -3
  284. package/fjs/website/module.f.mjs +4 -7
  285. package/fjs/website/proof.f.mjs +2 -1
  286. package/package.json +2 -2
  287. package/fjs/dev/package_json/module.f.d.mts +0 -39
  288. package/fjs/dev/package_json/module.f.mjs +0 -40
  289. package/fjs/dev/package_json/proof.f.d.mts +0 -6
  290. package/fjs/dev/package_json/proof.f.mjs +0 -32
  291. package/fjs/effects/eff/module.f.d.mts +0 -20
  292. package/fjs/effects/eff/module.f.mjs +0 -70
  293. package/fjs/effects/eff/proof.f.d.mts +0 -15
  294. package/fjs/effects/eff/proof.f.mjs +0 -69
  295. package/fjs/effects/eff/types.d.ts +0 -71
  296. package/fjs/types/rtti/validate/types.d.ts +0 -6
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * @module
5
5
  *
6
- * @import { WriteFile } from '../effects/node/types.ts'
6
+ * @import { Write, WriteFile } from '../effects/node/types.ts'
7
7
  * @import { Effect } from '../effects/types.ts'
8
8
  */
9
- import type { WriteFile } from '../effects/node/types.ts';
9
+ import type { Write, WriteFile } from '../effects/node/types.ts';
10
10
  import type { Effect } from '../effects/types.ts';
11
- export declare const main: () => Effect<WriteFile, number>;
11
+ export declare const main: () => Effect<Write | WriteFile, 0, number>;
@@ -3,13 +3,12 @@
3
3
  *
4
4
  * @module
5
5
  *
6
- * @import { WriteFile } from '../effects/node/types.ts'
6
+ * @import { Write, WriteFile } from '../effects/node/types.ts'
7
7
  * @import { Effect } from '../effects/types.ts'
8
8
  */
9
9
 
10
10
  import { htmlUtf8 } from '../media/html/module.f.mjs'
11
- import { writeFile } from '../effects/node/module.f.mjs'
12
- import { pure, step } from '../effects/module.f.mjs'
11
+ import { exitStep, writeFile } from '../effects/node/module.f.mjs'
13
12
 
14
13
  const html = htmlUtf8()(
15
14
  ['a',
@@ -17,9 +16,7 @@ const html = htmlUtf8()(
17
16
  'GitHub Repository'
18
17
  ])
19
18
 
20
- /** @type {Effect<WriteFile, number>} */
21
- const program = step(
22
- writeFile('index.html', html),
23
- () => pure(0))
19
+ /** @type {Effect<WriteFile | Write, 0, number>} */
20
+ const program = exitStep(writeFile('index.html', html))
24
21
 
25
22
  export const main = () => program
@@ -1,3 +1,4 @@
1
+ import { exitCode } from '../effects/node/module.f.mjs'
1
2
  import { main } from './module.f.mjs'
2
3
  import { emptyState, virtual } from '../effects/node/virtual/module.f.mjs'
3
4
  import { assertEq, assertNotNullish } from '../asserts/module.f.mjs'
@@ -9,6 +10,6 @@ export const proof = {
9
10
  run: () => {
10
11
  const state = { ...emptyState, root: { '.github': { workflows: {} } } }
11
12
  const [_, result] = virtual(state)(main())
12
- assertEq(result, 0)
13
+ assertEq(exitCode(result), 0)
13
14
  },
14
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.45.0",
3
+ "version": "0.46.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "prepack": "tsc --noEmit false --emitDeclarationOnly && tsc",
14
14
  "test": "tsc && node ./fjs/module.mjs t",
15
- "cov": "node --test --experimental-test-coverage --test-coverage-include=**/module.f.mjs fjs/emergent_testing/all.test.mjs",
15
+ "cov": "node --test --experimental-test-coverage --test-coverage-include=**/module.f.mjs --test-coverage-lines=100 --test-coverage-branches=100 --test-coverage-functions=100",
16
16
  "start": "node ./fjs/module.mjs",
17
17
  "ci-update": "node ./fjs/module.mjs ci && node ./fjs/module.mjs r ./fjs/nanvm/update/module.f.mjs",
18
18
  "dev-update": "node ./fjs/module.mjs r ./fjs/dev/update/module.f.mjs",
@@ -1,39 +0,0 @@
1
- /**
2
- * Helpers for reading package.json-style metadata without losing unrelated
3
- * fields before write-back.
4
- *
5
- * @module
6
- *
7
- * @import { ValidationError } from '../../types/rtti/common/types.ts'
8
- * @import { Ts } from '../../types/rtti/ts/types.ts'
9
- * @import { Result } from '../../types/result/types.ts'
10
- */
11
- import type { ValidationError } from '../../types/rtti/common/types.ts';
12
- import type { Ts } from '../../types/rtti/ts/types.ts';
13
- import type { Result } from '../../types/result/types.ts';
14
- export declare const packageJsonSchema: {
15
- readonly name: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
16
- readonly version: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
17
- readonly scripts: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts").Type1<"record", import("../../types/rtti/types.ts")._Type0<"string">>, undefined]>;
18
- };
19
- export type PackageJson = Ts<typeof packageJsonSchema>;
20
- export type JsonTextError = string | ValidationError;
21
- /** @typedef {Ts<typeof packageJsonSchema>} PackageJson */
22
- /** @typedef {string | ValidationError} JsonTextError */
23
- export declare const validatePackageJson: import("../../types/rtti/common/types.ts").Validate<{
24
- readonly name: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
25
- readonly version: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
26
- readonly scripts: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts").Type1<"record", import("../../types/rtti/types.ts")._Type0<"string">>, undefined]>;
27
- }>;
28
- /**
29
- * Parses `text` as JSON and validates it against {@link packageJsonSchema}.
30
- *
31
- * Both failures reach the caller as they were raised: a parse failure is a
32
- * `string`, a schema failure a `ValidationError`, and `JsonTextError` is
33
- * exactly that union — which is what `okThen` produces from the two steps'
34
- * own error types, with no rewrapping to widen either one.
35
- *
36
- * @param {string} text
37
- * @returns {Result<PackageJson, JsonTextError>}
38
- */
39
- export declare const validatePackageJsonText: (text: string) => Result<PackageJson, JsonTextError>;
@@ -1,40 +0,0 @@
1
- /**
2
- * Helpers for reading package.json-style metadata without losing unrelated
3
- * fields before write-back.
4
- *
5
- * @module
6
- *
7
- * @import { ValidationError } from '../../types/rtti/common/types.ts'
8
- * @import { Ts } from '../../types/rtti/ts/types.ts'
9
- * @import { Result } from '../../types/result/types.ts'
10
- */
11
-
12
- import { parse as parseJsonText } from '../../media/json/module.f.mjs'
13
- import { option, record, string } from '../../types/rtti/module.f.mjs'
14
- import { validate as rttiValidate } from '../../types/rtti/validate/module.f.mjs'
15
- import { okThen } from '../../types/result/module.f.mjs'
16
-
17
- export const packageJsonSchema = /** @type {const} */ ({
18
- name: option(string),
19
- version: option(string),
20
- scripts: option(record(string)),
21
- })
22
-
23
- /** @typedef {Ts<typeof packageJsonSchema>} PackageJson */
24
- /** @typedef {string | ValidationError} JsonTextError */
25
-
26
- export const validatePackageJson = rttiValidate(packageJsonSchema)
27
-
28
- /**
29
- * Parses `text` as JSON and validates it against {@link packageJsonSchema}.
30
- *
31
- * Both failures reach the caller as they were raised: a parse failure is a
32
- * `string`, a schema failure a `ValidationError`, and `JsonTextError` is
33
- * exactly that union — which is what `okThen` produces from the two steps'
34
- * own error types, with no rewrapping to widen either one.
35
- *
36
- * @param {string} text
37
- * @returns {Result<PackageJson, JsonTextError>}
38
- */
39
- export const validatePackageJsonText = text =>
40
- okThen(validatePackageJson)(parseJsonText(text))
@@ -1,6 +0,0 @@
1
- export declare const proof: {
2
- parseMetadata: () => void;
3
- malformedJson: () => void;
4
- validationError: () => void;
5
- validatePreservesOriginalObject: () => void;
6
- };
@@ -1,32 +0,0 @@
1
- import { assert, assertEq } from '../../asserts/module.f.mjs'
2
- import { unwrap } from '../../types/result/module.f.mjs'
3
- import {
4
- validatePackageJson,
5
- validatePackageJsonText,
6
- } from './module.f.mjs'
7
-
8
- export const proof = {
9
- parseMetadata: () => {
10
- const result = unwrap(validatePackageJsonText('{"name":"x","version":"1.0.0","scripts":{"test":"node test.js"}}'))
11
- assertEq(result.name, 'x', result)
12
- assertEq(result.version, '1.0.0', result)
13
- assertEq(result.scripts?.test, 'node test.js', result)
14
- },
15
- malformedJson: () => {
16
- const result = validatePackageJsonText('{')
17
- assert(result[0] === 'error', result)
18
- },
19
- validationError: () => {
20
- // valid JSON but `name` is a number, not a string — validation should fail
21
- const result = validatePackageJsonText('{"name": 42}')
22
- assert(result[0] === 'error', result)
23
- },
24
- validatePreservesOriginalObject: () => {
25
- const object = /** @type {const} */ ({ name: 'x', version: '1.0.0', private: true })
26
- const metadata = unwrap(validatePackageJson(object))
27
- assertEq(metadata.name, 'x', metadata)
28
- assertEq(metadata.version, '1.0.0', metadata)
29
- assert(Object.is(metadata, object), metadata)
30
- assertEq(object.private, true, object)
31
- },
32
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * A fluent, method-chaining wrapper over the raw `Effect`.
3
- *
4
- * See `./types.ts` for the `Eff` type-level API.
5
- *
6
- * @module
7
- *
8
- * @import { Effect, Operation } from '../types.ts'
9
- * @import { Eff } from './types.ts'
10
- */
11
- import type { Effect, Operation } from '../types.ts';
12
- import type { Eff } from './types.ts';
13
- /**
14
- * Wraps a raw {@link Effect}; the bridge into the `Eff` world, with an empty
15
- * history. The empty tuple is spelled out because {@link Eff} deliberately has
16
- * no default for `P` — see its docs.
17
- *
18
- * @type {<O extends Operation, T>(value: Effect<O, T>) => Eff<O, T, readonly[]>}
19
- */
20
- export declare const eff: <O extends Operation, T>(value: Effect<O, T>) => Eff<O, T, readonly []>;
@@ -1,70 +0,0 @@
1
- /**
2
- * A fluent, method-chaining wrapper over the raw `Effect`.
3
- *
4
- * See `./types.ts` for the `Eff` type-level API.
5
- *
6
- * @module
7
- *
8
- * @import { Effect, Operation } from '../types.ts'
9
- * @import { Eff } from './types.ts'
10
- */
11
-
12
- import { history, historyStep, mapStep, pure } from '../module.f.mjs'
13
-
14
- /**
15
- * Builds an `Eff` from two views of the same chain: `value`, the effect for the
16
- * current value alone, and `h`, a thunk for the `[current, ...history]` tuple.
17
- *
18
- * **The two must denote the same computation** — `value` has to be what `h()`
19
- * produces with the history dropped. Nothing enforces it. The
20
- * redundancy is deliberate: `value` used to be derived from `h` on demand,
21
- * which made disagreement impossible but also forced the entry case to rebuild
22
- * an effect it was already holding. Passing it in is what lets {@link eff} hand
23
- * the original back.
24
- *
25
- * The asymmetry between the two — one built, one deferred — is the point.
26
- * `value` is either already in hand ({@link eff} was given it) or already built
27
- * (`.step` has just composed the chain it projects from), so storing it costs
28
- * no more than the projection itself. `h` is different: nothing needs the
29
- * history tuple until a later `.step` asks for it, and composing effects is
30
- * eager, so holding a thunk is the only way to not compose it yet. That keeps
31
- * `eff(e)` free of work entirely.
32
- *
33
- * `.step` calls `h()` once and closes over the effect, so everything built
34
- * from that link shares it. `eff`'s thunk is not memoized, so calling `.step`
35
- * twice on the same `eff(e)` rebuilds and re-forces `e` — harmless under
36
- * `Pure`'s contract, which requires the thunk to be pure and to tolerate
37
- * repeat calls.
38
- *
39
- * @template {Operation} O
40
- * @template T
41
- * @template {readonly unknown[]} P
42
- * @param {Effect<O, T>} value
43
- * @param {() => Effect<O, readonly[T, ...P]>} h
44
- * @returns {Eff<O, T, P>}
45
- */
46
- const create = (value, h) => {
47
- // `self` is named so `.map` can be *defined* as the `.step` call it is
48
- // documented to equal, rather than as a second copy of `.step`'s body that
49
- // has to be re-checked against it.
50
- /** @type {Eff<O, T, P>} */
51
- const self = {
52
- value,
53
- step: f => {
54
- const x1 = historyStep(h(), f)
55
- return create(mapStep(x1, ([t]) => t), () => x1)
56
- },
57
- map: f => self.step((...tp) => pure(f(...tp)))
58
- }
59
- return self
60
- }
61
-
62
- /**
63
- * Wraps a raw {@link Effect}; the bridge into the `Eff` world, with an empty
64
- * history. The empty tuple is spelled out because {@link Eff} deliberately has
65
- * no default for `P` — see its docs.
66
- *
67
- * @type {<O extends Operation, T>(value: Effect<O, T>) => Eff<O, T, readonly[]>}
68
- */
69
- export const eff = value =>
70
- create(value, () => history(value))
@@ -1,15 +0,0 @@
1
- /**
2
- * @import { Effect, OperationMap } from '../types.ts'
3
- */
4
- export type _AddOp = readonly ['add', (a: number, b: number) => number];
5
- export declare const proof: {
6
- value: () => void;
7
- pure: () => void;
8
- chain: () => void;
9
- overDo: () => void;
10
- map: {
11
- chain: () => void;
12
- growsHistory: () => void;
13
- overDo: () => void;
14
- };
15
- };
@@ -1,69 +0,0 @@
1
- /**
2
- * @import { Effect, OperationMap } from '../types.ts'
3
- */
4
-
5
- import { do_, match, pure } from '../module.f.mjs'
6
- import { assert, assertEq } from '../../asserts/module.f.mjs'
7
- import { assertPure } from '../proof.f.mjs'
8
- import { eff } from './module.f.mjs'
9
-
10
- /** @typedef {readonly['add', (a: number, b: number) => number]} _AddOp */
11
-
12
- /** @type {(command: 'add') => (a: number, b: number) => Effect<_AddOp, number>} */
13
- const doAdd = do_
14
-
15
- const next = match(/** @type {OperationMap<_AddOp, number>} */ ({ add: (a, b) => a + b }))
16
-
17
- export const proof = {
18
- value: () => {
19
- assertPure(eff(pure(5)).value, 5)
20
- },
21
- pure: () => {
22
- assertPure(pure(5), 5)
23
- },
24
- chain: () => {
25
- const x = eff(pure(5))
26
- .step(v => pure(v + 1))
27
- .step(v => pure(v * 2))
28
- .value
29
- assertPure(x, 12)
30
- },
31
- overDo: () => {
32
- const e = eff(doAdd('add')(2, 3))
33
- .step(r => pure(r + 1))
34
- .value
35
- const r = next(e)
36
- assert(r[0] === 'cont', r)
37
- assertEq(r[1], 5)
38
- assertPure(r[2](r[1]), 6)
39
- },
40
- map: {
41
- chain: () => {
42
- const x = eff(pure(5))
43
- .map(v => v + 1)
44
- .map(v => v * 2)
45
- .value
46
- assertPure(x, 12)
47
- },
48
- // `.map` grows the history exactly as `.step` does, so a callback after
49
- // it still reaches the pre-`map` value. This is the contract that makes
50
- // rewriting `.step(v => pure(f(v)))` into `.map(f)` a pure readability
51
- // change rather than one that alters what later callbacks receive.
52
- growsHistory: () => {
53
- const x = eff(pure(5))
54
- .map(v => v + 1)
55
- .step((v, prev) => pure(`${prev}${v}`))
56
- .value
57
- assertPure(x, '56')
58
- },
59
- overDo: () => {
60
- const e = eff(doAdd('add')(2, 3))
61
- .map(r => r + 1)
62
- .value
63
- const r = next(e)
64
- assert(r[0] === 'cont', r)
65
- assertEq(r[1], 5)
66
- assertPure(r[2](r[1]), 6)
67
- },
68
- },
69
- }
@@ -1,71 +0,0 @@
1
- /**
2
- * Types for the `Eff` fluent, method-chaining monad.
3
- *
4
- * @module
5
- */
6
- import type { Effect, Operation } from '../types.ts';
7
- /**
8
- * A fluent, method-chaining monad over a raw `Effect` that also
9
- * accumulates the history of every value the chain has produced. `.step(f)`
10
- * is bind — `f` receives the current value followed by every prior value,
11
- * most recent first (`f(t, ...p)`), and returns a raw `Effect`; `.step`
12
- * re-wraps the result together with that history so `.step(f).step(g)`
13
- * chains and stays in the `Eff` world throughout. `.map(f)` is the functor
14
- * map — the same thing for an `f` that returns a plain value rather than an
15
- * effect, so it is exactly `.step((...tp) => pure(f(...tp)))`. `P` is the
16
- * tuple of prior values available to the *next* `.step` call; it grows by one
17
- * element (the current `T`) on every step, starting empty at `eff`.
18
- * `.value` is the exit back to a raw `Effect`, discarding the history. An
19
- * `Eff` is not assignable to `Effect`; unwrap through `.value`.
20
- *
21
- * **`.map` grows the history just as `.step` does, and does not widen `O`.**
22
- * Both follow from it being that `.step` call and nothing else: a chain
23
- * rewritten from `.step(v => pure(f(v)))` to `.map(f)` must hand later
24
- * callbacks the same prior values it did before, and a projection performs no
25
- * command, so it contributes no operation for a runner to interpret.
26
- *
27
- * **The history is positional, so every parameter a callback declares is
28
- * meaningful.** `f` is applied as `f(...tp)`, so a callback written
29
- * `(v, n = 1) => …` or `(v, ...rest) => …` receives prior chain values in `n` /
30
- * `rest` rather than the default or an empty rest — and where the types line up,
31
- * TypeScript will not object. Declare exactly as many parameters as the callback
32
- * intends to read; a defaulted or rest parameter after the current value is a
33
- * bug, not a convenience. This is what makes `.map(g)` a *different* call from
34
- * `.step(v => pure(g(v)))` whenever `g` is not genuinely unary — the lambda
35
- * pins the arity at one, while passing `g` point-free exposes it to the prior
36
- * values, the way `['1', '2', '3'].map(parseInt)` does.
37
- *
38
- * **`.value` is always an already-built `Effect`.** Reading it composes
39
- * nothing: the projection that drops the history tuple to its current value is
40
- * performed by the `.step` that produced the link, not deferred to the read.
41
- * An `Eff` is a record to look into, not an object with a method that quietly
42
- * does work when called.
43
- *
44
- * That costs one projection per link, paid whether or not the link is ever
45
- * unwrapped — an n-link chain builds n of them where a deferred `.result()`
46
- * method would build one. It is a constant factor on construction, with no
47
- * extra forcing of the wrapped effect and no change in growth rate, bought in
48
- * exchange for a uniform rule at the boundary every caller touches.
49
- *
50
- * At the entry it costs nothing at all: `eff(e).value` **is** `e`, because
51
- * `eff` stores what it was handed rather than rebuilding it from the
52
- * history, so wrapping and unwrapping round-trip to identity. `h` is still a
53
- * thunk, so `eff(e)` composes nothing and never forces `e`: an `Eff` that is
54
- * built and only read does no work at all.
55
- *
56
- * **`P` has no default, on purpose.** A default of `readonly[]` would make
57
- * `Eff<O, T>` a spelling that silently erases history: an
58
- * `Eff<O, T, readonly[A]>` is assignable to it, because `f` sits in a
59
- * contravariant position and TypeScript accepts a callback declaring fewer
60
- * parameters than the type it is checked against. The next `.step` callback
61
- * would then be typed as receiving no prior values while the runtime still
62
- * passes them, and any callback destructuring a rest parameter would be handed
63
- * entries its type says cannot exist. Requiring the third argument means that
64
- * erasure cannot be written at all, rather than merely being discouraged;
65
- * `eff` spells `readonly[]` itself.
66
- */
67
- export type Eff<O extends Operation, T, P extends readonly unknown[]> = {
68
- readonly value: Effect<O, T>;
69
- readonly step: <Q extends Operation, R>(f: (...tp: readonly [T, ...P]) => Effect<Q, R>) => Eff<O | Q, R, readonly [T, ...P]>;
70
- readonly map: <R>(f: (...tp: readonly [T, ...P]) => R) => Eff<O, R, readonly [T, ...P]>;
71
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * Type-level API for RTTI validation.
3
- *
4
- * @module
5
- */
6
- export type { Path, Result, Validate, ValidationError } from '../common/types.ts';