effect 4.0.0-beta.30 → 4.0.0-beta.32

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 (514) hide show
  1. package/dist/Array.d.ts +87 -86
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +47 -40
  4. package/dist/Array.js.map +1 -1
  5. package/dist/BigDecimal.d.ts +46 -45
  6. package/dist/BigDecimal.d.ts.map +1 -1
  7. package/dist/BigDecimal.js +35 -38
  8. package/dist/BigDecimal.js.map +1 -1
  9. package/dist/BigInt.d.ts +39 -32
  10. package/dist/BigInt.d.ts.map +1 -1
  11. package/dist/BigInt.js +32 -29
  12. package/dist/BigInt.js.map +1 -1
  13. package/dist/Channel.d.ts +2 -2
  14. package/dist/Channel.d.ts.map +1 -1
  15. package/dist/Channel.js.map +1 -1
  16. package/dist/Chunk.d.ts +58 -57
  17. package/dist/Chunk.d.ts.map +1 -1
  18. package/dist/Chunk.js +20 -21
  19. package/dist/Chunk.js.map +1 -1
  20. package/dist/Config.d.ts.map +1 -1
  21. package/dist/Config.js +4 -1
  22. package/dist/Config.js.map +1 -1
  23. package/dist/Cron.d.ts +3 -6
  24. package/dist/Cron.d.ts.map +1 -1
  25. package/dist/Cron.js +11 -18
  26. package/dist/Cron.js.map +1 -1
  27. package/dist/DateTime.d.ts +49 -92
  28. package/dist/DateTime.d.ts.map +1 -1
  29. package/dist/DateTime.js +9 -9
  30. package/dist/DateTime.js.map +1 -1
  31. package/dist/Deferred.d.ts +7 -5
  32. package/dist/Deferred.d.ts.map +1 -1
  33. package/dist/Deferred.js +7 -5
  34. package/dist/Deferred.js.map +1 -1
  35. package/dist/Duration.d.ts +55 -25
  36. package/dist/Duration.d.ts.map +1 -1
  37. package/dist/Duration.js +100 -70
  38. package/dist/Duration.js.map +1 -1
  39. package/dist/Effect.d.ts.map +1 -1
  40. package/dist/Effect.js +3 -4
  41. package/dist/Effect.js.map +1 -1
  42. package/dist/Fiber.d.ts +2 -1
  43. package/dist/Fiber.d.ts.map +1 -1
  44. package/dist/Fiber.js.map +1 -1
  45. package/dist/FiberHandle.d.ts +9 -8
  46. package/dist/FiberHandle.d.ts.map +1 -1
  47. package/dist/FiberHandle.js +8 -7
  48. package/dist/FiberHandle.js.map +1 -1
  49. package/dist/FiberMap.d.ts +20 -19
  50. package/dist/FiberMap.d.ts.map +1 -1
  51. package/dist/FiberMap.js +6 -6
  52. package/dist/FiberMap.js.map +1 -1
  53. package/dist/FileSystem.d.ts +17 -16
  54. package/dist/FileSystem.d.ts.map +1 -1
  55. package/dist/FileSystem.js +10 -7
  56. package/dist/FileSystem.js.map +1 -1
  57. package/dist/Graph.d.ts +64 -64
  58. package/dist/Graph.d.ts.map +1 -1
  59. package/dist/Graph.js +53 -53
  60. package/dist/Graph.js.map +1 -1
  61. package/dist/HashMap.d.ts +11 -5
  62. package/dist/HashMap.d.ts.map +1 -1
  63. package/dist/HashMap.js +3 -1
  64. package/dist/HashMap.js.map +1 -1
  65. package/dist/Iterable.d.ts +11 -11
  66. package/dist/Iterable.d.ts.map +1 -1
  67. package/dist/Iterable.js +12 -12
  68. package/dist/Iterable.js.map +1 -1
  69. package/dist/Latch.d.ts +69 -3
  70. package/dist/Latch.d.ts.map +1 -1
  71. package/dist/Latch.js +58 -0
  72. package/dist/Latch.js.map +1 -1
  73. package/dist/Layer.d.ts +181 -2
  74. package/dist/Layer.d.ts.map +1 -1
  75. package/dist/Layer.js +35 -2
  76. package/dist/Layer.js.map +1 -1
  77. package/dist/Number.d.ts +74 -18
  78. package/dist/Number.d.ts.map +1 -1
  79. package/dist/Number.js +34 -15
  80. package/dist/Number.js.map +1 -1
  81. package/dist/Option.d.ts +2 -0
  82. package/dist/Option.d.ts.map +1 -1
  83. package/dist/Option.js.map +1 -1
  84. package/dist/PartitionedSemaphore.d.ts +183 -0
  85. package/dist/PartitionedSemaphore.d.ts.map +1 -0
  86. package/dist/PartitionedSemaphore.js +231 -0
  87. package/dist/PartitionedSemaphore.js.map +1 -0
  88. package/dist/PubSub.d.ts +5 -4
  89. package/dist/PubSub.d.ts.map +1 -1
  90. package/dist/PubSub.js +6 -5
  91. package/dist/PubSub.js.map +1 -1
  92. package/dist/Queue.d.ts +3 -3
  93. package/dist/Queue.d.ts.map +1 -1
  94. package/dist/Queue.js +2 -2
  95. package/dist/Queue.js.map +1 -1
  96. package/dist/Record.d.ts +40 -40
  97. package/dist/Record.d.ts.map +1 -1
  98. package/dist/Record.js +16 -15
  99. package/dist/Record.js.map +1 -1
  100. package/dist/Scheduler.d.ts +25 -123
  101. package/dist/Scheduler.d.ts.map +1 -1
  102. package/dist/Scheduler.js +20 -123
  103. package/dist/Scheduler.js.map +1 -1
  104. package/dist/Schema.d.ts +2346 -114
  105. package/dist/Schema.d.ts.map +1 -1
  106. package/dist/Schema.js +1359 -68
  107. package/dist/Schema.js.map +1 -1
  108. package/dist/SchemaAST.d.ts +2 -2
  109. package/dist/SchemaAST.js +2 -2
  110. package/dist/SchemaGetter.js +6 -4
  111. package/dist/SchemaGetter.js.map +1 -1
  112. package/dist/SchemaRepresentation.d.ts +2 -2
  113. package/dist/SchemaRepresentation.d.ts.map +1 -1
  114. package/dist/SchemaRepresentation.js.map +1 -1
  115. package/dist/SchemaTransformation.d.ts.map +1 -1
  116. package/dist/SchemaTransformation.js +32 -27
  117. package/dist/SchemaTransformation.js.map +1 -1
  118. package/dist/Semaphore.d.ts +149 -53
  119. package/dist/Semaphore.d.ts.map +1 -1
  120. package/dist/Semaphore.js +137 -117
  121. package/dist/Semaphore.js.map +1 -1
  122. package/dist/ServiceMap.d.ts +26 -0
  123. package/dist/ServiceMap.d.ts.map +1 -1
  124. package/dist/ServiceMap.js +36 -21
  125. package/dist/ServiceMap.js.map +1 -1
  126. package/dist/Stream.js +1 -1
  127. package/dist/Stream.js.map +1 -1
  128. package/dist/String.d.ts +114 -47
  129. package/dist/String.d.ts.map +1 -1
  130. package/dist/String.js +29 -47
  131. package/dist/String.js.map +1 -1
  132. package/dist/SubscriptionRef.d.ts +1 -2
  133. package/dist/SubscriptionRef.d.ts.map +1 -1
  134. package/dist/SubscriptionRef.js +81 -115
  135. package/dist/SubscriptionRef.js.map +1 -1
  136. package/dist/Terminal.d.ts +2 -1
  137. package/dist/Terminal.d.ts.map +1 -1
  138. package/dist/Terminal.js.map +1 -1
  139. package/dist/Tracer.d.ts +5 -4
  140. package/dist/Tracer.d.ts.map +1 -1
  141. package/dist/Tracer.js +2 -1
  142. package/dist/Tracer.js.map +1 -1
  143. package/dist/Trie.d.ts +26 -14
  144. package/dist/Trie.d.ts.map +1 -1
  145. package/dist/Trie.js +8 -4
  146. package/dist/Trie.js.map +1 -1
  147. package/dist/TxHashMap.d.ts +77 -59
  148. package/dist/TxHashMap.d.ts.map +1 -1
  149. package/dist/TxHashMap.js +25 -19
  150. package/dist/TxHashMap.js.map +1 -1
  151. package/dist/TxSemaphore.d.ts +162 -2
  152. package/dist/TxSemaphore.d.ts.map +1 -1
  153. package/dist/TxSemaphore.js +16 -2
  154. package/dist/TxSemaphore.js.map +1 -1
  155. package/dist/index.d.ts +88 -32
  156. package/dist/index.d.ts.map +1 -1
  157. package/dist/index.js +88 -32
  158. package/dist/index.js.map +1 -1
  159. package/dist/internal/dateTime.js +66 -59
  160. package/dist/internal/dateTime.js.map +1 -1
  161. package/dist/internal/effect.js +21 -90
  162. package/dist/internal/effect.js.map +1 -1
  163. package/dist/internal/hashMap.js +2 -1
  164. package/dist/internal/hashMap.js.map +1 -1
  165. package/dist/internal/option.js +6 -0
  166. package/dist/internal/option.js.map +1 -1
  167. package/dist/internal/trie.js +3 -3
  168. package/dist/internal/trie.js.map +1 -1
  169. package/dist/unstable/ai/AiError.js +1 -1
  170. package/dist/unstable/ai/AiError.js.map +1 -1
  171. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  172. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  173. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  174. package/dist/unstable/ai/Chat.d.ts +3 -4
  175. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  176. package/dist/unstable/ai/Chat.js +2 -2
  177. package/dist/unstable/ai/Chat.js.map +1 -1
  178. package/dist/unstable/ai/LanguageModel.d.ts +30 -16
  179. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  180. package/dist/unstable/ai/LanguageModel.js +10 -87
  181. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  182. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  183. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  184. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  185. package/dist/unstable/ai/Tool.d.ts +14 -0
  186. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  187. package/dist/unstable/ai/Tool.js +13 -0
  188. package/dist/unstable/ai/Tool.js.map +1 -1
  189. package/dist/unstable/cli/Argument.d.ts +2 -4
  190. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  191. package/dist/unstable/cli/Argument.js +1 -3
  192. package/dist/unstable/cli/Argument.js.map +1 -1
  193. package/dist/unstable/cli/CliOutput.d.ts +3 -2
  194. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  195. package/dist/unstable/cli/CliOutput.js +4 -3
  196. package/dist/unstable/cli/CliOutput.js.map +1 -1
  197. package/dist/unstable/cli/Command.d.ts +3 -2
  198. package/dist/unstable/cli/Command.d.ts.map +1 -1
  199. package/dist/unstable/cli/Command.js +3 -3
  200. package/dist/unstable/cli/Command.js.map +1 -1
  201. package/dist/unstable/cli/Completions.d.ts +16 -0
  202. package/dist/unstable/cli/Completions.d.ts.map +1 -0
  203. package/dist/unstable/cli/Completions.js +23 -0
  204. package/dist/unstable/cli/Completions.js.map +1 -0
  205. package/dist/unstable/cli/Flag.d.ts +2 -2
  206. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  207. package/dist/unstable/cli/Flag.js +1 -1
  208. package/dist/unstable/cli/Flag.js.map +1 -1
  209. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
  210. package/dist/unstable/cli/GlobalFlag.js +4 -4
  211. package/dist/unstable/cli/GlobalFlag.js.map +1 -1
  212. package/dist/unstable/cli/HelpDoc.d.ts +14 -12
  213. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  214. package/dist/unstable/cli/Param.d.ts +4 -4
  215. package/dist/unstable/cli/Param.d.ts.map +1 -1
  216. package/dist/unstable/cli/Param.js +7 -7
  217. package/dist/unstable/cli/Param.js.map +1 -1
  218. package/dist/unstable/cli/Primitive.d.ts +1 -1
  219. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  220. package/dist/unstable/cli/Primitive.js.map +1 -1
  221. package/dist/unstable/cli/Prompt.js +71 -67
  222. package/dist/unstable/cli/Prompt.js.map +1 -1
  223. package/dist/unstable/cli/index.d.ts +4 -0
  224. package/dist/unstable/cli/index.d.ts.map +1 -1
  225. package/dist/unstable/cli/index.js +4 -0
  226. package/dist/unstable/cli/index.js.map +1 -1
  227. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
  228. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  229. package/dist/unstable/cli/internal/parser.js +8 -3
  230. package/dist/unstable/cli/internal/parser.js.map +1 -1
  231. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  232. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  233. package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
  234. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  235. package/dist/unstable/cluster/DeliverAt.js +1 -1
  236. package/dist/unstable/cluster/DeliverAt.js.map +1 -1
  237. package/dist/unstable/cluster/Entity.d.ts +3 -2
  238. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  239. package/dist/unstable/cluster/Entity.js +7 -7
  240. package/dist/unstable/cluster/Entity.js.map +1 -1
  241. package/dist/unstable/cluster/Message.d.ts +4 -3
  242. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  243. package/dist/unstable/cluster/Message.js +3 -2
  244. package/dist/unstable/cluster/Message.js.map +1 -1
  245. package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
  246. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  247. package/dist/unstable/cluster/MessageStorage.js +12 -12
  248. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  249. package/dist/unstable/cluster/Reply.d.ts +2 -1
  250. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  251. package/dist/unstable/cluster/Reply.js +4 -3
  252. package/dist/unstable/cluster/Reply.js.map +1 -1
  253. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  254. package/dist/unstable/cluster/RunnerServer.js +9 -8
  255. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  256. package/dist/unstable/cluster/Runners.d.ts +2 -1
  257. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  258. package/dist/unstable/cluster/Runners.js +7 -6
  259. package/dist/unstable/cluster/Runners.js.map +1 -1
  260. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  261. package/dist/unstable/cluster/Sharding.js +19 -13
  262. package/dist/unstable/cluster/Sharding.js.map +1 -1
  263. package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
  264. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  265. package/dist/unstable/cluster/ShardingConfig.js +4 -4
  266. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  267. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  268. package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
  269. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  270. package/dist/unstable/cluster/internal/entityManager.js +9 -10
  271. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  272. package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
  273. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  274. package/dist/unstable/devtools/DevToolsSchema.js +1 -4
  275. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  276. package/dist/unstable/encoding/Ndjson.d.ts +8 -8
  277. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  278. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  279. package/dist/unstable/http/Cookies.d.ts +5 -4
  280. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  281. package/dist/unstable/http/Cookies.js +3 -4
  282. package/dist/unstable/http/Cookies.js.map +1 -1
  283. package/dist/unstable/http/Etag.d.ts.map +1 -1
  284. package/dist/unstable/http/Etag.js +5 -1
  285. package/dist/unstable/http/Etag.js.map +1 -1
  286. package/dist/unstable/http/Headers.d.ts +3 -2
  287. package/dist/unstable/http/Headers.d.ts.map +1 -1
  288. package/dist/unstable/http/Headers.js +2 -1
  289. package/dist/unstable/http/Headers.js.map +1 -1
  290. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  291. package/dist/unstable/http/HttpClient.js +2 -1
  292. package/dist/unstable/http/HttpClient.js.map +1 -1
  293. package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
  294. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  295. package/dist/unstable/http/HttpClientRequest.js +8 -6
  296. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  297. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  298. package/dist/unstable/http/HttpClientResponse.js +2 -1
  299. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  300. package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
  301. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  302. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  303. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  304. package/dist/unstable/http/HttpMiddleware.js +16 -15
  305. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  306. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  307. package/dist/unstable/http/HttpPlatform.js +3 -2
  308. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  309. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  310. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  311. package/dist/unstable/http/HttpRouter.js +7 -7
  312. package/dist/unstable/http/HttpRouter.js.map +1 -1
  313. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  314. package/dist/unstable/http/HttpServer.js +2 -2
  315. package/dist/unstable/http/HttpServer.js.map +1 -1
  316. package/dist/unstable/http/HttpServerError.d.ts +2 -1
  317. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  318. package/dist/unstable/http/HttpServerError.js +2 -1
  319. package/dist/unstable/http/HttpServerError.js.map +1 -1
  320. package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
  321. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  322. package/dist/unstable/http/HttpServerRequest.js +14 -10
  323. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  324. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  325. package/dist/unstable/http/HttpServerResponse.js +4 -3
  326. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  327. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  328. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  329. package/dist/unstable/http/HttpTraceContext.js +27 -15
  330. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  331. package/dist/unstable/http/UrlParams.d.ts +5 -4
  332. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  333. package/dist/unstable/http/UrlParams.js +5 -6
  334. package/dist/unstable/http/UrlParams.js.map +1 -1
  335. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +2 -2
  336. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  337. package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
  338. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  339. package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
  340. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  341. package/dist/unstable/httpapi/HttpApiError.js +81 -3
  342. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  343. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  344. package/dist/unstable/observability/OtlpExporter.js +2 -2
  345. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  346. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  347. package/dist/unstable/observability/OtlpTracer.js +7 -3
  348. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  349. package/dist/unstable/persistence/Persistable.js +1 -1
  350. package/dist/unstable/persistence/Persistable.js.map +1 -1
  351. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  352. package/dist/unstable/reactivity/Atom.js +1 -5
  353. package/dist/unstable/reactivity/Atom.js.map +1 -1
  354. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  355. package/dist/unstable/reactivity/AtomRegistry.js +4 -2
  356. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  357. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  358. package/dist/unstable/rpc/Rpc.js +4 -3
  359. package/dist/unstable/rpc/Rpc.js.map +1 -1
  360. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  361. package/dist/unstable/rpc/RpcClient.js +4 -4
  362. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  363. package/dist/unstable/rpc/RpcGroup.d.ts +1 -3
  364. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  365. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  366. package/dist/unstable/rpc/RpcSchema.js +3 -2
  367. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  368. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  369. package/dist/unstable/rpc/RpcSerialization.js +4 -1
  370. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  371. package/dist/unstable/rpc/RpcServer.d.ts +1 -1
  372. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  373. package/dist/unstable/rpc/RpcServer.js +3 -2
  374. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  375. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  376. package/dist/unstable/socket/Socket.js +2 -1
  377. package/dist/unstable/socket/Socket.js.map +1 -1
  378. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  379. package/dist/unstable/sql/SqlClient.js +1 -1
  380. package/dist/unstable/sql/SqlClient.js.map +1 -1
  381. package/dist/unstable/workflow/DurableDeferred.js +6 -6
  382. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  383. package/dist/unstable/workflow/Workflow.d.ts +2 -1
  384. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  385. package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
  386. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  387. package/dist/unstable/workflow/WorkflowEngine.js +19 -14
  388. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  389. package/package.json +1 -1
  390. package/src/Array.ts +112 -105
  391. package/src/BigDecimal.ts +63 -66
  392. package/src/BigInt.ts +49 -41
  393. package/src/Channel.ts +3 -3
  394. package/src/Chunk.ts +68 -63
  395. package/src/Config.ts +4 -1
  396. package/src/Cron.ts +13 -18
  397. package/src/DateTime.ts +51 -92
  398. package/src/Deferred.ts +8 -6
  399. package/src/Duration.ts +112 -56
  400. package/src/Effect.ts +3 -4
  401. package/src/Fiber.ts +2 -1
  402. package/src/FiberHandle.ts +10 -9
  403. package/src/FiberMap.ts +22 -22
  404. package/src/FileSystem.ts +25 -22
  405. package/src/Graph.ts +105 -105
  406. package/src/HashMap.ts +11 -5
  407. package/src/Iterable.ts +13 -13
  408. package/src/Latch.ts +85 -3
  409. package/src/Layer.ts +244 -19
  410. package/src/Number.ts +85 -26
  411. package/src/Option.ts +2 -0
  412. package/src/PartitionedSemaphore.ts +414 -0
  413. package/src/PubSub.ts +7 -6
  414. package/src/Queue.ts +5 -5
  415. package/src/Record.ts +52 -47
  416. package/src/Scheduler.ts +37 -126
  417. package/src/Schema.ts +2366 -116
  418. package/src/SchemaAST.ts +2 -2
  419. package/src/SchemaGetter.ts +4 -4
  420. package/src/SchemaRepresentation.ts +2 -2
  421. package/src/SchemaTransformation.ts +27 -27
  422. package/src/Semaphore.ts +271 -183
  423. package/src/ServiceMap.ts +83 -31
  424. package/src/Stream.ts +1 -1
  425. package/src/String.ts +122 -69
  426. package/src/SubscriptionRef.ts +96 -117
  427. package/src/Terminal.ts +2 -1
  428. package/src/Tracer.ts +6 -5
  429. package/src/Trie.ts +26 -14
  430. package/src/TxHashMap.ts +78 -60
  431. package/src/TxSemaphore.ts +186 -11
  432. package/src/index.ts +89 -33
  433. package/src/internal/dateTime.ts +74 -65
  434. package/src/internal/effect.ts +30 -122
  435. package/src/internal/hashMap.ts +4 -3
  436. package/src/internal/option.ts +7 -0
  437. package/src/internal/trie.ts +6 -6
  438. package/src/unstable/ai/AiError.ts +1 -1
  439. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  440. package/src/unstable/ai/Chat.ts +17 -15
  441. package/src/unstable/ai/LanguageModel.ts +148 -97
  442. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  443. package/src/unstable/ai/Tool.ts +20 -0
  444. package/src/unstable/cli/Argument.ts +2 -4
  445. package/src/unstable/cli/CliOutput.ts +7 -5
  446. package/src/unstable/cli/Command.ts +5 -5
  447. package/src/unstable/cli/Completions.ts +36 -0
  448. package/src/unstable/cli/Flag.ts +2 -2
  449. package/src/unstable/cli/GlobalFlag.ts +4 -5
  450. package/src/unstable/cli/HelpDoc.ts +14 -12
  451. package/src/unstable/cli/Param.ts +15 -11
  452. package/src/unstable/cli/Primitive.ts +1 -1
  453. package/src/unstable/cli/Prompt.ts +81 -83
  454. package/src/unstable/cli/index.ts +5 -0
  455. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
  456. package/src/unstable/cli/internal/parser.ts +7 -4
  457. package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
  458. package/src/unstable/cluster/DeliverAt.ts +1 -1
  459. package/src/unstable/cluster/Entity.ts +13 -12
  460. package/src/unstable/cluster/Message.ts +6 -5
  461. package/src/unstable/cluster/MessageStorage.ts +26 -25
  462. package/src/unstable/cluster/Reply.ts +7 -4
  463. package/src/unstable/cluster/RunnerServer.ts +10 -13
  464. package/src/unstable/cluster/Runners.ts +8 -7
  465. package/src/unstable/cluster/Sharding.ts +24 -17
  466. package/src/unstable/cluster/ShardingConfig.ts +6 -6
  467. package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
  468. package/src/unstable/cluster/internal/entityManager.ts +27 -21
  469. package/src/unstable/devtools/DevToolsSchema.ts +3 -2
  470. package/src/unstable/encoding/Ndjson.ts +17 -17
  471. package/src/unstable/http/Cookies.ts +7 -8
  472. package/src/unstable/http/Etag.ts +5 -3
  473. package/src/unstable/http/Headers.ts +6 -5
  474. package/src/unstable/http/HttpClient.ts +2 -1
  475. package/src/unstable/http/HttpClientRequest.ts +11 -9
  476. package/src/unstable/http/HttpClientResponse.ts +5 -4
  477. package/src/unstable/http/HttpIncomingMessage.ts +3 -2
  478. package/src/unstable/http/HttpMiddleware.ts +16 -15
  479. package/src/unstable/http/HttpPlatform.ts +3 -2
  480. package/src/unstable/http/HttpRouter.ts +9 -9
  481. package/src/unstable/http/HttpServer.ts +3 -9
  482. package/src/unstable/http/HttpServerError.ts +3 -2
  483. package/src/unstable/http/HttpServerRequest.ts +29 -25
  484. package/src/unstable/http/HttpServerResponse.ts +7 -6
  485. package/src/unstable/http/HttpTraceContext.ts +31 -17
  486. package/src/unstable/http/UrlParams.ts +11 -14
  487. package/src/unstable/httpapi/HttpApiBuilder.ts +13 -7
  488. package/src/unstable/httpapi/HttpApiError.ts +67 -12
  489. package/src/unstable/observability/OtlpExporter.ts +5 -2
  490. package/src/unstable/observability/OtlpTracer.ts +8 -4
  491. package/src/unstable/persistence/Persistable.ts +1 -1
  492. package/src/unstable/reactivity/Atom.ts +1 -4
  493. package/src/unstable/reactivity/AtomRegistry.ts +5 -3
  494. package/src/unstable/rpc/Rpc.ts +4 -3
  495. package/src/unstable/rpc/RpcClient.ts +10 -9
  496. package/src/unstable/rpc/RpcGroup.ts +3 -3
  497. package/src/unstable/rpc/RpcSchema.ts +6 -5
  498. package/src/unstable/rpc/RpcSerialization.ts +4 -1
  499. package/src/unstable/rpc/RpcServer.ts +3 -3
  500. package/src/unstable/socket/Socket.ts +2 -1
  501. package/src/unstable/sql/SqlClient.ts +5 -3
  502. package/src/unstable/workflow/DurableDeferred.ts +6 -6
  503. package/src/unstable/workflow/Workflow.ts +1 -1
  504. package/src/unstable/workflow/WorkflowEngine.ts +29 -20
  505. package/dist/NullOr.d.ts +0 -149
  506. package/dist/NullOr.d.ts.map +0 -1
  507. package/dist/NullOr.js +0 -152
  508. package/dist/NullOr.js.map +0 -1
  509. package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
  510. package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
  511. package/dist/unstable/cli/internal/completions/Completions.js +0 -23
  512. package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
  513. package/src/NullOr.ts +0 -204
  514. package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/src/Array.ts CHANGED
@@ -1767,18 +1767,18 @@ export const last = <A>(self: ReadonlyArray<A>): Option.Option<A> =>
1767
1767
  export const lastNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): A => self[self.length - 1]
1768
1768
 
1769
1769
  /**
1770
- * Returns all elements except the first, or `undefined` if the array is empty.
1770
+ * Returns all elements except the first, wrapped in an `Option`.
1771
1771
  *
1772
1772
  * - Allocates a new array via `slice(1)`.
1773
- * - Returns `undefined` (not `Option`) for empty inputs.
1773
+ * - Returns `Option.none()` for empty inputs.
1774
1774
  *
1775
1775
  * **Example** (Getting the tail)
1776
1776
  *
1777
1777
  * ```ts
1778
1778
  * import { Array } from "effect"
1779
1779
  *
1780
- * console.log(Array.tail([1, 2, 3, 4])) // [2, 3, 4]
1781
- * console.log(Array.tail([])) // undefined
1780
+ * console.log(Array.tail([1, 2, 3, 4])) // Option.some([2, 3, 4])
1781
+ * console.log(Array.tail([])) // Option.none()
1782
1782
  * ```
1783
1783
  *
1784
1784
  * @see {@link tailNonEmpty} — when the array is known non-empty
@@ -1787,9 +1787,9 @@ export const lastNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): A => self[self.
1787
1787
  * @category getters
1788
1788
  * @since 2.0.0
1789
1789
  */
1790
- export function tail<A>(self: Iterable<A>): Array<A> | undefined {
1790
+ export function tail<A>(self: Iterable<A>): Option.Option<Array<A>> {
1791
1791
  const as = fromIterable(self)
1792
- return isReadonlyArrayNonEmpty(as) ? tailNonEmpty(as) : undefined
1792
+ return isReadonlyArrayNonEmpty(as) ? Option.some(tailNonEmpty(as)) : Option.none()
1793
1793
  }
1794
1794
 
1795
1795
  /**
@@ -1812,18 +1812,18 @@ export function tail<A>(self: Iterable<A>): Array<A> | undefined {
1812
1812
  export const tailNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): Array<A> => self.slice(1)
1813
1813
 
1814
1814
  /**
1815
- * Returns all elements except the last, or `undefined` if the array is empty.
1815
+ * Returns all elements except the last, wrapped in an `Option`.
1816
1816
  *
1817
1817
  * - Allocates a new array via `slice(0, -1)`.
1818
- * - Returns `undefined` (not `Option`) for empty inputs.
1818
+ * - Returns `Option.none()` for empty inputs.
1819
1819
  *
1820
1820
  * **Example** (Getting init)
1821
1821
  *
1822
1822
  * ```ts
1823
1823
  * import { Array } from "effect"
1824
1824
  *
1825
- * console.log(Array.init([1, 2, 3, 4])) // [1, 2, 3]
1826
- * console.log(Array.init([])) // undefined
1825
+ * console.log(Array.init([1, 2, 3, 4])) // Option.some([1, 2, 3])
1826
+ * console.log(Array.init([])) // Option.none()
1827
1827
  * ```
1828
1828
  *
1829
1829
  * @see {@link initNonEmpty} — when the array is known non-empty
@@ -1832,9 +1832,9 @@ export const tailNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): Array<A> => sel
1832
1832
  * @category getters
1833
1833
  * @since 2.0.0
1834
1834
  */
1835
- export function init<A>(self: Iterable<A>): Array<A> | undefined {
1835
+ export function init<A>(self: Iterable<A>): Option.Option<Array<A>> {
1836
1836
  const as = fromIterable(self)
1837
- return isReadonlyArrayNonEmpty(as) ? initNonEmpty(as) : undefined
1837
+ return isReadonlyArrayNonEmpty(as) ? Option.some(initNonEmpty(as)) : Option.none()
1838
1838
  }
1839
1839
 
1840
1840
  /**
@@ -2564,15 +2564,15 @@ export const dropWhileFilter: {
2564
2564
  )
2565
2565
 
2566
2566
  /**
2567
- * Returns the index of the first element matching the predicate, or `undefined`
2568
- * if none match.
2567
+ * Returns the index of the first element matching the predicate, wrapped in an
2568
+ * `Option`.
2569
2569
  *
2570
2570
  * **Example** (Finding an index)
2571
2571
  *
2572
2572
  * ```ts
2573
2573
  * import { Array } from "effect"
2574
2574
  *
2575
- * console.log(Array.findFirstIndex([5, 3, 8, 9], (x) => x > 5)) // 2
2575
+ * console.log(Array.findFirstIndex([5, 3, 8, 9], (x) => x > 5)) // Option.some(2)
2576
2576
  * ```
2577
2577
  *
2578
2578
  * @see {@link findLastIndex} — search from the end
@@ -2583,15 +2583,15 @@ export const dropWhileFilter: {
2583
2583
  */
2584
2584
  export const findFirstIndex: {
2585
2585
  /**
2586
- * Returns the index of the first element matching the predicate, or `undefined`
2587
- * if none match.
2586
+ * Returns the index of the first element matching the predicate, wrapped in an
2587
+ * `Option`.
2588
2588
  *
2589
2589
  * **Example** (Finding an index)
2590
2590
  *
2591
2591
  * ```ts
2592
2592
  * import { Array } from "effect"
2593
2593
  *
2594
- * console.log(Array.findFirstIndex([5, 3, 8, 9], (x) => x > 5)) // 2
2594
+ * console.log(Array.findFirstIndex([5, 3, 8, 9], (x) => x > 5)) // Option.some(2)
2595
2595
  * ```
2596
2596
  *
2597
2597
  * @see {@link findLastIndex} — search from the end
@@ -2600,17 +2600,17 @@ export const findFirstIndex: {
2600
2600
  * @category elements
2601
2601
  * @since 2.0.0
2602
2602
  */
2603
- <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => number | undefined
2603
+ <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option.Option<number>
2604
2604
  /**
2605
- * Returns the index of the first element matching the predicate, or `undefined`
2606
- * if none match.
2605
+ * Returns the index of the first element matching the predicate, wrapped in an
2606
+ * `Option`.
2607
2607
  *
2608
2608
  * **Example** (Finding an index)
2609
2609
  *
2610
2610
  * ```ts
2611
2611
  * import { Array } from "effect"
2612
2612
  *
2613
- * console.log(Array.findFirstIndex([5, 3, 8, 9], (x) => x > 5)) // 2
2613
+ * console.log(Array.findFirstIndex([5, 3, 8, 9], (x) => x > 5)) // Option.some(2)
2614
2614
  * ```
2615
2615
  *
2616
2616
  * @see {@link findLastIndex} — search from the end
@@ -2619,27 +2619,28 @@ export const findFirstIndex: {
2619
2619
  * @category elements
2620
2620
  * @since 2.0.0
2621
2621
  */
2622
- <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): number | undefined
2623
- } = dual(2, <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): number | undefined => {
2622
+ <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option.Option<number>
2623
+ } = dual(2, <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option.Option<number> => {
2624
2624
  let i = 0
2625
2625
  for (const a of self) {
2626
2626
  if (predicate(a, i)) {
2627
- return i
2627
+ return Option.some(i)
2628
2628
  }
2629
2629
  i++
2630
2630
  }
2631
+ return Option.none()
2631
2632
  })
2632
2633
 
2633
2634
  /**
2634
- * Returns the index of the last element matching the predicate, or `undefined`
2635
- * if none match.
2635
+ * Returns the index of the last element matching the predicate, wrapped in an
2636
+ * `Option`.
2636
2637
  *
2637
2638
  * **Example** (Finding the last matching index)
2638
2639
  *
2639
2640
  * ```ts
2640
2641
  * import { Array } from "effect"
2641
2642
  *
2642
- * console.log(Array.findLastIndex([1, 3, 8, 9], (x) => x < 5)) // 1
2643
+ * console.log(Array.findLastIndex([1, 3, 8, 9], (x) => x < 5)) // Option.some(1)
2643
2644
  * ```
2644
2645
  *
2645
2646
  * @see {@link findFirstIndex} — search from the start
@@ -2650,15 +2651,15 @@ export const findFirstIndex: {
2650
2651
  */
2651
2652
  export const findLastIndex: {
2652
2653
  /**
2653
- * Returns the index of the last element matching the predicate, or `undefined`
2654
- * if none match.
2654
+ * Returns the index of the last element matching the predicate, wrapped in an
2655
+ * `Option`.
2655
2656
  *
2656
2657
  * **Example** (Finding the last matching index)
2657
2658
  *
2658
2659
  * ```ts
2659
2660
  * import { Array } from "effect"
2660
2661
  *
2661
- * console.log(Array.findLastIndex([1, 3, 8, 9], (x) => x < 5)) // 1
2662
+ * console.log(Array.findLastIndex([1, 3, 8, 9], (x) => x < 5)) // Option.some(1)
2662
2663
  * ```
2663
2664
  *
2664
2665
  * @see {@link findFirstIndex} — search from the start
@@ -2667,17 +2668,17 @@ export const findLastIndex: {
2667
2668
  * @category elements
2668
2669
  * @since 2.0.0
2669
2670
  */
2670
- <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => number | undefined
2671
+ <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option.Option<number>
2671
2672
  /**
2672
- * Returns the index of the last element matching the predicate, or `undefined`
2673
- * if none match.
2673
+ * Returns the index of the last element matching the predicate, wrapped in an
2674
+ * `Option`.
2674
2675
  *
2675
2676
  * **Example** (Finding the last matching index)
2676
2677
  *
2677
2678
  * ```ts
2678
2679
  * import { Array } from "effect"
2679
2680
  *
2680
- * console.log(Array.findLastIndex([1, 3, 8, 9], (x) => x < 5)) // 1
2681
+ * console.log(Array.findLastIndex([1, 3, 8, 9], (x) => x < 5)) // Option.some(1)
2681
2682
  * ```
2682
2683
  *
2683
2684
  * @see {@link findFirstIndex} — search from the start
@@ -2686,14 +2687,15 @@ export const findLastIndex: {
2686
2687
  * @category elements
2687
2688
  * @since 2.0.0
2688
2689
  */
2689
- <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): number | undefined
2690
- } = dual(2, <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): number | undefined => {
2690
+ <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option.Option<number>
2691
+ } = dual(2, <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option.Option<number> => {
2691
2692
  const input = fromIterable(self)
2692
2693
  for (let i = input.length - 1; i >= 0; i--) {
2693
2694
  if (predicate(input[i], i)) {
2694
- return i
2695
+ return Option.some(i)
2695
2696
  }
2696
2697
  }
2698
+ return Option.none()
2697
2699
  })
2698
2700
 
2699
2701
  /**
@@ -2868,14 +2870,14 @@ export const findFirst: {
2868
2870
 
2869
2871
  /**
2870
2872
  * Returns a tuple `[element, index]` of the first element matching a
2871
- * predicate, or `undefined` if none match.
2873
+ * predicate, wrapped in an `Option`.
2872
2874
  *
2873
2875
  * **Example** (Finding element with its index)
2874
2876
  *
2875
2877
  * ```ts
2876
2878
  * import { Array } from "effect"
2877
2879
  *
2878
- * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // [4, 3]
2880
+ * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // Option.some([4, 3])
2879
2881
  * ```
2880
2882
  *
2881
2883
  * @see {@link findFirst} — get only the element
@@ -2887,14 +2889,14 @@ export const findFirst: {
2887
2889
  export const findFirstWithIndex: {
2888
2890
  /**
2889
2891
  * Returns a tuple `[element, index]` of the first element matching a
2890
- * predicate, or `undefined` if none match.
2892
+ * predicate, wrapped in an `Option`.
2891
2893
  *
2892
2894
  * **Example** (Finding element with its index)
2893
2895
  *
2894
2896
  * ```ts
2895
2897
  * import { Array } from "effect"
2896
2898
  *
2897
- * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // [4, 3]
2899
+ * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // Option.some([4, 3])
2898
2900
  * ```
2899
2901
  *
2900
2902
  * @see {@link findFirst} — get only the element
@@ -2903,17 +2905,17 @@ export const findFirstWithIndex: {
2903
2905
  * @category elements
2904
2906
  * @since 3.17.0
2905
2907
  */
2906
- <A, B>(f: (a: NoInfer<A>, i: number) => Option.Option<B>): (self: Iterable<A>) => [B, number] | undefined
2908
+ <A, B>(f: (a: NoInfer<A>, i: number) => Option.Option<B>): (self: Iterable<A>) => Option.Option<[B, number]>
2907
2909
  /**
2908
2910
  * Returns a tuple `[element, index]` of the first element matching a
2909
- * predicate, or `undefined` if none match.
2911
+ * predicate, wrapped in an `Option`.
2910
2912
  *
2911
2913
  * **Example** (Finding element with its index)
2912
2914
  *
2913
2915
  * ```ts
2914
2916
  * import { Array } from "effect"
2915
2917
  *
2916
- * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // [4, 3]
2918
+ * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // Option.some([4, 3])
2917
2919
  * ```
2918
2920
  *
2919
2921
  * @see {@link findFirst} — get only the element
@@ -2922,17 +2924,17 @@ export const findFirstWithIndex: {
2922
2924
  * @category elements
2923
2925
  * @since 3.17.0
2924
2926
  */
2925
- <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => [B, number] | undefined
2927
+ <A, B extends A>(refinement: (a: NoInfer<A>, i: number) => a is B): (self: Iterable<A>) => Option.Option<[B, number]>
2926
2928
  /**
2927
2929
  * Returns a tuple `[element, index]` of the first element matching a
2928
- * predicate, or `undefined` if none match.
2930
+ * predicate, wrapped in an `Option`.
2929
2931
  *
2930
2932
  * **Example** (Finding element with its index)
2931
2933
  *
2932
2934
  * ```ts
2933
2935
  * import { Array } from "effect"
2934
2936
  *
2935
- * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // [4, 3]
2937
+ * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // Option.some([4, 3])
2936
2938
  * ```
2937
2939
  *
2938
2940
  * @see {@link findFirst} — get only the element
@@ -2941,17 +2943,17 @@ export const findFirstWithIndex: {
2941
2943
  * @category elements
2942
2944
  * @since 3.17.0
2943
2945
  */
2944
- <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => [A, number] | undefined
2946
+ <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => Option.Option<[A, number]>
2945
2947
  /**
2946
2948
  * Returns a tuple `[element, index]` of the first element matching a
2947
- * predicate, or `undefined` if none match.
2949
+ * predicate, wrapped in an `Option`.
2948
2950
  *
2949
2951
  * **Example** (Finding element with its index)
2950
2952
  *
2951
2953
  * ```ts
2952
2954
  * import { Array } from "effect"
2953
2955
  *
2954
- * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // [4, 3]
2956
+ * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // Option.some([4, 3])
2955
2957
  * ```
2956
2958
  *
2957
2959
  * @see {@link findFirst} — get only the element
@@ -2960,17 +2962,17 @@ export const findFirstWithIndex: {
2960
2962
  * @category elements
2961
2963
  * @since 3.17.0
2962
2964
  */
2963
- <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option.Option<B>): [B, number] | undefined
2965
+ <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option.Option<B>): Option.Option<[B, number]>
2964
2966
  /**
2965
2967
  * Returns a tuple `[element, index]` of the first element matching a
2966
- * predicate, or `undefined` if none match.
2968
+ * predicate, wrapped in an `Option`.
2967
2969
  *
2968
2970
  * **Example** (Finding element with its index)
2969
2971
  *
2970
2972
  * ```ts
2971
2973
  * import { Array } from "effect"
2972
2974
  *
2973
- * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // [4, 3]
2975
+ * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // Option.some([4, 3])
2974
2976
  * ```
2975
2977
  *
2976
2978
  * @see {@link findFirst} — get only the element
@@ -2979,17 +2981,17 @@ export const findFirstWithIndex: {
2979
2981
  * @category elements
2980
2982
  * @since 3.17.0
2981
2983
  */
2982
- <A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): [B, number] | undefined
2984
+ <A, B extends A>(self: Iterable<A>, refinement: (a: A, i: number) => a is B): Option.Option<[B, number]>
2983
2985
  /**
2984
2986
  * Returns a tuple `[element, index]` of the first element matching a
2985
- * predicate, or `undefined` if none match.
2987
+ * predicate, wrapped in an `Option`.
2986
2988
  *
2987
2989
  * **Example** (Finding element with its index)
2988
2990
  *
2989
2991
  * ```ts
2990
2992
  * import { Array } from "effect"
2991
2993
  *
2992
- * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // [4, 3]
2994
+ * console.log(Array.findFirstWithIndex([1, 2, 3, 4, 5], (x) => x > 3)) // Option.some([4, 3])
2993
2995
  * ```
2994
2996
  *
2995
2997
  * @see {@link findFirst} — get only the element
@@ -2998,27 +3000,28 @@ export const findFirstWithIndex: {
2998
3000
  * @category elements
2999
3001
  * @since 3.17.0
3000
3002
  */
3001
- <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): [A, number] | undefined
3003
+ <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): Option.Option<[A, number]>
3002
3004
  } = dual(
3003
3005
  2,
3004
3006
  <A>(
3005
3007
  self: Iterable<A>,
3006
3008
  f: ((a: A, i: number) => boolean) | ((a: A, i: number) => Option.Option<A>)
3007
- ): [A, number] | undefined => {
3009
+ ): Option.Option<[A, number]> => {
3008
3010
  let i = 0
3009
3011
  for (const a of self) {
3010
3012
  const o = f(a, i)
3011
3013
  if (typeof o === "boolean") {
3012
3014
  if (o) {
3013
- return [a, i]
3015
+ return Option.some([a, i])
3014
3016
  }
3015
3017
  } else {
3016
3018
  if (Option.isSome(o)) {
3017
- return [o.value, i]
3019
+ return Option.some([o.value, i])
3018
3020
  }
3019
3021
  }
3020
3022
  i++
3021
3023
  }
3024
+ return Option.none()
3022
3025
  }
3023
3026
  )
3024
3027
 
@@ -3201,8 +3204,8 @@ export const findLast: {
3201
3204
  )
3202
3205
 
3203
3206
  /**
3204
- * Inserts an element at the specified index, returning a new `NonEmptyArray`,
3205
- * or `undefined` if the index is out of bounds.
3207
+ * Inserts an element at the specified index, returning a new `NonEmptyArray`
3208
+ * wrapped in an `Option`.
3206
3209
  *
3207
3210
  * - Valid indices: `0` to `length` (inclusive — inserting at `length` appends).
3208
3211
  * - Does not mutate the input.
@@ -3212,7 +3215,7 @@ export const findLast: {
3212
3215
  * ```ts
3213
3216
  * import { Array } from "effect"
3214
3217
  *
3215
- * console.log(Array.insertAt(["a", "b", "c", "e"], 3, "d")) // ["a", "b", "c", "d", "e"]
3218
+ * console.log(Array.insertAt(["a", "b", "c", "e"], 3, "d")) // Option.some(["a", "b", "c", "d", "e"])
3216
3219
  * ```
3217
3220
  *
3218
3221
  * @see {@link replace} — replace an existing element
@@ -3223,8 +3226,8 @@ export const findLast: {
3223
3226
  */
3224
3227
  export const insertAt: {
3225
3228
  /**
3226
- * Inserts an element at the specified index, returning a new `NonEmptyArray`,
3227
- * or `undefined` if the index is out of bounds.
3229
+ * Inserts an element at the specified index, returning a new `NonEmptyArray`
3230
+ * wrapped in an `Option`.
3228
3231
  *
3229
3232
  * - Valid indices: `0` to `length` (inclusive — inserting at `length` appends).
3230
3233
  * - Does not mutate the input.
@@ -3234,7 +3237,7 @@ export const insertAt: {
3234
3237
  * ```ts
3235
3238
  * import { Array } from "effect"
3236
3239
  *
3237
- * console.log(Array.insertAt(["a", "b", "c", "e"], 3, "d")) // ["a", "b", "c", "d", "e"]
3240
+ * console.log(Array.insertAt(["a", "b", "c", "e"], 3, "d")) // Option.some(["a", "b", "c", "d", "e"])
3238
3241
  * ```
3239
3242
  *
3240
3243
  * @see {@link replace} — replace an existing element
@@ -3243,10 +3246,10 @@ export const insertAt: {
3243
3246
  * @category elements
3244
3247
  * @since 2.0.0
3245
3248
  */
3246
- <B>(i: number, b: B): <A>(self: Iterable<A>) => NonEmptyArray<A | B> | undefined
3249
+ <B>(i: number, b: B): <A>(self: Iterable<A>) => Option.Option<NonEmptyArray<A | B>>
3247
3250
  /**
3248
- * Inserts an element at the specified index, returning a new `NonEmptyArray`,
3249
- * or `undefined` if the index is out of bounds.
3251
+ * Inserts an element at the specified index, returning a new `NonEmptyArray`
3252
+ * wrapped in an `Option`.
3250
3253
  *
3251
3254
  * - Valid indices: `0` to `length` (inclusive — inserting at `length` appends).
3252
3255
  * - Does not mutate the input.
@@ -3256,7 +3259,7 @@ export const insertAt: {
3256
3259
  * ```ts
3257
3260
  * import { Array } from "effect"
3258
3261
  *
3259
- * console.log(Array.insertAt(["a", "b", "c", "e"], 3, "d")) // ["a", "b", "c", "d", "e"]
3262
+ * console.log(Array.insertAt(["a", "b", "c", "e"], 3, "d")) // Option.some(["a", "b", "c", "d", "e"])
3260
3263
  * ```
3261
3264
  *
3262
3265
  * @see {@link replace} — replace an existing element
@@ -3265,19 +3268,19 @@ export const insertAt: {
3265
3268
  * @category elements
3266
3269
  * @since 2.0.0
3267
3270
  */
3268
- <A, B>(self: Iterable<A>, i: number, b: B): NonEmptyArray<A | B> | undefined
3269
- } = dual(3, <A, B>(self: Iterable<A>, i: number, b: B): NonEmptyArray<A | B> | undefined => {
3271
+ <A, B>(self: Iterable<A>, i: number, b: B): Option.Option<NonEmptyArray<A | B>>
3272
+ } = dual(3, <A, B>(self: Iterable<A>, i: number, b: B): Option.Option<NonEmptyArray<A | B>> => {
3270
3273
  const out: Array<A | B> = Array.from(self) // copy because `splice` mutates the array
3271
3274
  if (i < 0 || i > out.length) {
3272
- return undefined
3275
+ return Option.none()
3273
3276
  }
3274
3277
  out.splice(i, 0, b)
3275
- return out as any
3278
+ return Option.some(out as any)
3276
3279
  })
3277
3280
 
3278
3281
  /**
3279
3282
  * Replaces the element at the specified index with a new value, returning a new
3280
- * array, or `undefined` if the index is out of bounds.
3283
+ * array, wrapped in an `Option`.
3281
3284
  *
3282
3285
  * - Does not mutate the input.
3283
3286
  *
@@ -3286,7 +3289,7 @@ export const insertAt: {
3286
3289
  * ```ts
3287
3290
  * import { Array } from "effect"
3288
3291
  *
3289
- * console.log(Array.replace([1, 2, 3], 1, 4)) // [1, 4, 3]
3292
+ * console.log(Array.replace([1, 2, 3], 1, 4)) // Option.some([1, 4, 3])
3290
3293
  * ```
3291
3294
  *
3292
3295
  * @see {@link modify} — transform an element with a function
@@ -3298,7 +3301,7 @@ export const insertAt: {
3298
3301
  export const replace: {
3299
3302
  /**
3300
3303
  * Replaces the element at the specified index with a new value, returning a new
3301
- * array, or `undefined` if the index is out of bounds.
3304
+ * array, wrapped in an `Option`.
3302
3305
  *
3303
3306
  * - Does not mutate the input.
3304
3307
  *
@@ -3307,7 +3310,7 @@ export const replace: {
3307
3310
  * ```ts
3308
3311
  * import { Array } from "effect"
3309
3312
  *
3310
- * console.log(Array.replace([1, 2, 3], 1, 4)) // [1, 4, 3]
3313
+ * console.log(Array.replace([1, 2, 3], 1, 4)) // Option.some([1, 4, 3])
3311
3314
  * ```
3312
3315
  *
3313
3316
  * @see {@link modify} — transform an element with a function
@@ -3318,10 +3321,10 @@ export const replace: {
3318
3321
  */
3319
3322
  <B>(i: number, b: B): <A, S extends Iterable<A> = Iterable<A>>(
3320
3323
  self: S
3321
- ) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B> | undefined
3324
+ ) => Option.Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
3322
3325
  /**
3323
3326
  * Replaces the element at the specified index with a new value, returning a new
3324
- * array, or `undefined` if the index is out of bounds.
3327
+ * array, wrapped in an `Option`.
3325
3328
  *
3326
3329
  * - Does not mutate the input.
3327
3330
  *
@@ -3330,7 +3333,7 @@ export const replace: {
3330
3333
  * ```ts
3331
3334
  * import { Array } from "effect"
3332
3335
  *
3333
- * console.log(Array.replace([1, 2, 3], 1, 4)) // [1, 4, 3]
3336
+ * console.log(Array.replace([1, 2, 3], 1, 4)) // Option.some([1, 4, 3])
3334
3337
  * ```
3335
3338
  *
3336
3339
  * @see {@link modify} — transform an element with a function
@@ -3339,15 +3342,15 @@ export const replace: {
3339
3342
  * @category elements
3340
3343
  * @since 2.0.0
3341
3344
  */
3342
- <A, B, S extends Iterable<A> = Iterable<A>>(self: S, i: number, b: B): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B> | undefined
3345
+ <A, B, S extends Iterable<A> = Iterable<A>>(self: S, i: number, b: B): Option.Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
3343
3346
  } = dual(
3344
3347
  3,
3345
- <A, B>(self: Iterable<A>, i: number, b: B): Array<A | B> | undefined => modify(self, i, () => b)
3348
+ <A, B>(self: Iterable<A>, i: number, b: B): Option.Option<Array<A | B>> => modify(self, i, () => b)
3346
3349
  )
3347
3350
 
3348
3351
  /**
3349
3352
  * Applies a function to the element at the specified index, returning a new
3350
- * array, or `undefined` if the index is out of bounds.
3353
+ * array, wrapped in an `Option`.
3351
3354
  *
3352
3355
  * - Does not mutate the input.
3353
3356
  *
@@ -3356,8 +3359,8 @@ export const replace: {
3356
3359
  * ```ts
3357
3360
  * import { Array } from "effect"
3358
3361
  *
3359
- * console.log(Array.modify([1, 2, 3, 4], 2, (n) => n * 2)) // [1, 2, 6, 4]
3360
- * console.log(Array.modify([1, 2, 3, 4], 5, (n) => n * 2)) // undefined
3362
+ * console.log(Array.modify([1, 2, 3, 4], 2, (n) => n * 2)) // Option.some([1, 2, 6, 4])
3363
+ * console.log(Array.modify([1, 2, 3, 4], 5, (n) => n * 2)) // Option.none()
3361
3364
  * ```
3362
3365
  *
3363
3366
  * @see {@link replace} — set a fixed value at an index
@@ -3370,7 +3373,7 @@ export const replace: {
3370
3373
  export const modify: {
3371
3374
  /**
3372
3375
  * Applies a function to the element at the specified index, returning a new
3373
- * array, or `undefined` if the index is out of bounds.
3376
+ * array, wrapped in an `Option`.
3374
3377
  *
3375
3378
  * - Does not mutate the input.
3376
3379
  *
@@ -3379,8 +3382,8 @@ export const modify: {
3379
3382
  * ```ts
3380
3383
  * import { Array } from "effect"
3381
3384
  *
3382
- * console.log(Array.modify([1, 2, 3, 4], 2, (n) => n * 2)) // [1, 2, 6, 4]
3383
- * console.log(Array.modify([1, 2, 3, 4], 5, (n) => n * 2)) // undefined
3385
+ * console.log(Array.modify([1, 2, 3, 4], 2, (n) => n * 2)) // Option.some([1, 2, 6, 4])
3386
+ * console.log(Array.modify([1, 2, 3, 4], 5, (n) => n * 2)) // Option.none()
3384
3387
  * ```
3385
3388
  *
3386
3389
  * @see {@link replace} — set a fixed value at an index
@@ -3390,10 +3393,10 @@ export const modify: {
3390
3393
  * @category elements
3391
3394
  * @since 2.0.0
3392
3395
  */
3393
- <A, B, S extends Iterable<A> = Iterable<A>>(i: number, f: (a: ReadonlyArray.Infer<S>) => B): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B> | undefined
3396
+ <A, B, S extends Iterable<A> = Iterable<A>>(i: number, f: (a: ReadonlyArray.Infer<S>) => B): (self: S) => Option.Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
3394
3397
  /**
3395
3398
  * Applies a function to the element at the specified index, returning a new
3396
- * array, or `undefined` if the index is out of bounds.
3399
+ * array, wrapped in an `Option`.
3397
3400
  *
3398
3401
  * - Does not mutate the input.
3399
3402
  *
@@ -3402,8 +3405,8 @@ export const modify: {
3402
3405
  * ```ts
3403
3406
  * import { Array } from "effect"
3404
3407
  *
3405
- * console.log(Array.modify([1, 2, 3, 4], 2, (n) => n * 2)) // [1, 2, 6, 4]
3406
- * console.log(Array.modify([1, 2, 3, 4], 5, (n) => n * 2)) // undefined
3408
+ * console.log(Array.modify([1, 2, 3, 4], 2, (n) => n * 2)) // Option.some([1, 2, 6, 4])
3409
+ * console.log(Array.modify([1, 2, 3, 4], 5, (n) => n * 2)) // Option.none()
3407
3410
  * ```
3408
3411
  *
3409
3412
  * @see {@link replace} — set a fixed value at an index
@@ -3413,16 +3416,16 @@ export const modify: {
3413
3416
  * @category elements
3414
3417
  * @since 2.0.0
3415
3418
  */
3416
- <A, B, S extends Iterable<A> = Iterable<A>>(self: S, i: number, f: (a: ReadonlyArray.Infer<S>) => B): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B> | undefined
3417
- } = dual(3, <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Array<A | B> | undefined => {
3419
+ <A, B, S extends Iterable<A> = Iterable<A>>(self: S, i: number, f: (a: ReadonlyArray.Infer<S>) => B): Option.Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
3420
+ } = dual(3, <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Option.Option<Array<A | B>> => {
3418
3421
  const arr = Array.from(self)
3419
3422
  if (isOutOfBounds(i, arr)) {
3420
- return undefined
3423
+ return Option.none()
3421
3424
  }
3422
3425
  const out: Array<A | B> = arr
3423
3426
  const b = f(arr[i])
3424
3427
  out[i] = b
3425
- return out
3428
+ return Option.some(out)
3426
3429
  })
3427
3430
 
3428
3431
  /**
@@ -7373,14 +7376,15 @@ export const max: {
7373
7376
 
7374
7377
  /**
7375
7378
  * Builds an array by repeatedly applying a function to a seed value. The
7376
- * function returns `[element, nextSeed]` to continue, or `undefined` to stop.
7379
+ * function returns `Option.some([element, nextSeed])` to continue, or
7380
+ * `Option.none()` to stop.
7377
7381
  *
7378
7382
  * **Example** (Generating a sequence)
7379
7383
  *
7380
7384
  * ```ts
7381
- * import { Array } from "effect"
7385
+ * import { Array, Option } from "effect"
7382
7386
  *
7383
- * console.log(Array.unfold(1, (n) => n <= 5 ? [n, n + 1] : undefined))
7387
+ * console.log(Array.unfold(1, (n) => n <= 5 ? Option.some([n, n + 1]) : Option.none()))
7384
7388
  * // [1, 2, 3, 4, 5]
7385
7389
  * ```
7386
7390
  *
@@ -7390,12 +7394,15 @@ export const max: {
7390
7394
  * @category constructors
7391
7395
  * @since 2.0.0
7392
7396
  */
7393
- export const unfold = <B, A>(b: B, f: (b: B) => readonly [A, B] | undefined): Array<A> => {
7397
+ export const unfold = <B, A>(b: B, f: (b: B) => Option.Option<readonly [A, B]>): Array<A> => {
7394
7398
  const out: Array<A> = []
7395
7399
  let next: B = b
7396
- let o: readonly [A, B] | undefined
7397
- while ((o = f(next))) {
7398
- const [a, b] = o
7400
+ while (true) {
7401
+ const o = f(next)
7402
+ if (Option.isNone(o)) {
7403
+ break
7404
+ }
7405
+ const [a, b] = o.value
7399
7406
  out.push(a)
7400
7407
  next = b
7401
7408
  }