effect 4.0.0-beta.4 → 4.0.0-beta.41

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 (1235) hide show
  1. package/dist/Array.d.ts +213 -385
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +149 -102
  4. package/dist/Array.js.map +1 -1
  5. package/dist/BigDecimal.d.ts +82 -45
  6. package/dist/BigDecimal.d.ts.map +1 -1
  7. package/dist/BigDecimal.js +87 -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/Brand.d.ts +1 -1
  14. package/dist/Brand.d.ts.map +1 -1
  15. package/dist/Brand.js +1 -1
  16. package/dist/Brand.js.map +1 -1
  17. package/dist/Cache.d.ts +2 -2
  18. package/dist/Cache.d.ts.map +1 -1
  19. package/dist/Cache.js +6 -5
  20. package/dist/Cache.js.map +1 -1
  21. package/dist/Cause.d.ts +33 -2
  22. package/dist/Cause.d.ts.map +1 -1
  23. package/dist/Cause.js +19 -0
  24. package/dist/Cause.js.map +1 -1
  25. package/dist/Channel.d.ts +130 -35
  26. package/dist/Channel.d.ts.map +1 -1
  27. package/dist/Channel.js +96 -45
  28. package/dist/Channel.js.map +1 -1
  29. package/dist/Chunk.d.ts +112 -304
  30. package/dist/Chunk.d.ts.map +1 -1
  31. package/dist/Chunk.js +56 -88
  32. package/dist/Chunk.js.map +1 -1
  33. package/dist/Combiner.d.ts +280 -13
  34. package/dist/Combiner.d.ts.map +1 -1
  35. package/dist/Combiner.js +198 -7
  36. package/dist/Combiner.js.map +1 -1
  37. package/dist/Config.d.ts +169 -9
  38. package/dist/Config.d.ts.map +1 -1
  39. package/dist/Config.js +69 -11
  40. package/dist/Config.js.map +1 -1
  41. package/dist/ConfigProvider.d.ts +1 -1
  42. package/dist/Cron.d.ts +11 -7
  43. package/dist/Cron.d.ts.map +1 -1
  44. package/dist/Cron.js +120 -63
  45. package/dist/Cron.js.map +1 -1
  46. package/dist/Data.d.ts +535 -366
  47. package/dist/Data.d.ts.map +1 -1
  48. package/dist/Data.js +132 -79
  49. package/dist/Data.js.map +1 -1
  50. package/dist/DateTime.d.ts +72 -253
  51. package/dist/DateTime.d.ts.map +1 -1
  52. package/dist/DateTime.js +15 -60
  53. package/dist/DateTime.js.map +1 -1
  54. package/dist/Deferred.d.ts +7 -5
  55. package/dist/Deferred.d.ts.map +1 -1
  56. package/dist/Deferred.js +7 -5
  57. package/dist/Deferred.js.map +1 -1
  58. package/dist/Duration.d.ts +62 -32
  59. package/dist/Duration.d.ts.map +1 -1
  60. package/dist/Duration.js +108 -78
  61. package/dist/Duration.js.map +1 -1
  62. package/dist/Effect.d.ts +1225 -951
  63. package/dist/Effect.d.ts.map +1 -1
  64. package/dist/Effect.js +398 -338
  65. package/dist/Effect.js.map +1 -1
  66. package/dist/Encoding.d.ts +194 -0
  67. package/dist/Encoding.d.ts.map +1 -0
  68. package/dist/Encoding.js +352 -0
  69. package/dist/Encoding.js.map +1 -0
  70. package/dist/Equal.d.ts +276 -109
  71. package/dist/Equal.d.ts.map +1 -1
  72. package/dist/Equal.js +124 -48
  73. package/dist/Equal.js.map +1 -1
  74. package/dist/Equivalence.d.ts +60 -3
  75. package/dist/Equivalence.d.ts.map +1 -1
  76. package/dist/Equivalence.js +70 -13
  77. package/dist/Equivalence.js.map +1 -1
  78. package/dist/ErrorReporter.d.ts +374 -0
  79. package/dist/ErrorReporter.d.ts.map +1 -0
  80. package/dist/ErrorReporter.js +245 -0
  81. package/dist/ErrorReporter.js.map +1 -0
  82. package/dist/Exit.d.ts +24 -12
  83. package/dist/Exit.d.ts.map +1 -1
  84. package/dist/Exit.js +8 -4
  85. package/dist/Exit.js.map +1 -1
  86. package/dist/Fiber.d.ts +5 -3
  87. package/dist/Fiber.d.ts.map +1 -1
  88. package/dist/Fiber.js.map +1 -1
  89. package/dist/FiberHandle.d.ts +9 -8
  90. package/dist/FiberHandle.d.ts.map +1 -1
  91. package/dist/FiberHandle.js +8 -7
  92. package/dist/FiberHandle.js.map +1 -1
  93. package/dist/FiberMap.d.ts +20 -19
  94. package/dist/FiberMap.d.ts.map +1 -1
  95. package/dist/FiberMap.js +6 -6
  96. package/dist/FiberMap.js.map +1 -1
  97. package/dist/FileSystem.d.ts +18 -17
  98. package/dist/FileSystem.d.ts.map +1 -1
  99. package/dist/FileSystem.js +17 -13
  100. package/dist/FileSystem.js.map +1 -1
  101. package/dist/Filter.d.ts +34 -38
  102. package/dist/Filter.d.ts.map +1 -1
  103. package/dist/Filter.js +15 -13
  104. package/dist/Filter.js.map +1 -1
  105. package/dist/Formatter.d.ts +131 -47
  106. package/dist/Formatter.d.ts.map +1 -1
  107. package/dist/Formatter.js +229 -51
  108. package/dist/Formatter.js.map +1 -1
  109. package/dist/Function.d.ts +1 -9
  110. package/dist/Function.d.ts.map +1 -1
  111. package/dist/Function.js +2 -10
  112. package/dist/Function.js.map +1 -1
  113. package/dist/Graph.d.ts +65 -65
  114. package/dist/Graph.d.ts.map +1 -1
  115. package/dist/Graph.js +60 -62
  116. package/dist/Graph.js.map +1 -1
  117. package/dist/HashMap.d.ts +26 -19
  118. package/dist/HashMap.d.ts.map +1 -1
  119. package/dist/HashMap.js +7 -5
  120. package/dist/HashMap.js.map +1 -1
  121. package/dist/Iterable.d.ts +50 -50
  122. package/dist/Iterable.d.ts.map +1 -1
  123. package/dist/Iterable.js +106 -34
  124. package/dist/Iterable.js.map +1 -1
  125. package/dist/JsonSchema.d.ts +299 -10
  126. package/dist/JsonSchema.d.ts.map +1 -1
  127. package/dist/JsonSchema.js +323 -4
  128. package/dist/JsonSchema.js.map +1 -1
  129. package/dist/Latch.d.ts +175 -0
  130. package/dist/Latch.d.ts.map +1 -0
  131. package/dist/Latch.js +130 -0
  132. package/dist/Latch.js.map +1 -0
  133. package/dist/Layer.d.ts +306 -129
  134. package/dist/Layer.d.ts.map +1 -1
  135. package/dist/Layer.js +93 -48
  136. package/dist/Layer.js.map +1 -1
  137. package/dist/LayerMap.d.ts +9 -8
  138. package/dist/LayerMap.d.ts.map +1 -1
  139. package/dist/LayerMap.js +3 -3
  140. package/dist/LayerMap.js.map +1 -1
  141. package/dist/LogLevel.d.ts +32 -0
  142. package/dist/LogLevel.d.ts.map +1 -1
  143. package/dist/LogLevel.js +28 -100
  144. package/dist/LogLevel.js.map +1 -1
  145. package/dist/Logger.d.ts +29 -95
  146. package/dist/Logger.d.ts.map +1 -1
  147. package/dist/Logger.js +2 -3
  148. package/dist/Logger.js.map +1 -1
  149. package/dist/ManagedRuntime.d.ts +2 -2
  150. package/dist/ManagedRuntime.d.ts.map +1 -1
  151. package/dist/ManagedRuntime.js +21 -9
  152. package/dist/ManagedRuntime.js.map +1 -1
  153. package/dist/Metric.d.ts +4 -6
  154. package/dist/Metric.d.ts.map +1 -1
  155. package/dist/Metric.js +3 -5
  156. package/dist/Metric.js.map +1 -1
  157. package/dist/MutableHashMap.d.ts +7 -0
  158. package/dist/MutableHashMap.d.ts.map +1 -1
  159. package/dist/MutableHashMap.js +8 -0
  160. package/dist/MutableHashMap.js.map +1 -1
  161. package/dist/MutableHashSet.d.ts +7 -0
  162. package/dist/MutableHashSet.d.ts.map +1 -1
  163. package/dist/MutableHashSet.js +8 -0
  164. package/dist/MutableHashSet.js.map +1 -1
  165. package/dist/Newtype.d.ts +291 -0
  166. package/dist/Newtype.d.ts.map +1 -0
  167. package/dist/Newtype.js +161 -0
  168. package/dist/Newtype.js.map +1 -0
  169. package/dist/Number.d.ts +74 -18
  170. package/dist/Number.d.ts.map +1 -1
  171. package/dist/Number.js +34 -15
  172. package/dist/Number.js.map +1 -1
  173. package/dist/Optic.d.ts +947 -18
  174. package/dist/Optic.d.ts.map +1 -1
  175. package/dist/Optic.js +454 -5
  176. package/dist/Optic.js.map +1 -1
  177. package/dist/Option.d.ts +25 -16
  178. package/dist/Option.d.ts.map +1 -1
  179. package/dist/Option.js +15 -9
  180. package/dist/Option.js.map +1 -1
  181. package/dist/Order.d.ts +6 -1
  182. package/dist/Order.d.ts.map +1 -1
  183. package/dist/Order.js +19 -14
  184. package/dist/Order.js.map +1 -1
  185. package/dist/PartitionedSemaphore.d.ts +146 -15
  186. package/dist/PartitionedSemaphore.d.ts.map +1 -1
  187. package/dist/PartitionedSemaphore.js +174 -61
  188. package/dist/PartitionedSemaphore.js.map +1 -1
  189. package/dist/Pipeable.d.ts +17 -0
  190. package/dist/Pipeable.d.ts.map +1 -1
  191. package/dist/Pipeable.js +19 -1
  192. package/dist/Pipeable.js.map +1 -1
  193. package/dist/PlatformError.d.ts +10 -9
  194. package/dist/PlatformError.d.ts.map +1 -1
  195. package/dist/PlatformError.js +2 -2
  196. package/dist/PlatformError.js.map +1 -1
  197. package/dist/Pool.d.ts +6 -4
  198. package/dist/Pool.d.ts.map +1 -1
  199. package/dist/Pool.js +7 -5
  200. package/dist/Pool.js.map +1 -1
  201. package/dist/PubSub.d.ts +8 -6
  202. package/dist/PubSub.d.ts.map +1 -1
  203. package/dist/PubSub.js +18 -10
  204. package/dist/PubSub.js.map +1 -1
  205. package/dist/Pull.d.ts.map +1 -1
  206. package/dist/Pull.js +1 -1
  207. package/dist/Pull.js.map +1 -1
  208. package/dist/Queue.d.ts +9 -6
  209. package/dist/Queue.d.ts.map +1 -1
  210. package/dist/Queue.js +7 -5
  211. package/dist/Queue.js.map +1 -1
  212. package/dist/Random.d.ts +35 -1
  213. package/dist/Random.d.ts.map +1 -1
  214. package/dist/Random.js +46 -12
  215. package/dist/Random.js.map +1 -1
  216. package/dist/RcMap.d.ts +2 -2
  217. package/dist/RcMap.d.ts.map +1 -1
  218. package/dist/RcMap.js +1 -1
  219. package/dist/RcMap.js.map +1 -1
  220. package/dist/RcRef.d.ts +1 -1
  221. package/dist/RcRef.d.ts.map +1 -1
  222. package/dist/Record.d.ts +63 -160
  223. package/dist/Record.d.ts.map +1 -1
  224. package/dist/Record.js +37 -56
  225. package/dist/Record.js.map +1 -1
  226. package/dist/Reducer.d.ts +166 -7
  227. package/dist/Reducer.d.ts.map +1 -1
  228. package/dist/Reducer.js +135 -1
  229. package/dist/Reducer.js.map +1 -1
  230. package/dist/References.d.ts +242 -226
  231. package/dist/References.d.ts.map +1 -1
  232. package/dist/References.js +240 -247
  233. package/dist/References.js.map +1 -1
  234. package/dist/Request.d.ts +1 -1
  235. package/dist/Request.d.ts.map +1 -1
  236. package/dist/Request.js +2 -1
  237. package/dist/Request.js.map +1 -1
  238. package/dist/RequestResolver.d.ts +25 -45
  239. package/dist/RequestResolver.d.ts.map +1 -1
  240. package/dist/RequestResolver.js +10 -30
  241. package/dist/RequestResolver.js.map +1 -1
  242. package/dist/Resource.d.ts.map +1 -1
  243. package/dist/Resource.js +2 -1
  244. package/dist/Resource.js.map +1 -1
  245. package/dist/Result.d.ts +1 -1
  246. package/dist/Result.d.ts.map +1 -1
  247. package/dist/Result.js +1 -2
  248. package/dist/Result.js.map +1 -1
  249. package/dist/Runtime.d.ts +66 -0
  250. package/dist/Runtime.d.ts.map +1 -1
  251. package/dist/Runtime.js +79 -6
  252. package/dist/Runtime.js.map +1 -1
  253. package/dist/Schedule.d.ts +174 -291
  254. package/dist/Schedule.d.ts.map +1 -1
  255. package/dist/Schedule.js +160 -134
  256. package/dist/Schedule.js.map +1 -1
  257. package/dist/Scheduler.d.ts +34 -123
  258. package/dist/Scheduler.d.ts.map +1 -1
  259. package/dist/Scheduler.js +31 -123
  260. package/dist/Scheduler.js.map +1 -1
  261. package/dist/Schema.d.ts +2722 -247
  262. package/dist/Schema.d.ts.map +1 -1
  263. package/dist/Schema.js +1947 -224
  264. package/dist/Schema.js.map +1 -1
  265. package/dist/SchemaAST.d.ts +7 -2
  266. package/dist/SchemaAST.d.ts.map +1 -1
  267. package/dist/SchemaAST.js +131 -25
  268. package/dist/SchemaAST.js.map +1 -1
  269. package/dist/SchemaGetter.d.ts +5 -5
  270. package/dist/SchemaGetter.d.ts.map +1 -1
  271. package/dist/SchemaGetter.js +18 -18
  272. package/dist/SchemaGetter.js.map +1 -1
  273. package/dist/SchemaParser.d.ts +44 -54
  274. package/dist/SchemaParser.d.ts.map +1 -1
  275. package/dist/SchemaParser.js +55 -2
  276. package/dist/SchemaParser.js.map +1 -1
  277. package/dist/SchemaRepresentation.d.ts +46 -45
  278. package/dist/SchemaRepresentation.d.ts.map +1 -1
  279. package/dist/SchemaRepresentation.js +49 -24
  280. package/dist/SchemaRepresentation.js.map +1 -1
  281. package/dist/SchemaTransformation.d.ts +107 -3
  282. package/dist/SchemaTransformation.d.ts.map +1 -1
  283. package/dist/SchemaTransformation.js +173 -13
  284. package/dist/SchemaTransformation.js.map +1 -1
  285. package/dist/ScopedCache.d.ts +2 -2
  286. package/dist/ScopedCache.d.ts.map +1 -1
  287. package/dist/ScopedCache.js +1 -1
  288. package/dist/ScopedCache.js.map +1 -1
  289. package/dist/Semaphore.d.ts +307 -0
  290. package/dist/Semaphore.d.ts.map +1 -0
  291. package/dist/Semaphore.js +222 -0
  292. package/dist/Semaphore.js.map +1 -0
  293. package/dist/ServiceMap.d.ts +76 -52
  294. package/dist/ServiceMap.d.ts.map +1 -1
  295. package/dist/ServiceMap.js +45 -29
  296. package/dist/ServiceMap.js.map +1 -1
  297. package/dist/Sink.d.ts +18 -15
  298. package/dist/Sink.d.ts.map +1 -1
  299. package/dist/Sink.js +53 -6
  300. package/dist/Sink.js.map +1 -1
  301. package/dist/Stdio.d.ts +16 -4
  302. package/dist/Stdio.d.ts.map +1 -1
  303. package/dist/Stdio.js +18 -0
  304. package/dist/Stdio.js.map +1 -1
  305. package/dist/Stream.d.ts +284 -431
  306. package/dist/Stream.d.ts.map +1 -1
  307. package/dist/Stream.js +189 -88
  308. package/dist/Stream.js.map +1 -1
  309. package/dist/String.d.ts +114 -47
  310. package/dist/String.d.ts.map +1 -1
  311. package/dist/String.js +29 -47
  312. package/dist/String.js.map +1 -1
  313. package/dist/Struct.d.ts +23 -7
  314. package/dist/Struct.d.ts.map +1 -1
  315. package/dist/Struct.js +22 -0
  316. package/dist/Struct.js.map +1 -1
  317. package/dist/SubscriptionRef.d.ts +3 -3
  318. package/dist/SubscriptionRef.d.ts.map +1 -1
  319. package/dist/SubscriptionRef.js +85 -117
  320. package/dist/SubscriptionRef.js.map +1 -1
  321. package/dist/SynchronizedRef.d.ts +2 -1
  322. package/dist/SynchronizedRef.d.ts.map +1 -1
  323. package/dist/SynchronizedRef.js +2 -1
  324. package/dist/SynchronizedRef.js.map +1 -1
  325. package/dist/Terminal.d.ts +2 -1
  326. package/dist/Terminal.d.ts.map +1 -1
  327. package/dist/Terminal.js.map +1 -1
  328. package/dist/Tracer.d.ts +5 -4
  329. package/dist/Tracer.d.ts.map +1 -1
  330. package/dist/Tracer.js +2 -1
  331. package/dist/Tracer.js.map +1 -1
  332. package/dist/Trie.d.ts +44 -31
  333. package/dist/Trie.d.ts.map +1 -1
  334. package/dist/Trie.js +13 -9
  335. package/dist/Trie.js.map +1 -1
  336. package/dist/TxChunk.d.ts +37 -37
  337. package/dist/TxChunk.d.ts.map +1 -1
  338. package/dist/TxChunk.js +3 -3
  339. package/dist/TxChunk.js.map +1 -1
  340. package/dist/TxDeferred.d.ts +328 -0
  341. package/dist/TxDeferred.d.ts.map +1 -0
  342. package/dist/TxDeferred.js +197 -0
  343. package/dist/TxDeferred.js.map +1 -0
  344. package/dist/TxHashMap.d.ts +159 -140
  345. package/dist/TxHashMap.d.ts.map +1 -1
  346. package/dist/TxHashMap.js +51 -44
  347. package/dist/TxHashMap.js.map +1 -1
  348. package/dist/TxHashSet.d.ts +36 -36
  349. package/dist/TxHashSet.d.ts.map +1 -1
  350. package/dist/TxHashSet.js +16 -15
  351. package/dist/TxHashSet.js.map +1 -1
  352. package/dist/TxPriorityQueue.d.ts +609 -0
  353. package/dist/TxPriorityQueue.d.ts.map +1 -0
  354. package/dist/TxPriorityQueue.js +416 -0
  355. package/dist/TxPriorityQueue.js.map +1 -0
  356. package/dist/TxPubSub.d.ts +585 -0
  357. package/dist/TxPubSub.d.ts.map +1 -0
  358. package/dist/TxPubSub.js +521 -0
  359. package/dist/TxPubSub.js.map +1 -0
  360. package/dist/TxQueue.d.ts +32 -32
  361. package/dist/TxQueue.d.ts.map +1 -1
  362. package/dist/TxQueue.js +26 -26
  363. package/dist/TxQueue.js.map +1 -1
  364. package/dist/TxReentrantLock.d.ts +523 -0
  365. package/dist/TxReentrantLock.d.ts.map +1 -0
  366. package/dist/TxReentrantLock.js +504 -0
  367. package/dist/TxReentrantLock.js.map +1 -0
  368. package/dist/TxRef.d.ts +34 -34
  369. package/dist/TxRef.d.ts.map +1 -1
  370. package/dist/TxRef.js +21 -14
  371. package/dist/TxRef.js.map +1 -1
  372. package/dist/TxSemaphore.d.ts +170 -10
  373. package/dist/TxSemaphore.d.ts.map +1 -1
  374. package/dist/TxSemaphore.js +23 -8
  375. package/dist/TxSemaphore.js.map +1 -1
  376. package/dist/TxSubscriptionRef.d.ts +508 -0
  377. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  378. package/dist/TxSubscriptionRef.js +293 -0
  379. package/dist/TxSubscriptionRef.js.map +1 -0
  380. package/dist/Types.d.ts +80 -23
  381. package/dist/Types.d.ts.map +1 -1
  382. package/dist/Utils.d.ts +137 -65
  383. package/dist/Utils.d.ts.map +1 -1
  384. package/dist/Utils.js +38 -66
  385. package/dist/Utils.js.map +1 -1
  386. package/dist/index.d.ts +806 -55
  387. package/dist/index.d.ts.map +1 -1
  388. package/dist/index.js +806 -55
  389. package/dist/index.js.map +1 -1
  390. package/dist/internal/core.js +11 -3
  391. package/dist/internal/core.js.map +1 -1
  392. package/dist/internal/dateTime.js +77 -71
  393. package/dist/internal/dateTime.js.map +1 -1
  394. package/dist/internal/effect.js +284 -201
  395. package/dist/internal/effect.js.map +1 -1
  396. package/dist/internal/hashMap.js +7 -5
  397. package/dist/internal/hashMap.js.map +1 -1
  398. package/dist/internal/option.js +6 -0
  399. package/dist/internal/option.js.map +1 -1
  400. package/dist/internal/random.d.ts +2 -0
  401. package/dist/internal/random.d.ts.map +1 -0
  402. package/dist/internal/random.js +13 -0
  403. package/dist/internal/random.js.map +1 -0
  404. package/dist/internal/rcRef.js +3 -2
  405. package/dist/internal/rcRef.js.map +1 -1
  406. package/dist/internal/references.d.ts +2 -0
  407. package/dist/internal/references.d.ts.map +1 -0
  408. package/dist/internal/references.js +51 -0
  409. package/dist/internal/references.js.map +1 -0
  410. package/dist/internal/request.js +2 -2
  411. package/dist/internal/request.js.map +1 -1
  412. package/dist/internal/schema/annotations.js +2 -0
  413. package/dist/internal/schema/annotations.js.map +1 -1
  414. package/dist/internal/schema/representation.js +75 -106
  415. package/dist/internal/schema/representation.js.map +1 -1
  416. package/dist/internal/schema/schema.js +1 -0
  417. package/dist/internal/schema/schema.js.map +1 -1
  418. package/dist/internal/schema/to-codec.js +7 -10
  419. package/dist/internal/schema/to-codec.js.map +1 -1
  420. package/dist/internal/trie.js +8 -7
  421. package/dist/internal/trie.js.map +1 -1
  422. package/dist/testing/TestClock.d.ts +8 -7
  423. package/dist/testing/TestClock.d.ts.map +1 -1
  424. package/dist/testing/TestClock.js +6 -4
  425. package/dist/testing/TestClock.js.map +1 -1
  426. package/dist/testing/TestSchema.d.ts +266 -32
  427. package/dist/testing/TestSchema.d.ts.map +1 -1
  428. package/dist/testing/TestSchema.js +296 -23
  429. package/dist/testing/TestSchema.js.map +1 -1
  430. package/dist/testing/index.d.ts +64 -1
  431. package/dist/testing/index.d.ts.map +1 -1
  432. package/dist/testing/index.js +64 -1
  433. package/dist/testing/index.js.map +1 -1
  434. package/dist/unstable/ai/AiError.d.ts +136 -54
  435. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  436. package/dist/unstable/ai/AiError.js +28 -23
  437. package/dist/unstable/ai/AiError.js.map +1 -1
  438. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  439. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  440. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  441. package/dist/unstable/ai/Chat.d.ts +35 -7
  442. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  443. package/dist/unstable/ai/Chat.js +38 -44
  444. package/dist/unstable/ai/Chat.js.map +1 -1
  445. package/dist/unstable/ai/EmbeddingModel.d.ts +130 -0
  446. package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -0
  447. package/dist/unstable/ai/EmbeddingModel.js +127 -0
  448. package/dist/unstable/ai/EmbeddingModel.js.map +1 -0
  449. package/dist/unstable/ai/LanguageModel.d.ts +117 -47
  450. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  451. package/dist/unstable/ai/LanguageModel.js +258 -59
  452. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  453. package/dist/unstable/ai/McpSchema.d.ts +183 -88
  454. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  455. package/dist/unstable/ai/McpSchema.js +57 -12
  456. package/dist/unstable/ai/McpSchema.js.map +1 -1
  457. package/dist/unstable/ai/McpServer.d.ts +66 -13
  458. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  459. package/dist/unstable/ai/McpServer.js +193 -51
  460. package/dist/unstable/ai/McpServer.js.map +1 -1
  461. package/dist/unstable/ai/Model.d.ts +25 -7
  462. package/dist/unstable/ai/Model.d.ts.map +1 -1
  463. package/dist/unstable/ai/Model.js +22 -6
  464. package/dist/unstable/ai/Model.js.map +1 -1
  465. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  466. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  467. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  468. package/dist/unstable/ai/Prompt.d.ts +20 -20
  469. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  470. package/dist/unstable/ai/Response.d.ts +26 -26
  471. package/dist/unstable/ai/Response.d.ts.map +1 -1
  472. package/dist/unstable/ai/Response.js +1 -1
  473. package/dist/unstable/ai/Response.js.map +1 -1
  474. package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
  475. package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
  476. package/dist/unstable/ai/ResponseIdTracker.js +68 -0
  477. package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
  478. package/dist/unstable/ai/Tool.d.ts +34 -4
  479. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  480. package/dist/unstable/ai/Tool.js +28 -10
  481. package/dist/unstable/ai/Tool.js.map +1 -1
  482. package/dist/unstable/ai/Toolkit.d.ts +1 -1
  483. package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
  484. package/dist/unstable/ai/Toolkit.js +4 -11
  485. package/dist/unstable/ai/Toolkit.js.map +1 -1
  486. package/dist/unstable/ai/index.d.ts +22 -1
  487. package/dist/unstable/ai/index.d.ts.map +1 -1
  488. package/dist/unstable/ai/index.js +22 -1
  489. package/dist/unstable/ai/index.js.map +1 -1
  490. package/dist/unstable/ai/internal/codec-transformer.js +0 -5
  491. package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
  492. package/dist/unstable/cli/Argument.d.ts +2 -4
  493. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  494. package/dist/unstable/cli/Argument.js +1 -3
  495. package/dist/unstable/cli/Argument.js.map +1 -1
  496. package/dist/unstable/cli/CliError.d.ts +27 -60
  497. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  498. package/dist/unstable/cli/CliError.js +25 -57
  499. package/dist/unstable/cli/CliError.js.map +1 -1
  500. package/dist/unstable/cli/CliOutput.d.ts +3 -2
  501. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  502. package/dist/unstable/cli/CliOutput.js +65 -10
  503. package/dist/unstable/cli/CliOutput.js.map +1 -1
  504. package/dist/unstable/cli/Command.d.ts +371 -58
  505. package/dist/unstable/cli/Command.d.ts.map +1 -1
  506. package/dist/unstable/cli/Command.js +328 -67
  507. package/dist/unstable/cli/Command.js.map +1 -1
  508. package/dist/unstable/cli/Completions.d.ts +16 -0
  509. package/dist/unstable/cli/Completions.d.ts.map +1 -0
  510. package/dist/unstable/cli/Completions.js +23 -0
  511. package/dist/unstable/cli/Completions.js.map +1 -0
  512. package/dist/unstable/cli/Flag.d.ts +2 -2
  513. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  514. package/dist/unstable/cli/Flag.js +1 -1
  515. package/dist/unstable/cli/Flag.js.map +1 -1
  516. package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
  517. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
  518. package/dist/unstable/cli/GlobalFlag.js +118 -0
  519. package/dist/unstable/cli/GlobalFlag.js.map +1 -0
  520. package/dist/unstable/cli/HelpDoc.d.ts +81 -11
  521. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  522. package/dist/unstable/cli/Param.d.ts +4 -4
  523. package/dist/unstable/cli/Param.d.ts.map +1 -1
  524. package/dist/unstable/cli/Param.js +7 -7
  525. package/dist/unstable/cli/Param.js.map +1 -1
  526. package/dist/unstable/cli/Primitive.d.ts +2 -2
  527. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  528. package/dist/unstable/cli/Primitive.js +1 -1
  529. package/dist/unstable/cli/Primitive.js.map +1 -1
  530. package/dist/unstable/cli/Prompt.js +259 -85
  531. package/dist/unstable/cli/Prompt.js.map +1 -1
  532. package/dist/unstable/cli/index.d.ts +8 -0
  533. package/dist/unstable/cli/index.d.ts.map +1 -1
  534. package/dist/unstable/cli/index.js +8 -0
  535. package/dist/unstable/cli/index.js.map +1 -1
  536. package/dist/unstable/cli/internal/command.d.ts +40 -14
  537. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  538. package/dist/unstable/cli/internal/command.js +72 -46
  539. package/dist/unstable/cli/internal/command.js.map +1 -1
  540. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +16 -4
  541. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  542. package/dist/unstable/cli/internal/config.js +42 -0
  543. package/dist/unstable/cli/internal/config.js.map +1 -1
  544. package/dist/unstable/cli/internal/help.d.ts +33 -0
  545. package/dist/unstable/cli/internal/help.d.ts.map +1 -0
  546. package/dist/unstable/cli/internal/help.js +125 -0
  547. package/dist/unstable/cli/internal/help.js.map +1 -0
  548. package/dist/unstable/cli/internal/parser.js +61 -43
  549. package/dist/unstable/cli/internal/parser.js.map +1 -1
  550. package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
  551. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  552. package/dist/unstable/cluster/ClusterCron.js +1 -1
  553. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  554. package/dist/unstable/cluster/ClusterSchema.d.ts +18 -0
  555. package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
  556. package/dist/unstable/cluster/ClusterSchema.js +21 -1
  557. package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
  558. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  559. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  560. package/dist/unstable/cluster/ClusterWorkflowEngine.js +35 -29
  561. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  562. package/dist/unstable/cluster/DeliverAt.js +1 -1
  563. package/dist/unstable/cluster/DeliverAt.js.map +1 -1
  564. package/dist/unstable/cluster/Entity.d.ts +10 -8
  565. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  566. package/dist/unstable/cluster/Entity.js +8 -7
  567. package/dist/unstable/cluster/Entity.js.map +1 -1
  568. package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
  569. package/dist/unstable/cluster/EntityAddress.js +1 -1
  570. package/dist/unstable/cluster/EntityAddress.js.map +1 -1
  571. package/dist/unstable/cluster/EntityResource.d.ts +2 -2
  572. package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
  573. package/dist/unstable/cluster/Envelope.d.ts +1 -1
  574. package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
  575. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  576. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  577. package/dist/unstable/cluster/Message.d.ts +18 -15
  578. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  579. package/dist/unstable/cluster/Message.js +15 -7
  580. package/dist/unstable/cluster/Message.js.map +1 -1
  581. package/dist/unstable/cluster/MessageStorage.d.ts +33 -10
  582. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  583. package/dist/unstable/cluster/MessageStorage.js +36 -20
  584. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  585. package/dist/unstable/cluster/Reply.d.ts +8 -7
  586. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  587. package/dist/unstable/cluster/Reply.js +4 -3
  588. package/dist/unstable/cluster/Reply.js.map +1 -1
  589. package/dist/unstable/cluster/Runner.d.ts +1 -1
  590. package/dist/unstable/cluster/Runner.d.ts.map +1 -1
  591. package/dist/unstable/cluster/Runner.js +1 -1
  592. package/dist/unstable/cluster/Runner.js.map +1 -1
  593. package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
  594. package/dist/unstable/cluster/RunnerAddress.js +1 -1
  595. package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
  596. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  597. package/dist/unstable/cluster/RunnerServer.js +9 -8
  598. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  599. package/dist/unstable/cluster/Runners.d.ts +2 -1
  600. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  601. package/dist/unstable/cluster/Runners.js +11 -9
  602. package/dist/unstable/cluster/Runners.js.map +1 -1
  603. package/dist/unstable/cluster/ShardId.js +3 -3
  604. package/dist/unstable/cluster/ShardId.js.map +1 -1
  605. package/dist/unstable/cluster/Sharding.d.ts +2 -2
  606. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  607. package/dist/unstable/cluster/Sharding.js +51 -39
  608. package/dist/unstable/cluster/Sharding.js.map +1 -1
  609. package/dist/unstable/cluster/ShardingConfig.d.ts +26 -25
  610. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  611. package/dist/unstable/cluster/ShardingConfig.js +24 -24
  612. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  613. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  614. package/dist/unstable/cluster/SqlMessageStorage.js +25 -19
  615. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  616. package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
  617. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  618. package/dist/unstable/cluster/internal/entityManager.js +24 -18
  619. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  620. package/dist/unstable/cluster/internal/entityReaper.js +2 -1
  621. package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
  622. package/dist/unstable/cluster/internal/resourceRef.js +2 -1
  623. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  624. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  625. package/dist/unstable/devtools/DevToolsClient.js +4 -3
  626. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  627. package/dist/unstable/devtools/DevToolsSchema.d.ts +40 -40
  628. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  629. package/dist/unstable/devtools/DevToolsSchema.js +9 -2
  630. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  631. package/dist/unstable/encoding/Msgpack.d.ts +1 -1
  632. package/dist/unstable/encoding/Ndjson.d.ts +9 -9
  633. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  634. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  635. package/dist/unstable/encoding/Sse.d.ts +4 -4
  636. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  637. package/dist/unstable/encoding/Sse.js +1 -1
  638. package/dist/unstable/encoding/Sse.js.map +1 -1
  639. package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
  640. package/dist/unstable/eventlog/EventJournal.js +2 -2
  641. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  642. package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
  643. package/dist/unstable/eventlog/EventLog.js +3 -2
  644. package/dist/unstable/eventlog/EventLog.js.map +1 -1
  645. package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
  646. package/dist/unstable/eventlog/SqlEventLogJournal.js +2 -2
  647. package/dist/unstable/eventlog/SqlEventLogJournal.js.map +1 -1
  648. package/dist/unstable/http/Cookies.d.ts +52 -7
  649. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  650. package/dist/unstable/http/Cookies.js +27 -6
  651. package/dist/unstable/http/Cookies.js.map +1 -1
  652. package/dist/unstable/http/Etag.d.ts.map +1 -1
  653. package/dist/unstable/http/Etag.js +5 -1
  654. package/dist/unstable/http/Etag.js.map +1 -1
  655. package/dist/unstable/http/Headers.d.ts +19 -2
  656. package/dist/unstable/http/Headers.d.ts.map +1 -1
  657. package/dist/unstable/http/Headers.js +40 -11
  658. package/dist/unstable/http/Headers.js.map +1 -1
  659. package/dist/unstable/http/HttpBody.d.ts +1 -1
  660. package/dist/unstable/http/HttpClient.d.ts +117 -15
  661. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  662. package/dist/unstable/http/HttpClient.js +191 -13
  663. package/dist/unstable/http/HttpClient.js.map +1 -1
  664. package/dist/unstable/http/HttpClientError.d.ts +7 -7
  665. package/dist/unstable/http/HttpClientRequest.d.ts +43 -15
  666. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  667. package/dist/unstable/http/HttpClientRequest.js +131 -21
  668. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  669. package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
  670. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  671. package/dist/unstable/http/HttpClientResponse.js +6 -1
  672. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  673. package/dist/unstable/http/HttpEffect.d.ts +7 -5
  674. package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
  675. package/dist/unstable/http/HttpEffect.js +46 -54
  676. package/dist/unstable/http/HttpEffect.js.map +1 -1
  677. package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
  678. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  679. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  680. package/dist/unstable/http/HttpMethod.d.ts +4 -4
  681. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  682. package/dist/unstable/http/HttpMethod.js +3 -3
  683. package/dist/unstable/http/HttpMethod.js.map +1 -1
  684. package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
  685. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  686. package/dist/unstable/http/HttpMiddleware.js +24 -32
  687. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  688. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  689. package/dist/unstable/http/HttpPlatform.js +3 -2
  690. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  691. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  692. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  693. package/dist/unstable/http/HttpRouter.js +7 -7
  694. package/dist/unstable/http/HttpRouter.js.map +1 -1
  695. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  696. package/dist/unstable/http/HttpServer.js +2 -2
  697. package/dist/unstable/http/HttpServer.js.map +1 -1
  698. package/dist/unstable/http/HttpServerError.d.ts +22 -34
  699. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  700. package/dist/unstable/http/HttpServerError.js +39 -45
  701. package/dist/unstable/http/HttpServerError.js.map +1 -1
  702. package/dist/unstable/http/HttpServerRequest.d.ts +15 -3
  703. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  704. package/dist/unstable/http/HttpServerRequest.js +301 -7
  705. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  706. package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
  707. package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
  708. package/dist/unstable/http/HttpServerRespondable.js +5 -5
  709. package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
  710. package/dist/unstable/http/HttpServerResponse.d.ts +50 -3
  711. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  712. package/dist/unstable/http/HttpServerResponse.js +236 -1
  713. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  714. package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
  715. package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
  716. package/dist/unstable/http/HttpStaticServer.js +353 -0
  717. package/dist/unstable/http/HttpStaticServer.js.map +1 -0
  718. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  719. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  720. package/dist/unstable/http/HttpTraceContext.js +27 -15
  721. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  722. package/dist/unstable/http/Multipart.d.ts +3 -3
  723. package/dist/unstable/http/Url.d.ts +604 -0
  724. package/dist/unstable/http/Url.d.ts.map +1 -0
  725. package/dist/unstable/http/Url.js +256 -0
  726. package/dist/unstable/http/Url.js.map +1 -0
  727. package/dist/unstable/http/UrlParams.d.ts +19 -10
  728. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  729. package/dist/unstable/http/UrlParams.js +6 -7
  730. package/dist/unstable/http/UrlParams.js.map +1 -1
  731. package/dist/unstable/http/index.d.ts +8 -0
  732. package/dist/unstable/http/index.d.ts.map +1 -1
  733. package/dist/unstable/http/index.js +8 -0
  734. package/dist/unstable/http/index.js.map +1 -1
  735. package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
  736. package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
  737. package/dist/unstable/http/internal/preResponseHandler.js +10 -0
  738. package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
  739. package/dist/unstable/httpapi/HttpApi.d.ts +4 -4
  740. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  741. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  742. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
  743. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  744. package/dist/unstable/httpapi/HttpApiBuilder.js +40 -27
  745. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  746. package/dist/unstable/httpapi/HttpApiClient.d.ts +83 -7
  747. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  748. package/dist/unstable/httpapi/HttpApiClient.js +78 -10
  749. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  750. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +207 -101
  751. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  752. package/dist/unstable/httpapi/HttpApiEndpoint.js +49 -43
  753. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  754. package/dist/unstable/httpapi/HttpApiError.d.ts +31 -14
  755. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  756. package/dist/unstable/httpapi/HttpApiError.js +125 -32
  757. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  758. package/dist/unstable/httpapi/HttpApiGroup.d.ts +4 -3
  759. package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
  760. package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
  761. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +46 -15
  762. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  763. package/dist/unstable/httpapi/HttpApiMiddleware.js +32 -3
  764. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  765. package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
  766. package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
  767. package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
  768. package/dist/unstable/httpapi/HttpApiSchema.d.ts +6 -3
  769. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  770. package/dist/unstable/httpapi/HttpApiSchema.js +20 -2
  771. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  772. package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
  773. package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
  774. package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
  775. package/dist/unstable/httpapi/OpenApi.d.ts +1 -0
  776. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  777. package/dist/unstable/httpapi/OpenApi.js +34 -26
  778. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  779. package/dist/unstable/observability/Otlp.d.ts +12 -12
  780. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  781. package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
  782. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  783. package/dist/unstable/observability/OtlpExporter.js +3 -3
  784. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  785. package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
  786. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  787. package/dist/unstable/observability/OtlpLogger.js +7 -4
  788. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  789. package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
  790. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  791. package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
  792. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  793. package/dist/unstable/observability/OtlpTracer.js +7 -3
  794. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  795. package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
  796. package/dist/unstable/persistence/KeyValueStore.js +6 -6
  797. package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
  798. package/dist/unstable/persistence/Persistable.d.ts +2 -2
  799. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  800. package/dist/unstable/persistence/Persistable.js +1 -1
  801. package/dist/unstable/persistence/Persistable.js.map +1 -1
  802. package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
  803. package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
  804. package/dist/unstable/persistence/PersistedCache.js +2 -1
  805. package/dist/unstable/persistence/PersistedCache.js.map +1 -1
  806. package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
  807. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  808. package/dist/unstable/persistence/PersistedQueue.js +12 -11
  809. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  810. package/dist/unstable/persistence/Persistence.d.ts +1 -1
  811. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  812. package/dist/unstable/persistence/Persistence.js +2 -2
  813. package/dist/unstable/persistence/Persistence.js.map +1 -1
  814. package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
  815. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  816. package/dist/unstable/persistence/RateLimiter.js +1 -1
  817. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  818. package/dist/unstable/process/ChildProcess.d.ts +5 -128
  819. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  820. package/dist/unstable/process/ChildProcess.js +1 -65
  821. package/dist/unstable/process/ChildProcess.js.map +1 -1
  822. package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
  823. package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
  824. package/dist/unstable/process/ChildProcessSpawner.js +21 -1
  825. package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
  826. package/dist/unstable/reactivity/Atom.d.ts +73 -12
  827. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  828. package/dist/unstable/reactivity/Atom.js +108 -25
  829. package/dist/unstable/reactivity/Atom.js.map +1 -1
  830. package/dist/unstable/reactivity/AtomHttpApi.d.ts +17 -15
  831. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  832. package/dist/unstable/reactivity/AtomHttpApi.js +45 -15
  833. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  834. package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
  835. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  836. package/dist/unstable/reactivity/AtomRegistry.js +54 -11
  837. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  838. package/dist/unstable/reactivity/AtomRpc.d.ts +9 -9
  839. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  840. package/dist/unstable/reactivity/AtomRpc.js +47 -21
  841. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  842. package/dist/unstable/reactivity/Hydration.d.ts +39 -0
  843. package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
  844. package/dist/unstable/reactivity/Hydration.js +76 -0
  845. package/dist/unstable/reactivity/Hydration.js.map +1 -0
  846. package/dist/unstable/reactivity/index.d.ts +4 -0
  847. package/dist/unstable/reactivity/index.d.ts.map +1 -1
  848. package/dist/unstable/reactivity/index.js +4 -0
  849. package/dist/unstable/reactivity/index.js.map +1 -1
  850. package/dist/unstable/rpc/Rpc.d.ts +6 -5
  851. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  852. package/dist/unstable/rpc/Rpc.js +4 -3
  853. package/dist/unstable/rpc/Rpc.js.map +1 -1
  854. package/dist/unstable/rpc/RpcClient.d.ts +5 -26
  855. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  856. package/dist/unstable/rpc/RpcClient.js +53 -43
  857. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  858. package/dist/unstable/rpc/RpcGroup.d.ts +3 -5
  859. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  860. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  861. package/dist/unstable/rpc/RpcMiddleware.d.ts +8 -8
  862. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  863. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  864. package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
  865. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  866. package/dist/unstable/rpc/RpcSchema.js +17 -2
  867. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  868. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  869. package/dist/unstable/rpc/RpcSerialization.js +39 -11
  870. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  871. package/dist/unstable/rpc/RpcServer.d.ts +6 -10
  872. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  873. package/dist/unstable/rpc/RpcServer.js +20 -19
  874. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  875. package/dist/unstable/rpc/Utils.d.ts.map +1 -1
  876. package/dist/unstable/rpc/Utils.js +3 -2
  877. package/dist/unstable/rpc/Utils.js.map +1 -1
  878. package/dist/unstable/schema/Model.d.ts +22 -1
  879. package/dist/unstable/schema/Model.d.ts.map +1 -1
  880. package/dist/unstable/schema/Model.js +15 -0
  881. package/dist/unstable/schema/Model.js.map +1 -1
  882. package/dist/unstable/schema/VariantSchema.d.ts +6 -6
  883. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  884. package/dist/unstable/schema/VariantSchema.js +6 -6
  885. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  886. package/dist/unstable/socket/Socket.d.ts +6 -5
  887. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  888. package/dist/unstable/socket/Socket.js +12 -9
  889. package/dist/unstable/socket/Socket.js.map +1 -1
  890. package/dist/unstable/socket/SocketServer.d.ts +3 -3
  891. package/dist/unstable/sql/Migrator.d.ts +1 -1
  892. package/dist/unstable/sql/Migrator.d.ts.map +1 -1
  893. package/dist/unstable/sql/Migrator.js +2 -2
  894. package/dist/unstable/sql/Migrator.js.map +1 -1
  895. package/dist/unstable/sql/SqlClient.d.ts +1 -1
  896. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  897. package/dist/unstable/sql/SqlClient.js +1 -1
  898. package/dist/unstable/sql/SqlClient.js.map +1 -1
  899. package/dist/unstable/sql/SqlError.d.ts +237 -17
  900. package/dist/unstable/sql/SqlError.d.ts.map +1 -1
  901. package/dist/unstable/sql/SqlError.js +260 -4
  902. package/dist/unstable/sql/SqlError.js.map +1 -1
  903. package/dist/unstable/sql/SqlModel.d.ts +2 -2
  904. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  905. package/dist/unstable/sql/SqlModel.js +3 -3
  906. package/dist/unstable/sql/SqlModel.js.map +1 -1
  907. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  908. package/dist/unstable/sql/SqlResolver.js +17 -8
  909. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  910. package/dist/unstable/sql/SqlSchema.d.ts +17 -6
  911. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  912. package/dist/unstable/sql/SqlSchema.js +17 -7
  913. package/dist/unstable/sql/SqlSchema.js.map +1 -1
  914. package/dist/unstable/sql/Statement.js +0 -1
  915. package/dist/unstable/sql/Statement.js.map +1 -1
  916. package/dist/unstable/workers/Worker.d.ts.map +1 -1
  917. package/dist/unstable/workers/Worker.js +2 -1
  918. package/dist/unstable/workers/Worker.js.map +1 -1
  919. package/dist/unstable/workflow/Activity.d.ts +5 -0
  920. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  921. package/dist/unstable/workflow/Activity.js +13 -0
  922. package/dist/unstable/workflow/Activity.js.map +1 -1
  923. package/dist/unstable/workflow/DurableClock.d.ts +3 -3
  924. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  925. package/dist/unstable/workflow/DurableClock.js +3 -3
  926. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  927. package/dist/unstable/workflow/DurableDeferred.js +8 -8
  928. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  929. package/dist/unstable/workflow/Workflow.d.ts +5 -4
  930. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  931. package/dist/unstable/workflow/Workflow.js +1 -1
  932. package/dist/unstable/workflow/Workflow.js.map +1 -1
  933. package/dist/unstable/workflow/WorkflowEngine.d.ts +17 -5
  934. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  935. package/dist/unstable/workflow/WorkflowEngine.js +153 -12
  936. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  937. package/package.json +2 -2
  938. package/src/Array.ts +304 -447
  939. package/src/BigDecimal.ts +117 -66
  940. package/src/BigInt.ts +49 -41
  941. package/src/Brand.ts +1 -1
  942. package/src/Cache.ts +9 -8
  943. package/src/Cause.ts +37 -2
  944. package/src/Channel.ts +582 -154
  945. package/src/Chunk.ts +149 -331
  946. package/src/Combiner.ts +280 -13
  947. package/src/Config.ts +195 -25
  948. package/src/Cron.ts +155 -63
  949. package/src/Data.ts +539 -376
  950. package/src/DateTime.ts +75 -256
  951. package/src/Deferred.ts +8 -6
  952. package/src/Duration.ts +122 -66
  953. package/src/Effect.ts +1484 -1157
  954. package/src/Encoding.ts +879 -0
  955. package/src/Equal.ts +278 -111
  956. package/src/Equivalence.ts +114 -52
  957. package/src/ErrorReporter.ts +458 -0
  958. package/src/Exit.ts +24 -12
  959. package/src/Fiber.ts +12 -3
  960. package/src/FiberHandle.ts +10 -9
  961. package/src/FiberMap.ts +22 -22
  962. package/src/FileSystem.ts +34 -31
  963. package/src/Filter.ts +52 -63
  964. package/src/Formatter.ts +253 -51
  965. package/src/Function.ts +2 -10
  966. package/src/Graph.ts +131 -117
  967. package/src/HashMap.ts +26 -19
  968. package/src/Iterable.ts +117 -63
  969. package/src/JsonSchema.ts +383 -10
  970. package/src/Latch.ts +194 -0
  971. package/src/Layer.ts +394 -160
  972. package/src/LayerMap.ts +11 -9
  973. package/src/LogLevel.ts +37 -0
  974. package/src/Logger.ts +33 -100
  975. package/src/ManagedRuntime.ts +35 -22
  976. package/src/Metric.ts +6 -8
  977. package/src/MutableHashMap.ts +9 -0
  978. package/src/MutableHashSet.ts +9 -0
  979. package/src/Newtype.ts +308 -0
  980. package/src/Number.ts +85 -26
  981. package/src/Optic.ts +948 -19
  982. package/src/Option.ts +34 -24
  983. package/src/Order.ts +39 -32
  984. package/src/PartitionedSemaphore.ts +288 -56
  985. package/src/Pipeable.ts +32 -1
  986. package/src/PlatformError.ts +5 -5
  987. package/src/Pool.ts +13 -11
  988. package/src/PubSub.ts +30 -20
  989. package/src/Pull.ts +1 -1
  990. package/src/Queue.ts +11 -9
  991. package/src/Random.ts +51 -14
  992. package/src/RcMap.ts +5 -5
  993. package/src/RcRef.ts +1 -1
  994. package/src/Record.ts +94 -199
  995. package/src/Reducer.ts +166 -7
  996. package/src/References.ts +283 -287
  997. package/src/Request.ts +3 -2
  998. package/src/RequestResolver.ts +29 -49
  999. package/src/Resource.ts +2 -1
  1000. package/src/Result.ts +2 -4
  1001. package/src/Runtime.ts +102 -6
  1002. package/src/Schedule.ts +458 -449
  1003. package/src/Scheduler.ts +49 -126
  1004. package/src/Schema.ts +3298 -392
  1005. package/src/SchemaAST.ts +172 -33
  1006. package/src/SchemaGetter.ts +19 -21
  1007. package/src/SchemaParser.ts +92 -27
  1008. package/src/SchemaRepresentation.ts +51 -26
  1009. package/src/SchemaTransformation.ts +198 -13
  1010. package/src/ScopedCache.ts +3 -3
  1011. package/src/Semaphore.ts +444 -0
  1012. package/src/ServiceMap.ts +144 -97
  1013. package/src/Sink.ts +83 -28
  1014. package/src/Stdio.ts +27 -4
  1015. package/src/Stream.ts +687 -617
  1016. package/src/String.ts +122 -69
  1017. package/src/Struct.ts +33 -7
  1018. package/src/SubscriptionRef.ts +101 -120
  1019. package/src/SynchronizedRef.ts +3 -2
  1020. package/src/Terminal.ts +2 -1
  1021. package/src/Tracer.ts +6 -5
  1022. package/src/Trie.ts +44 -31
  1023. package/src/TxChunk.ts +72 -53
  1024. package/src/TxDeferred.ts +394 -0
  1025. package/src/TxHashMap.ts +409 -343
  1026. package/src/TxHashSet.ts +113 -118
  1027. package/src/TxPriorityQueue.ts +766 -0
  1028. package/src/TxPubSub.ts +789 -0
  1029. package/src/TxQueue.ts +241 -251
  1030. package/src/TxReentrantLock.ts +753 -0
  1031. package/src/TxRef.ts +50 -38
  1032. package/src/TxSemaphore.ts +217 -44
  1033. package/src/TxSubscriptionRef.ts +639 -0
  1034. package/src/Types.ts +73 -19
  1035. package/src/Utils.ts +137 -111
  1036. package/src/index.ts +816 -56
  1037. package/src/internal/core.ts +12 -5
  1038. package/src/internal/dateTime.ts +91 -96
  1039. package/src/internal/effect.ts +844 -432
  1040. package/src/internal/hashMap.ts +12 -10
  1041. package/src/internal/option.ts +7 -0
  1042. package/src/internal/random.ts +20 -0
  1043. package/src/internal/rcRef.ts +4 -3
  1044. package/src/internal/references.ts +72 -0
  1045. package/src/internal/request.ts +2 -2
  1046. package/src/internal/schema/annotations.ts +2 -0
  1047. package/src/internal/schema/representation.ts +73 -94
  1048. package/src/internal/schema/schema.ts +1 -0
  1049. package/src/internal/schema/to-codec.ts +7 -17
  1050. package/src/internal/trie.ts +21 -15
  1051. package/src/testing/TestClock.ts +13 -11
  1052. package/src/testing/TestSchema.ts +332 -35
  1053. package/src/testing/index.ts +64 -1
  1054. package/src/unstable/ai/AiError.ts +111 -54
  1055. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  1056. package/src/unstable/ai/Chat.ts +134 -85
  1057. package/src/unstable/ai/EmbeddingModel.ts +209 -0
  1058. package/src/unstable/ai/LanguageModel.ts +683 -253
  1059. package/src/unstable/ai/McpSchema.ts +73 -13
  1060. package/src/unstable/ai/McpServer.ts +271 -61
  1061. package/src/unstable/ai/Model.ts +40 -9
  1062. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  1063. package/src/unstable/ai/Prompt.ts +37 -37
  1064. package/src/unstable/ai/Response.ts +25 -25
  1065. package/src/unstable/ai/ResponseIdTracker.ts +97 -0
  1066. package/src/unstable/ai/Tool.ts +42 -16
  1067. package/src/unstable/ai/Toolkit.ts +5 -14
  1068. package/src/unstable/ai/index.ts +24 -1
  1069. package/src/unstable/ai/internal/codec-transformer.ts +0 -7
  1070. package/src/unstable/cli/Argument.ts +2 -4
  1071. package/src/unstable/cli/CliError.ts +47 -59
  1072. package/src/unstable/cli/CliOutput.ts +85 -13
  1073. package/src/unstable/cli/Command.ts +801 -192
  1074. package/src/unstable/cli/Completions.ts +36 -0
  1075. package/src/unstable/cli/Flag.ts +2 -2
  1076. package/src/unstable/cli/GlobalFlag.ts +242 -0
  1077. package/src/unstable/cli/HelpDoc.ts +91 -11
  1078. package/src/unstable/cli/Param.ts +15 -11
  1079. package/src/unstable/cli/Primitive.ts +2 -2
  1080. package/src/unstable/cli/Prompt.ts +265 -101
  1081. package/src/unstable/cli/index.ts +10 -0
  1082. package/src/unstable/cli/internal/command.ts +109 -63
  1083. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +10 -4
  1084. package/src/unstable/cli/internal/config.ts +49 -0
  1085. package/src/unstable/cli/internal/help.ts +171 -0
  1086. package/src/unstable/cli/internal/parser.ts +71 -63
  1087. package/src/unstable/cluster/ClusterCron.ts +2 -2
  1088. package/src/unstable/cluster/ClusterSchema.ts +29 -1
  1089. package/src/unstable/cluster/ClusterWorkflowEngine.ts +62 -37
  1090. package/src/unstable/cluster/DeliverAt.ts +1 -1
  1091. package/src/unstable/cluster/Entity.ts +25 -22
  1092. package/src/unstable/cluster/EntityAddress.ts +1 -1
  1093. package/src/unstable/cluster/EntityResource.ts +4 -4
  1094. package/src/unstable/cluster/Envelope.ts +1 -1
  1095. package/src/unstable/cluster/K8sHttpClient.ts +5 -5
  1096. package/src/unstable/cluster/Message.ts +28 -15
  1097. package/src/unstable/cluster/MessageStorage.ts +66 -36
  1098. package/src/unstable/cluster/Reply.ts +7 -4
  1099. package/src/unstable/cluster/Runner.ts +1 -1
  1100. package/src/unstable/cluster/RunnerAddress.ts +1 -1
  1101. package/src/unstable/cluster/RunnerServer.ts +10 -13
  1102. package/src/unstable/cluster/Runners.ts +14 -12
  1103. package/src/unstable/cluster/ShardId.ts +2 -2
  1104. package/src/unstable/cluster/Sharding.ts +66 -49
  1105. package/src/unstable/cluster/ShardingConfig.ts +36 -37
  1106. package/src/unstable/cluster/SqlMessageStorage.ts +31 -19
  1107. package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
  1108. package/src/unstable/cluster/internal/entityManager.ts +50 -34
  1109. package/src/unstable/cluster/internal/entityReaper.ts +2 -1
  1110. package/src/unstable/cluster/internal/resourceRef.ts +2 -1
  1111. package/src/unstable/devtools/DevToolsClient.ts +23 -18
  1112. package/src/unstable/devtools/DevToolsSchema.ts +16 -3
  1113. package/src/unstable/encoding/Ndjson.ts +17 -17
  1114. package/src/unstable/encoding/Sse.ts +3 -5
  1115. package/src/unstable/eventlog/EventJournal.ts +2 -2
  1116. package/src/unstable/eventlog/EventLog.ts +3 -2
  1117. package/src/unstable/eventlog/SqlEventLogJournal.ts +2 -2
  1118. package/src/unstable/http/Cookies.ts +94 -11
  1119. package/src/unstable/http/Etag.ts +5 -3
  1120. package/src/unstable/http/Headers.ts +68 -18
  1121. package/src/unstable/http/HttpClient.ts +376 -34
  1122. package/src/unstable/http/HttpClientRequest.ts +151 -39
  1123. package/src/unstable/http/HttpClientResponse.ts +12 -6
  1124. package/src/unstable/http/HttpEffect.ts +54 -68
  1125. package/src/unstable/http/HttpIncomingMessage.ts +3 -2
  1126. package/src/unstable/http/HttpMethod.ts +16 -4
  1127. package/src/unstable/http/HttpMiddleware.ts +25 -39
  1128. package/src/unstable/http/HttpPlatform.ts +3 -2
  1129. package/src/unstable/http/HttpRouter.ts +9 -9
  1130. package/src/unstable/http/HttpServer.ts +3 -9
  1131. package/src/unstable/http/HttpServerError.ts +45 -47
  1132. package/src/unstable/http/HttpServerRequest.ts +407 -16
  1133. package/src/unstable/http/HttpServerRespondable.ts +6 -6
  1134. package/src/unstable/http/HttpServerResponse.ts +345 -7
  1135. package/src/unstable/http/HttpStaticServer.ts +456 -0
  1136. package/src/unstable/http/HttpTraceContext.ts +31 -17
  1137. package/src/unstable/http/Multipart.ts +2 -2
  1138. package/src/unstable/http/Url.ts +650 -0
  1139. package/src/unstable/http/UrlParams.ts +31 -19
  1140. package/src/unstable/http/index.ts +10 -0
  1141. package/src/unstable/http/internal/preResponseHandler.ts +15 -0
  1142. package/src/unstable/httpapi/HttpApi.ts +6 -6
  1143. package/src/unstable/httpapi/HttpApiBuilder.ts +106 -41
  1144. package/src/unstable/httpapi/HttpApiClient.ts +180 -28
  1145. package/src/unstable/httpapi/HttpApiEndpoint.ts +216 -104
  1146. package/src/unstable/httpapi/HttpApiError.ts +108 -30
  1147. package/src/unstable/httpapi/HttpApiGroup.ts +7 -6
  1148. package/src/unstable/httpapi/HttpApiMiddleware.ts +83 -22
  1149. package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
  1150. package/src/unstable/httpapi/HttpApiSchema.ts +21 -3
  1151. package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
  1152. package/src/unstable/httpapi/OpenApi.ts +44 -29
  1153. package/src/unstable/observability/Otlp.ts +12 -12
  1154. package/src/unstable/observability/OtlpExporter.ts +8 -5
  1155. package/src/unstable/observability/OtlpLogger.ts +13 -9
  1156. package/src/unstable/observability/OtlpMetrics.ts +4 -4
  1157. package/src/unstable/observability/OtlpTracer.ts +12 -8
  1158. package/src/unstable/persistence/KeyValueStore.ts +6 -6
  1159. package/src/unstable/persistence/Persistable.ts +3 -3
  1160. package/src/unstable/persistence/PersistedCache.ts +20 -9
  1161. package/src/unstable/persistence/PersistedQueue.ts +25 -24
  1162. package/src/unstable/persistence/Persistence.ts +3 -3
  1163. package/src/unstable/persistence/RateLimiter.ts +4 -4
  1164. package/src/unstable/process/ChildProcess.ts +6 -208
  1165. package/src/unstable/process/ChildProcessSpawner.ts +75 -14
  1166. package/src/unstable/reactivity/Atom.ts +212 -54
  1167. package/src/unstable/reactivity/AtomHttpApi.ts +81 -41
  1168. package/src/unstable/reactivity/AtomRegistry.ts +66 -12
  1169. package/src/unstable/reactivity/AtomRpc.ts +51 -20
  1170. package/src/unstable/reactivity/Hydration.ts +112 -0
  1171. package/src/unstable/reactivity/index.ts +5 -0
  1172. package/src/unstable/rpc/Rpc.ts +12 -12
  1173. package/src/unstable/rpc/RpcClient.ts +67 -96
  1174. package/src/unstable/rpc/RpcGroup.ts +7 -7
  1175. package/src/unstable/rpc/RpcMiddleware.ts +15 -9
  1176. package/src/unstable/rpc/RpcSchema.ts +23 -5
  1177. package/src/unstable/rpc/RpcSerialization.ts +49 -11
  1178. package/src/unstable/rpc/RpcServer.ts +31 -35
  1179. package/src/unstable/rpc/Utils.ts +3 -2
  1180. package/src/unstable/schema/Model.ts +31 -0
  1181. package/src/unstable/schema/VariantSchema.ts +10 -10
  1182. package/src/unstable/socket/Socket.ts +31 -27
  1183. package/src/unstable/sql/Migrator.ts +7 -5
  1184. package/src/unstable/sql/SqlClient.ts +6 -4
  1185. package/src/unstable/sql/SqlError.ts +365 -11
  1186. package/src/unstable/sql/SqlModel.ts +5 -5
  1187. package/src/unstable/sql/SqlResolver.ts +17 -7
  1188. package/src/unstable/sql/SqlSchema.ts +42 -26
  1189. package/src/unstable/sql/Statement.ts +0 -1
  1190. package/src/unstable/workers/Worker.ts +2 -1
  1191. package/src/unstable/workflow/Activity.ts +23 -0
  1192. package/src/unstable/workflow/DurableClock.ts +8 -8
  1193. package/src/unstable/workflow/DurableDeferred.ts +8 -8
  1194. package/src/unstable/workflow/Workflow.ts +7 -3
  1195. package/src/unstable/workflow/WorkflowEngine.ts +211 -19
  1196. package/dist/NullOr.d.ts +0 -149
  1197. package/dist/NullOr.d.ts.map +0 -1
  1198. package/dist/NullOr.js +0 -152
  1199. package/dist/NullOr.js.map +0 -1
  1200. package/dist/encoding/Base64.d.ts +0 -67
  1201. package/dist/encoding/Base64.d.ts.map +0 -1
  1202. package/dist/encoding/Base64.js +0 -146
  1203. package/dist/encoding/Base64.js.map +0 -1
  1204. package/dist/encoding/Base64Url.d.ts +0 -60
  1205. package/dist/encoding/Base64Url.d.ts.map +0 -1
  1206. package/dist/encoding/Base64Url.js +0 -89
  1207. package/dist/encoding/Base64Url.js.map +0 -1
  1208. package/dist/encoding/EncodingError.d.ts +0 -31
  1209. package/dist/encoding/EncodingError.d.ts.map +0 -1
  1210. package/dist/encoding/EncodingError.js +0 -22
  1211. package/dist/encoding/EncodingError.js.map +0 -1
  1212. package/dist/encoding/Hex.d.ts +0 -61
  1213. package/dist/encoding/Hex.d.ts.map +0 -1
  1214. package/dist/encoding/Hex.js +0 -115
  1215. package/dist/encoding/Hex.js.map +0 -1
  1216. package/dist/encoding/index.d.ts +0 -26
  1217. package/dist/encoding/index.d.ts.map +0 -1
  1218. package/dist/encoding/index.js +0 -27
  1219. package/dist/encoding/index.js.map +0 -1
  1220. package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
  1221. package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
  1222. package/dist/unstable/cli/internal/builtInFlags.js +0 -44
  1223. package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
  1224. package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
  1225. package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
  1226. package/dist/unstable/cli/internal/completions/Completions.js +0 -23
  1227. package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
  1228. package/src/NullOr.ts +0 -204
  1229. package/src/encoding/Base64.ts +0 -366
  1230. package/src/encoding/Base64Url.ts +0 -104
  1231. package/src/encoding/EncodingError.ts +0 -35
  1232. package/src/encoding/Hex.ts +0 -390
  1233. package/src/encoding/index.ts +0 -31
  1234. package/src/unstable/cli/internal/builtInFlags.ts +0 -78
  1235. package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/dist/Effect.d.ts CHANGED
@@ -40,12 +40,14 @@
40
40
  *
41
41
  * @example
42
42
  * ```ts
43
- * import { Effect } from "effect"
43
+ * import { Data, Effect } from "effect"
44
+ *
45
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
44
46
  *
45
47
  * // Effect that may fail
46
48
  * const divide = (a: number, b: number) =>
47
49
  * b === 0
48
- * ? Effect.fail(new Error("Division by zero"))
50
+ * ? Effect.fail(new DiscountRateError())
49
51
  * : Effect.succeed(a / b)
50
52
  *
51
53
  * // Error handling
@@ -78,7 +80,7 @@ import { type LazyArg } from "./Function.ts";
78
80
  import type { TypeLambda } from "./HKT.ts";
79
81
  import type * as Layer from "./Layer.ts";
80
82
  import type { Logger } from "./Logger.ts";
81
- import type { LogLevel } from "./LogLevel.ts";
83
+ import type { Severity } from "./LogLevel.ts";
82
84
  import * as Metric from "./Metric.ts";
83
85
  import type { Option } from "./Option.ts";
84
86
  import type { Pipeable } from "./Pipeable.ts";
@@ -92,7 +94,7 @@ import type { Scope } from "./Scope.ts";
92
94
  import * as ServiceMap from "./ServiceMap.ts";
93
95
  import type { AnySpan, ParentSpan, Span, SpanLink, SpanOptions, SpanOptionsNoTrace, TraceOptions, Tracer } from "./Tracer.ts";
94
96
  import type { TxRef } from "./TxRef.ts";
95
- import type { Concurrency, Covariant, EqualsWith, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NoInfer, ReasonOf, ReasonTags, Tags, unassigned } from "./Types.ts";
97
+ import type { Concurrency, Covariant, EqualsWith, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NarrowReason, NoInfer, OmitReason, ReasonOf, ReasonTags, Simplify, Tags, unassigned } from "./Types.ts";
96
98
  import type * as Unify from "./Unify.ts";
97
99
  declare const TypeId: "~effect/Effect";
98
100
  /**
@@ -111,13 +113,15 @@ declare const TypeId: "~effect/Effect";
111
113
  *
112
114
  * @example
113
115
  * ```ts
114
- * import { Effect } from "effect"
116
+ * import { Data, Effect } from "effect"
117
+ *
118
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
115
119
  *
116
120
  * // A simple effect that succeeds with a value
117
121
  * const success = Effect.succeed(42)
118
122
  *
119
- * // An effect that may fail
120
- * const risky = Effect.fail(new Error("Something went wrong"))
123
+ * // An effect that will always fail
124
+ * const risky = Effect.fail(new TaskError({ message: "Something went wrong" }))
121
125
  *
122
126
  * // Effects can be composed using generator functions
123
127
  * const program = Effect.gen(function*() {
@@ -134,7 +138,7 @@ export interface Effect<out A, out E = never, out R = never> extends Pipeable, Y
134
138
  readonly [TypeId]: Variance<A, E, R>;
135
139
  [Unify.typeSymbol]?: unknown;
136
140
  [Unify.unifySymbol]?: EffectUnify<this>;
137
- [Unify.ignoreSymbol]?: EffectUnifyIgnore;
141
+ [Unify.ignoreSymbol]?: {};
138
142
  }
139
143
  /**
140
144
  * A type that can be yielded in an Effect generator function.
@@ -191,21 +195,6 @@ export interface EffectUnify<A extends {
191
195
  }> {
192
196
  Effect?: () => A[Unify.typeSymbol] extends Effect<infer A0, infer E0, infer R0> | infer _ ? Effect<A0, E0, R0> : never;
193
197
  }
194
- /**
195
- * @category Models
196
- * @since 2.0.0
197
- * @example
198
- * ```ts
199
- * import type { Effect } from "effect"
200
- *
201
- * // EffectUnifyIgnore is used internally to control type unification
202
- * // It prevents certain types from being unified with Effect types
203
- * declare const ignored: Effect.EffectUnifyIgnore
204
- * ```
205
- */
206
- export interface EffectUnifyIgnore {
207
- Effect?: true;
208
- }
209
198
  /**
210
199
  * @category Type Lambdas
211
200
  * @since 2.0.0
@@ -367,13 +356,15 @@ export declare namespace All {
367
356
  * @category Models
368
357
  * @example
369
358
  * ```ts
370
- * import { Effect } from "effect"
359
+ * import { Data, Effect } from "effect"
360
+ *
361
+ * class OopsError extends Data.TaggedError("OopsError")<{}> {}
371
362
  *
372
363
  * // EffectAny represents an Effect with any type parameters
373
364
  * const effects: Array<Effect.All.EffectAny> = [
374
365
  * Effect.succeed(42),
375
366
  * Effect.succeed("hello"),
376
- * Effect.fail(new Error("oops"))
367
+ * Effect.fail(new OopsError())
377
368
  * ]
378
369
  * ```
379
370
  */
@@ -625,7 +616,6 @@ export declare namespace All {
625
616
  * ```
626
617
  *
627
618
  * @see {@link forEach} for iterating over elements and applying an effect.
628
- * @see {@link allWith} for a data-last version of this function.
629
619
  *
630
620
  * @since 2.0.0
631
621
  * @category Collecting
@@ -724,6 +714,291 @@ export declare const partition: {
724
714
  readonly concurrency?: Concurrency | undefined;
725
715
  }): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>;
726
716
  };
717
+ /**
718
+ * Applies an effectful function to each element and accumulates all failures.
719
+ *
720
+ * This function always evaluates every element. If at least one effect fails,
721
+ * all failures are returned as a non-empty array and successes are discarded.
722
+ * If all effects succeed, it returns all collected successes.
723
+ *
724
+ * Use `discard: true` to ignore successful values while still validating all
725
+ * elements.
726
+ *
727
+ * @example
728
+ * ```ts
729
+ * import { Effect } from "effect"
730
+ *
731
+ * const program = Effect.validate([0, 1, 2, 3], (n) =>
732
+ * n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
733
+ * )
734
+ *
735
+ * Effect.runPromiseExit(program).then(console.log)
736
+ * // {
737
+ * // _id: 'Exit',
738
+ * // _tag: 'Failure',
739
+ * // cause: {
740
+ * // _id: 'Cause',
741
+ * // reasons: [
742
+ * // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
743
+ * // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
744
+ * // ]
745
+ * // }
746
+ * // }
747
+ * ```
748
+ *
749
+ * @since 4.0.0
750
+ * @category Error Accumulation
751
+ */
752
+ export declare const validate: {
753
+ /**
754
+ * Applies an effectful function to each element and accumulates all failures.
755
+ *
756
+ * This function always evaluates every element. If at least one effect fails,
757
+ * all failures are returned as a non-empty array and successes are discarded.
758
+ * If all effects succeed, it returns all collected successes.
759
+ *
760
+ * Use `discard: true` to ignore successful values while still validating all
761
+ * elements.
762
+ *
763
+ * @example
764
+ * ```ts
765
+ * import { Effect } from "effect"
766
+ *
767
+ * const program = Effect.validate([0, 1, 2, 3], (n) =>
768
+ * n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
769
+ * )
770
+ *
771
+ * Effect.runPromiseExit(program).then(console.log)
772
+ * // {
773
+ * // _id: 'Exit',
774
+ * // _tag: 'Failure',
775
+ * // cause: {
776
+ * // _id: 'Cause',
777
+ * // reasons: [
778
+ * // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
779
+ * // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
780
+ * // ]
781
+ * // }
782
+ * // }
783
+ * ```
784
+ *
785
+ * @since 4.0.0
786
+ * @category Error Accumulation
787
+ */
788
+ <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
789
+ readonly concurrency?: Concurrency | undefined;
790
+ readonly discard?: false | undefined;
791
+ } | undefined): (elements: Iterable<A>) => Effect<Array<B>, Arr.NonEmptyArray<E>, R>;
792
+ /**
793
+ * Applies an effectful function to each element and accumulates all failures.
794
+ *
795
+ * This function always evaluates every element. If at least one effect fails,
796
+ * all failures are returned as a non-empty array and successes are discarded.
797
+ * If all effects succeed, it returns all collected successes.
798
+ *
799
+ * Use `discard: true` to ignore successful values while still validating all
800
+ * elements.
801
+ *
802
+ * @example
803
+ * ```ts
804
+ * import { Effect } from "effect"
805
+ *
806
+ * const program = Effect.validate([0, 1, 2, 3], (n) =>
807
+ * n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
808
+ * )
809
+ *
810
+ * Effect.runPromiseExit(program).then(console.log)
811
+ * // {
812
+ * // _id: 'Exit',
813
+ * // _tag: 'Failure',
814
+ * // cause: {
815
+ * // _id: 'Cause',
816
+ * // reasons: [
817
+ * // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
818
+ * // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
819
+ * // ]
820
+ * // }
821
+ * // }
822
+ * ```
823
+ *
824
+ * @since 4.0.0
825
+ * @category Error Accumulation
826
+ */
827
+ <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options: {
828
+ readonly concurrency?: Concurrency | undefined;
829
+ readonly discard: true;
830
+ }): (elements: Iterable<A>) => Effect<void, Arr.NonEmptyArray<E>, R>;
831
+ /**
832
+ * Applies an effectful function to each element and accumulates all failures.
833
+ *
834
+ * This function always evaluates every element. If at least one effect fails,
835
+ * all failures are returned as a non-empty array and successes are discarded.
836
+ * If all effects succeed, it returns all collected successes.
837
+ *
838
+ * Use `discard: true` to ignore successful values while still validating all
839
+ * elements.
840
+ *
841
+ * @example
842
+ * ```ts
843
+ * import { Effect } from "effect"
844
+ *
845
+ * const program = Effect.validate([0, 1, 2, 3], (n) =>
846
+ * n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
847
+ * )
848
+ *
849
+ * Effect.runPromiseExit(program).then(console.log)
850
+ * // {
851
+ * // _id: 'Exit',
852
+ * // _tag: 'Failure',
853
+ * // cause: {
854
+ * // _id: 'Cause',
855
+ * // reasons: [
856
+ * // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
857
+ * // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
858
+ * // ]
859
+ * // }
860
+ * // }
861
+ * ```
862
+ *
863
+ * @since 4.0.0
864
+ * @category Error Accumulation
865
+ */
866
+ <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
867
+ readonly concurrency?: Concurrency | undefined;
868
+ readonly discard?: false | undefined;
869
+ } | undefined): Effect<Array<B>, Arr.NonEmptyArray<E>, R>;
870
+ /**
871
+ * Applies an effectful function to each element and accumulates all failures.
872
+ *
873
+ * This function always evaluates every element. If at least one effect fails,
874
+ * all failures are returned as a non-empty array and successes are discarded.
875
+ * If all effects succeed, it returns all collected successes.
876
+ *
877
+ * Use `discard: true` to ignore successful values while still validating all
878
+ * elements.
879
+ *
880
+ * @example
881
+ * ```ts
882
+ * import { Effect } from "effect"
883
+ *
884
+ * const program = Effect.validate([0, 1, 2, 3], (n) =>
885
+ * n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
886
+ * )
887
+ *
888
+ * Effect.runPromiseExit(program).then(console.log)
889
+ * // {
890
+ * // _id: 'Exit',
891
+ * // _tag: 'Failure',
892
+ * // cause: {
893
+ * // _id: 'Cause',
894
+ * // reasons: [
895
+ * // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
896
+ * // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
897
+ * // ]
898
+ * // }
899
+ * // }
900
+ * ```
901
+ *
902
+ * @since 4.0.0
903
+ * @category Error Accumulation
904
+ */
905
+ <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options: {
906
+ readonly concurrency?: Concurrency | undefined;
907
+ readonly discard: true;
908
+ }): Effect<void, Arr.NonEmptyArray<E>, R>;
909
+ };
910
+ /**
911
+ * Returns the first element that satisfies an effectful predicate.
912
+ *
913
+ * The predicate receives the element and its index. Evaluation short-circuits
914
+ * as soon as an element matches.
915
+ *
916
+ * @example
917
+ * ```ts
918
+ * import { Effect } from "effect"
919
+ *
920
+ * const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
921
+ *
922
+ * Effect.runPromise(program).then(console.log)
923
+ * // { _id: 'Option', _tag: 'Some', value: 3 }
924
+ * ```
925
+ *
926
+ * @since 2.0.0
927
+ * @category Collecting
928
+ */
929
+ export declare const findFirst: {
930
+ /**
931
+ * Returns the first element that satisfies an effectful predicate.
932
+ *
933
+ * The predicate receives the element and its index. Evaluation short-circuits
934
+ * as soon as an element matches.
935
+ *
936
+ * @example
937
+ * ```ts
938
+ * import { Effect } from "effect"
939
+ *
940
+ * const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
941
+ *
942
+ * Effect.runPromise(program).then(console.log)
943
+ * // { _id: 'Option', _tag: 'Some', value: 3 }
944
+ * ```
945
+ *
946
+ * @since 2.0.0
947
+ * @category Collecting
948
+ */
949
+ <A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): (elements: Iterable<A>) => Effect<Option<A>, E, R>;
950
+ /**
951
+ * Returns the first element that satisfies an effectful predicate.
952
+ *
953
+ * The predicate receives the element and its index. Evaluation short-circuits
954
+ * as soon as an element matches.
955
+ *
956
+ * @example
957
+ * ```ts
958
+ * import { Effect } from "effect"
959
+ *
960
+ * const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
961
+ *
962
+ * Effect.runPromise(program).then(console.log)
963
+ * // { _id: 'Option', _tag: 'Some', value: 3 }
964
+ * ```
965
+ *
966
+ * @since 2.0.0
967
+ * @category Collecting
968
+ */
969
+ <A, E, R>(elements: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): Effect<Option<A>, E, R>;
970
+ };
971
+ /**
972
+ * Returns the first value that passes an effectful `FilterEffect`.
973
+ *
974
+ * The filter receives the element and index. Evaluation short-circuits on the
975
+ * first `Result.succeed` and returns the transformed value in `Option.some`.
976
+ *
977
+ * @since 4.0.0
978
+ * @category Collecting
979
+ */
980
+ export declare const findFirstFilter: {
981
+ /**
982
+ * Returns the first value that passes an effectful `FilterEffect`.
983
+ *
984
+ * The filter receives the element and index. Evaluation short-circuits on the
985
+ * first `Result.succeed` and returns the transformed value in `Option.some`.
986
+ *
987
+ * @since 4.0.0
988
+ * @category Collecting
989
+ */
990
+ <A, B, X, E, R>(filter: (input: NoInfer<A>, i: number) => Effect<Result.Result<B, X>, E, R>): (elements: Iterable<A>) => Effect<Option<B>, E, R>;
991
+ /**
992
+ * Returns the first value that passes an effectful `FilterEffect`.
993
+ *
994
+ * The filter receives the element and index. Evaluation short-circuits on the
995
+ * first `Result.succeed` and returns the transformed value in `Option.some`.
996
+ *
997
+ * @since 4.0.0
998
+ * @category Collecting
999
+ */
1000
+ <A, B, X, E, R>(elements: Iterable<A>, filter: (input: NoInfer<A>, i: number) => Effect<Result.Result<B, X>, E, R>): Effect<Option<B>, E, R>;
1001
+ };
727
1002
  /**
728
1003
  * Executes an effectful operation for each element in an `Iterable`.
729
1004
  *
@@ -1068,16 +1343,18 @@ export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike
1068
1343
  *
1069
1344
  * @example Custom Error Handling
1070
1345
  * ```ts
1071
- * import { Effect } from "effect"
1346
+ * import { Data, Effect } from "effect"
1347
+ *
1348
+ * class TodoFetchError extends Data.TaggedError("TodoFetchError")<{ readonly cause: unknown }> {}
1072
1349
  *
1073
1350
  * const getTodo = (id: number) =>
1074
1351
  * Effect.tryPromise({
1075
1352
  * try: () => fetch(`https://jsonplaceholder.typicode.com/todos/${id}`),
1076
1353
  * // remap the error
1077
- * catch: (unknown) => new Error(`something went wrong ${unknown}`)
1354
+ * catch: (cause) => new TodoFetchError({ cause })
1078
1355
  * })
1079
1356
  *
1080
- * // ┌─── Effect<Response, Error, never>
1357
+ * // ┌─── Effect<Response, TodoFetchError, never>
1081
1358
  * // ▼
1082
1359
  * const program = getTodo(1)
1083
1360
  * ```
@@ -1307,8 +1584,13 @@ undefined_ as undefined };
1307
1584
  *
1308
1585
  * **When to Use**
1309
1586
  *
1310
- * Use `Effect.async` when dealing with APIs that use callback-style instead of
1587
+ * Use `Effect.callback` when dealing with APIs that use callback-style instead of
1311
1588
  * `async/await` or `Promise`.
1589
+ * * **Previously Known As**
1590
+ *
1591
+ * This API replaces the following from Effect 3.x:
1592
+ *
1593
+ * - `Effect.async`
1312
1594
  *
1313
1595
  * @example
1314
1596
  * ```ts
@@ -1352,6 +1634,90 @@ export declare const callback: <A, E = never, R = never>(register: (this: Schedu
1352
1634
  * @category Creating Effects
1353
1635
  */
1354
1636
  export declare const never: Effect<never>;
1637
+ /**
1638
+ * An `Effect` containing an empty record `{}`, used as the starting point for
1639
+ * do notation chains.
1640
+ *
1641
+ * @example
1642
+ * ```ts
1643
+ * import { Effect } from "effect"
1644
+ * import { pipe } from "effect/Function"
1645
+ *
1646
+ * const program = pipe(
1647
+ * Effect.Do,
1648
+ * Effect.bind("x", () => Effect.succeed(2)),
1649
+ * Effect.bind("y", ({ x }) => Effect.succeed(x + 1)),
1650
+ * Effect.let("sum", ({ x, y }) => x + y)
1651
+ * )
1652
+ * ```
1653
+ *
1654
+ * @since 4.0.0
1655
+ * @category Do notation
1656
+ */
1657
+ export declare const Do: Effect<{}>;
1658
+ /**
1659
+ * Gives a name to the success value of an `Effect`, creating a single-key
1660
+ * record used in do notation pipelines.
1661
+ *
1662
+ * @since 4.0.0
1663
+ * @category Do notation
1664
+ */
1665
+ export declare const bindTo: {
1666
+ /**
1667
+ * Gives a name to the success value of an `Effect`, creating a single-key
1668
+ * record used in do notation pipelines.
1669
+ *
1670
+ * @since 4.0.0
1671
+ * @category Do notation
1672
+ */
1673
+ <N extends string>(name: N): <A, E, R>(self: Effect<A, E, R>) => Effect<{
1674
+ [K in N]: A;
1675
+ }, E, R>;
1676
+ /**
1677
+ * Gives a name to the success value of an `Effect`, creating a single-key
1678
+ * record used in do notation pipelines.
1679
+ *
1680
+ * @since 4.0.0
1681
+ * @category Do notation
1682
+ */
1683
+ <A, E, R, N extends string>(self: Effect<A, E, R>, name: N): Effect<{
1684
+ [K in N]: A;
1685
+ }, E, R>;
1686
+ };
1687
+ declare const let_: {
1688
+ <N extends string, A extends Record<string, any>, B>(name: N, f: (a: NoInfer<A>) => B): <E, R>(self: Effect<A, E, R>) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>;
1689
+ <A extends Record<string, any>, E, R, B, N extends string>(self: Effect<A, E, R>, name: N, f: (a: NoInfer<A>) => B): Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>;
1690
+ };
1691
+ export {
1692
+ /**
1693
+ * Adds a computed plain value to the do notation record.
1694
+ *
1695
+ * @since 4.0.0
1696
+ * @category Do notation
1697
+ */
1698
+ let_ as let };
1699
+ /**
1700
+ * Adds an `Effect` value to the do notation record under a given name.
1701
+ *
1702
+ * @since 4.0.0
1703
+ * @category Do notation
1704
+ */
1705
+ export declare const bind: {
1706
+ /**
1707
+ * Adds an `Effect` value to the do notation record under a given name.
1708
+ *
1709
+ * @since 4.0.0
1710
+ * @category Do notation
1711
+ */
1712
+ <N extends string, A extends Record<string, any>, B, E2, R2>(name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>;
1713
+ /**
1714
+ * Adds an `Effect` value to the do notation record under a given name.
1715
+ *
1716
+ * @since 4.0.0
1717
+ * @category Do notation
1718
+ */
1719
+ <A extends Record<string, any>, E, R, B, E2, R2, N extends string>(self: Effect<A, E, R>, name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>;
1720
+ };
1355
1721
  /**
1356
1722
  * Provides a way to write effectful code using generator functions, simplifying
1357
1723
  * control flow and error handling.
@@ -1369,16 +1735,18 @@ export declare const never: Effect<never>;
1369
1735
  *
1370
1736
  * @example
1371
1737
  * ```ts
1372
- * import { Effect } from "effect"
1738
+ * import { Data, Effect } from "effect"
1739
+ *
1740
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
1373
1741
  *
1374
1742
  * const addServiceCharge = (amount: number) => amount + 1
1375
1743
  *
1376
1744
  * const applyDiscount = (
1377
1745
  * total: number,
1378
1746
  * discountRate: number
1379
- * ): Effect.Effect<number, Error> =>
1747
+ * ): Effect.Effect<number, DiscountRateError> =>
1380
1748
  * discountRate === 0
1381
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
1749
+ * ? Effect.fail(new DiscountRateError())
1382
1750
  * : Effect.succeed(total - (total * discountRate) / 100)
1383
1751
  *
1384
1752
  * const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
@@ -1418,16 +1786,18 @@ export declare const gen: {
1418
1786
  *
1419
1787
  * @example
1420
1788
  * ```ts
1421
- * import { Effect } from "effect"
1789
+ * import { Data, Effect } from "effect"
1790
+ *
1791
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
1422
1792
  *
1423
1793
  * const addServiceCharge = (amount: number) => amount + 1
1424
1794
  *
1425
1795
  * const applyDiscount = (
1426
1796
  * total: number,
1427
1797
  * discountRate: number
1428
- * ): Effect.Effect<number, Error> =>
1798
+ * ): Effect.Effect<number, DiscountRateError> =>
1429
1799
  * discountRate === 0
1430
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
1800
+ * ? Effect.fail(new DiscountRateError())
1431
1801
  * : Effect.succeed(total - (total * discountRate) / 100)
1432
1802
  *
1433
1803
  * const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
@@ -1471,16 +1841,18 @@ export declare const gen: {
1471
1841
  *
1472
1842
  * @example
1473
1843
  * ```ts
1474
- * import { Effect } from "effect"
1844
+ * import { Data, Effect } from "effect"
1845
+ *
1846
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
1475
1847
  *
1476
1848
  * const addServiceCharge = (amount: number) => amount + 1
1477
1849
  *
1478
1850
  * const applyDiscount = (
1479
1851
  * total: number,
1480
1852
  * discountRate: number
1481
- * ): Effect.Effect<number, Error> =>
1853
+ * ): Effect.Effect<number, DiscountRateError> =>
1482
1854
  * discountRate === 0
1483
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
1855
+ * ? Effect.fail(new DiscountRateError())
1484
1856
  * : Effect.succeed(total - (total * discountRate) / 100)
1485
1857
  *
1486
1858
  * const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
@@ -1535,12 +1907,14 @@ export declare namespace gen {
1535
1907
  * @example
1536
1908
  * ```ts
1537
1909
  * // Title: Creating a Failed Effect
1538
- * import { Effect } from "effect"
1910
+ * import { Data, Effect } from "effect"
1911
+ *
1912
+ * class OperationFailedError extends Data.TaggedError("OperationFailedError")<{}> {}
1539
1913
  *
1540
- * // ┌─── Effect<never, Error, never>
1914
+ * // ┌─── Effect<never, OperationFailedError, never>
1541
1915
  * // ▼
1542
1916
  * const failure = Effect.fail(
1543
- * new Error("Operation failed due to network error")
1917
+ * new OperationFailedError()
1544
1918
  * )
1545
1919
  * ```
1546
1920
  *
@@ -1556,9 +1930,11 @@ export declare const fail: <E>(error: E) => Effect<never, E>;
1556
1930
  *
1557
1931
  * @example
1558
1932
  * ```ts
1559
- * import { Effect } from "effect"
1933
+ * import { Data, Effect } from "effect"
1560
1934
  *
1561
- * const program = Effect.failSync(() => new Error("Something went wrong"))
1935
+ * class ProgramError extends Data.TaggedError("ProgramError")<{ readonly failedAt: Date }> {}
1936
+ *
1937
+ * const program = Effect.failSync(() => new ProgramError({ failedAt: new Date() }))
1562
1938
  *
1563
1939
  * Effect.runPromiseExit(program).then(console.log)
1564
1940
  * // Output: { _id: 'Exit', _tag: 'Failure', cause: ... }
@@ -1705,12 +2081,14 @@ export {
1705
2081
  *
1706
2082
  * @example Custom Error Handling
1707
2083
  * ```ts
1708
- * import { Effect } from "effect"
2084
+ * import { Data, Effect } from "effect"
2085
+ *
2086
+ * class JsonParsingError extends Data.TaggedError("JsonParsingError")<{ readonly cause: unknown }> {}
1709
2087
  *
1710
2088
  * const parseJSON = (input: string) =>
1711
2089
  * Effect.try({
1712
2090
  * try: () => JSON.parse(input),
1713
- * catch: (error) => new Error(`JSON parsing failed: ${error}`)
2091
+ * catch: (cause) => new JsonParsingError({ cause })
1714
2092
  * })
1715
2093
  *
1716
2094
  * Effect.runPromiseExit(parseJSON("invalid json")).then(console.log)
@@ -1832,17 +2210,17 @@ export declare const fromOption: <A>(option: Option<A>) => Effect<A, Cause.NoSuc
1832
2210
  * ```ts
1833
2211
  * import { Console, Effect } from "effect"
1834
2212
  *
1835
- * const input: string | null = null
1836
- *
1837
- * const program = Effect.gen(function*() {
2213
+ * const program = Effect.fn(function*(input: string | null) {
1838
2214
  * const value = yield* Effect.fromNullishOr(input)
1839
2215
  * yield* Console.log(value)
1840
- * }).pipe(
2216
+ * },
1841
2217
  * Effect.catch(() => Console.log("missing"))
1842
2218
  * )
1843
2219
  *
1844
- * Effect.runPromise(program)
2220
+ * Effect.runPromise(program(null))
1845
2221
  * // Output: missing
2222
+ * Effect.runPromise(program("hello"))
2223
+ * // Output: hello
1846
2224
  * ```
1847
2225
  *
1848
2226
  * @since 4.0.0
@@ -1903,15 +2281,17 @@ export declare const fromYieldable: <Self extends Yieldable.Any, A, E, R>(yielda
1903
2281
  *
1904
2282
  * @example
1905
2283
  * ```ts
1906
- * import { Effect, pipe } from "effect"
2284
+ * import { Data, Effect, pipe } from "effect"
2285
+ *
2286
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
1907
2287
  *
1908
2288
  * // Function to apply a discount safely to a transaction amount
1909
2289
  * const applyDiscount = (
1910
2290
  * total: number,
1911
2291
  * discountRate: number
1912
- * ): Effect.Effect<number, Error> =>
2292
+ * ): Effect.Effect<number, DiscountRateError> =>
1913
2293
  * discountRate === 0
1914
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2294
+ * ? Effect.fail(new DiscountRateError())
1915
2295
  * : Effect.succeed(total - (total * discountRate) / 100)
1916
2296
  *
1917
2297
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -1965,15 +2345,17 @@ export declare const flatMap: {
1965
2345
  *
1966
2346
  * @example
1967
2347
  * ```ts
1968
- * import { Effect, pipe } from "effect"
2348
+ * import { Data, Effect, pipe } from "effect"
2349
+ *
2350
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
1969
2351
  *
1970
2352
  * // Function to apply a discount safely to a transaction amount
1971
2353
  * const applyDiscount = (
1972
2354
  * total: number,
1973
2355
  * discountRate: number
1974
- * ): Effect.Effect<number, Error> =>
2356
+ * ): Effect.Effect<number, DiscountRateError> =>
1975
2357
  * discountRate === 0
1976
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2358
+ * ? Effect.fail(new DiscountRateError())
1977
2359
  * : Effect.succeed(total - (total * discountRate) / 100)
1978
2360
  *
1979
2361
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2027,15 +2409,17 @@ export declare const flatMap: {
2027
2409
  *
2028
2410
  * @example
2029
2411
  * ```ts
2030
- * import { Effect, pipe } from "effect"
2412
+ * import { Data, Effect, pipe } from "effect"
2413
+ *
2414
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
2031
2415
  *
2032
2416
  * // Function to apply a discount safely to a transaction amount
2033
2417
  * const applyDiscount = (
2034
2418
  * total: number,
2035
2419
  * discountRate: number
2036
- * ): Effect.Effect<number, Error> =>
2420
+ * ): Effect.Effect<number, DiscountRateError> =>
2037
2421
  * discountRate === 0
2038
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2422
+ * ? Effect.fail(new DiscountRateError())
2039
2423
  * : Effect.succeed(total - (total * discountRate) / 100)
2040
2424
  *
2041
2425
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2120,15 +2504,17 @@ export declare const flatten: <A, E, R, E2, R2>(self: Effect<Effect<A, E, R>, E2
2120
2504
  *
2121
2505
  * @example Applying a Discount Based on Fetched Amount
2122
2506
  * ```ts
2123
- * import { Effect, pipe } from "effect"
2507
+ * import { Data, Effect, pipe } from "effect"
2508
+ *
2509
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
2124
2510
  *
2125
2511
  * // Function to apply a discount safely to a transaction amount
2126
2512
  * const applyDiscount = (
2127
2513
  * total: number,
2128
2514
  * discountRate: number
2129
- * ): Effect.Effect<number, Error> =>
2515
+ * ): Effect.Effect<number, DiscountRateError> =>
2130
2516
  * discountRate === 0
2131
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2517
+ * ? Effect.fail(new DiscountRateError())
2132
2518
  * : Effect.succeed(total - (total * discountRate) / 100)
2133
2519
  *
2134
2520
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2201,15 +2587,17 @@ export declare const andThen: {
2201
2587
  *
2202
2588
  * @example Applying a Discount Based on Fetched Amount
2203
2589
  * ```ts
2204
- * import { Effect, pipe } from "effect"
2590
+ * import { Data, Effect, pipe } from "effect"
2591
+ *
2592
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
2205
2593
  *
2206
2594
  * // Function to apply a discount safely to a transaction amount
2207
2595
  * const applyDiscount = (
2208
2596
  * total: number,
2209
2597
  * discountRate: number
2210
- * ): Effect.Effect<number, Error> =>
2598
+ * ): Effect.Effect<number, DiscountRateError> =>
2211
2599
  * discountRate === 0
2212
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2600
+ * ? Effect.fail(new DiscountRateError())
2213
2601
  * : Effect.succeed(total - (total * discountRate) / 100)
2214
2602
  *
2215
2603
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2282,15 +2670,17 @@ export declare const andThen: {
2282
2670
  *
2283
2671
  * @example Applying a Discount Based on Fetched Amount
2284
2672
  * ```ts
2285
- * import { Effect, pipe } from "effect"
2673
+ * import { Data, Effect, pipe } from "effect"
2674
+ *
2675
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
2286
2676
  *
2287
2677
  * // Function to apply a discount safely to a transaction amount
2288
2678
  * const applyDiscount = (
2289
2679
  * total: number,
2290
2680
  * discountRate: number
2291
- * ): Effect.Effect<number, Error> =>
2681
+ * ): Effect.Effect<number, DiscountRateError> =>
2292
2682
  * discountRate === 0
2293
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2683
+ * ? Effect.fail(new DiscountRateError())
2294
2684
  * : Effect.succeed(total - (total * discountRate) / 100)
2295
2685
  *
2296
2686
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2363,15 +2753,17 @@ export declare const andThen: {
2363
2753
  *
2364
2754
  * @example Applying a Discount Based on Fetched Amount
2365
2755
  * ```ts
2366
- * import { Effect, pipe } from "effect"
2756
+ * import { Data, Effect, pipe } from "effect"
2757
+ *
2758
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
2367
2759
  *
2368
2760
  * // Function to apply a discount safely to a transaction amount
2369
2761
  * const applyDiscount = (
2370
2762
  * total: number,
2371
2763
  * discountRate: number
2372
- * ): Effect.Effect<number, Error> =>
2764
+ * ): Effect.Effect<number, DiscountRateError> =>
2373
2765
  * discountRate === 0
2374
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2766
+ * ? Effect.fail(new DiscountRateError())
2375
2767
  * : Effect.succeed(total - (total * discountRate) / 100)
2376
2768
  *
2377
2769
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2444,15 +2836,17 @@ export declare const andThen: {
2444
2836
  *
2445
2837
  * @example Applying a Discount Based on Fetched Amount
2446
2838
  * ```ts
2447
- * import { Effect, pipe } from "effect"
2839
+ * import { Data, Effect, pipe } from "effect"
2840
+ *
2841
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
2448
2842
  *
2449
2843
  * // Function to apply a discount safely to a transaction amount
2450
2844
  * const applyDiscount = (
2451
2845
  * total: number,
2452
2846
  * discountRate: number
2453
- * ): Effect.Effect<number, Error> =>
2847
+ * ): Effect.Effect<number, DiscountRateError> =>
2454
2848
  * discountRate === 0
2455
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2849
+ * ? Effect.fail(new DiscountRateError())
2456
2850
  * : Effect.succeed(total - (total * discountRate) / 100)
2457
2851
  *
2458
2852
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2510,16 +2904,18 @@ export declare const andThen: {
2510
2904
  * @example
2511
2905
  * ```ts
2512
2906
  * // Title: Logging a step in a pipeline
2513
- * import { Effect, pipe } from "effect"
2907
+ * import { Data, Effect, pipe } from "effect"
2514
2908
  * import { Console } from "effect"
2515
2909
  *
2910
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
2911
+ *
2516
2912
  * // Function to apply a discount safely to a transaction amount
2517
2913
  * const applyDiscount = (
2518
2914
  * total: number,
2519
2915
  * discountRate: number
2520
- * ): Effect.Effect<number, Error> =>
2916
+ * ): Effect.Effect<number, DiscountRateError> =>
2521
2917
  * discountRate === 0
2522
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2918
+ * ? Effect.fail(new DiscountRateError())
2523
2919
  * : Effect.succeed(total - (total * discountRate) / 100)
2524
2920
  *
2525
2921
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2569,16 +2965,18 @@ export declare const tap: {
2569
2965
  * @example
2570
2966
  * ```ts
2571
2967
  * // Title: Logging a step in a pipeline
2572
- * import { Effect, pipe } from "effect"
2968
+ * import { Data, Effect, pipe } from "effect"
2573
2969
  * import { Console } from "effect"
2574
2970
  *
2971
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
2972
+ *
2575
2973
  * // Function to apply a discount safely to a transaction amount
2576
2974
  * const applyDiscount = (
2577
2975
  * total: number,
2578
2976
  * discountRate: number
2579
- * ): Effect.Effect<number, Error> =>
2977
+ * ): Effect.Effect<number, DiscountRateError> =>
2580
2978
  * discountRate === 0
2581
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
2979
+ * ? Effect.fail(new DiscountRateError())
2582
2980
  * : Effect.succeed(total - (total * discountRate) / 100)
2583
2981
  *
2584
2982
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2628,16 +3026,18 @@ export declare const tap: {
2628
3026
  * @example
2629
3027
  * ```ts
2630
3028
  * // Title: Logging a step in a pipeline
2631
- * import { Effect, pipe } from "effect"
3029
+ * import { Data, Effect, pipe } from "effect"
2632
3030
  * import { Console } from "effect"
2633
3031
  *
3032
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
3033
+ *
2634
3034
  * // Function to apply a discount safely to a transaction amount
2635
3035
  * const applyDiscount = (
2636
3036
  * total: number,
2637
3037
  * discountRate: number
2638
- * ): Effect.Effect<number, Error> =>
3038
+ * ): Effect.Effect<number, DiscountRateError> =>
2639
3039
  * discountRate === 0
2640
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
3040
+ * ? Effect.fail(new DiscountRateError())
2641
3041
  * : Effect.succeed(total - (total * discountRate) / 100)
2642
3042
  *
2643
3043
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2687,16 +3087,18 @@ export declare const tap: {
2687
3087
  * @example
2688
3088
  * ```ts
2689
3089
  * // Title: Logging a step in a pipeline
2690
- * import { Effect, pipe } from "effect"
3090
+ * import { Data, Effect, pipe } from "effect"
2691
3091
  * import { Console } from "effect"
2692
3092
  *
3093
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
3094
+ *
2693
3095
  * // Function to apply a discount safely to a transaction amount
2694
3096
  * const applyDiscount = (
2695
3097
  * total: number,
2696
3098
  * discountRate: number
2697
- * ): Effect.Effect<number, Error> =>
3099
+ * ): Effect.Effect<number, DiscountRateError> =>
2698
3100
  * discountRate === 0
2699
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
3101
+ * ? Effect.fail(new DiscountRateError())
2700
3102
  * : Effect.succeed(total - (total * discountRate) / 100)
2701
3103
  *
2702
3104
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -2746,16 +3148,18 @@ export declare const tap: {
2746
3148
  * @example
2747
3149
  * ```ts
2748
3150
  * // Title: Logging a step in a pipeline
2749
- * import { Effect, pipe } from "effect"
3151
+ * import { Data, Effect, pipe } from "effect"
2750
3152
  * import { Console } from "effect"
2751
3153
  *
3154
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
3155
+ *
2752
3156
  * // Function to apply a discount safely to a transaction amount
2753
3157
  * const applyDiscount = (
2754
3158
  * total: number,
2755
3159
  * discountRate: number
2756
- * ): Effect.Effect<number, Error> =>
3160
+ * ): Effect.Effect<number, DiscountRateError> =>
2757
3161
  * discountRate === 0
2758
- * ? Effect.fail(new Error("Discount rate cannot be zero"))
3162
+ * ? Effect.fail(new DiscountRateError())
2759
3163
  * : Effect.succeed(total - (total * discountRate) / 100)
2760
3164
  *
2761
3165
  * // Simulated asynchronous task to fetch a transaction amount from database
@@ -3538,12 +3942,12 @@ export {
3538
3942
  *
3539
3943
  * **Details**
3540
3944
  *
3541
- * The `catchAll` function catches any errors that may occur during the
3945
+ * The `catch` function catches any errors that may occur during the
3542
3946
  * execution of an effect and allows you to handle them by specifying a fallback
3543
3947
  * effect. This ensures that the program continues without failing by recovering
3544
3948
  * from errors using the provided fallback logic.
3545
3949
  *
3546
- * **Note**: `catchAll` only handles recoverable errors. It will not recover
3950
+ * **Note**: `catch` only handles recoverable errors. It will not recover
3547
3951
  * from unrecoverable defects.
3548
3952
  *
3549
3953
  * @see {@link catchCause} for a version that can recover from both recoverable and unrecoverable errors.
@@ -3691,7 +4095,8 @@ export declare const catchTag: {
3691
4095
  * once. Instead of using {@link catchTag} multiple times, you can pass an
3692
4096
  * object where each key is an error type's `_tag`, and the value is the handler
3693
4097
  * for that specific error. This allows you to catch and recover from multiple
3694
- * error types in a single call.
4098
+ * error types in a single call. You can also provide a fallback handler for
4099
+ * unhandled errors.
3695
4100
  *
3696
4101
  * The error type must have a readonly `_tag` field to use `catchTag`. This
3697
4102
  * field is used to identify and match errors.
@@ -3733,7 +4138,8 @@ export declare const catchTags: {
3733
4138
  * once. Instead of using {@link catchTag} multiple times, you can pass an
3734
4139
  * object where each key is an error type's `_tag`, and the value is the handler
3735
4140
  * for that specific error. This allows you to catch and recover from multiple
3736
- * error types in a single call.
4141
+ * error types in a single call. You can also provide a fallback handler for
4142
+ * unhandled errors.
3737
4143
  *
3738
4144
  * The error type must have a readonly `_tag` field to use `catchTag`. This
3739
4145
  * field is used to identify and match errors.
@@ -3775,13 +4181,15 @@ export declare const catchTags: {
3775
4181
  [K in Exclude<keyof Cases, Extract<E, {
3776
4182
  _tag: string;
3777
4183
  }>["_tag"]>]: never;
3778
- })>(cases: Cases): <A, R>(self: Effect<A, E, R>) => Effect<A | {
3779
- [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
3780
- }[keyof Cases], Exclude<E, {
4184
+ }), A2 = never, E2 = Exclude<E, {
3781
4185
  _tag: keyof Cases;
3782
- }> | {
4186
+ }>, R2 = never>(cases: Cases, orElse?: ((e: Exclude<E, {
4187
+ _tag: keyof Cases;
4188
+ }>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | {
4189
+ [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
4190
+ }[keyof Cases], E2 | {
3783
4191
  [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
3784
- }[keyof Cases], R | {
4192
+ }[keyof Cases], R | R2 | {
3785
4193
  [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never;
3786
4194
  }[keyof Cases]>;
3787
4195
  /**
@@ -3793,7 +4201,8 @@ export declare const catchTags: {
3793
4201
  * once. Instead of using {@link catchTag} multiple times, you can pass an
3794
4202
  * object where each key is an error type's `_tag`, and the value is the handler
3795
4203
  * for that specific error. This allows you to catch and recover from multiple
3796
- * error types in a single call.
4204
+ * error types in a single call. You can also provide a fallback handler for
4205
+ * unhandled errors.
3797
4206
  *
3798
4207
  * The error type must have a readonly `_tag` field to use `catchTag`. This
3799
4208
  * field is used to identify and match errors.
@@ -3835,13 +4244,15 @@ export declare const catchTags: {
3835
4244
  [K in Exclude<keyof Cases, Extract<E, {
3836
4245
  _tag: string;
3837
4246
  }>["_tag"]>]: never;
3838
- })>(self: Effect<A, E, R>, cases: Cases): Effect<A | {
3839
- [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
3840
- }[keyof Cases], Exclude<E, {
4247
+ }), A2 = never, E2 = Exclude<E, {
3841
4248
  _tag: keyof Cases;
3842
- }> | {
4249
+ }>, R2 = never>(self: Effect<A, E, R>, cases: Cases, orElse?: ((e: Exclude<E, {
4250
+ _tag: keyof Cases;
4251
+ }>) => Effect<A2, E2, R2>) | undefined): Effect<A | A2 | {
4252
+ [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
4253
+ }[keyof Cases], E2 | {
3843
4254
  [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
3844
- }[keyof Cases], R | {
4255
+ }[keyof Cases], R | R2 | {
3845
4256
  [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never;
3846
4257
  }[keyof Cases]>;
3847
4258
  };
@@ -3916,7 +4327,7 @@ export declare const catchReason: {
3916
4327
  * @since 4.0.0
3917
4328
  * @category Error Handling
3918
4329
  */
3919
- <K extends Tags<E>, E, RK extends ReasonTags<ExtractTag<NoInfer<E>, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
4330
+ <K extends Tags<E>, E, RK extends ReasonTags<ExtractTag<NoInfer<E>, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>, error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>, error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
3920
4331
  /**
3921
4332
  * Catches a specific reason within a tagged error.
3922
4333
  *
@@ -3952,7 +4363,7 @@ export declare const catchReason: {
3952
4363
  * @since 4.0.0
3953
4364
  * @category Error Handling
3954
4365
  */
3955
- <A, E, R, K extends Tags<E>, RK extends ReasonTags<ExtractTag<E, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Effect<A, E, R>, errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
4366
+ <A, E, R, K extends Tags<E>, RK extends ReasonTags<ExtractTag<E, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Effect<A, E, R>, errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
3956
4367
  };
3957
4368
  /**
3958
4369
  * Catches multiple reasons within a tagged error using an object of handlers.
@@ -4024,8 +4435,8 @@ export declare const catchReasons: {
4024
4435
  * @category Error Handling
4025
4436
  */
4026
4437
  <K extends Tags<E>, E, Cases extends {
4027
- [RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<any, any, any>;
4028
- }, A2 = unassigned, E2 = never, R2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | Exclude<A2, unassigned> | {
4438
+ [RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>, error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<any, any, any>;
4439
+ }, A2 = unassigned, E2 = never, R2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | Exclude<A2, unassigned> | {
4029
4440
  [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
4030
4441
  }[keyof Cases], (A2 extends unassigned ? E : ExcludeTag<E, K>) | E2 | {
4031
4442
  [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
@@ -4067,8 +4478,8 @@ export declare const catchReasons: {
4067
4478
  * @category Error Handling
4068
4479
  */
4069
4480
  <A, E, R, K extends Tags<E>, Cases extends {
4070
- [RK in ReasonTags<ExtractTag<E, K>>]+?: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<any, any, any>;
4071
- }, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): Effect<A | Exclude<A2, unassigned> | {
4481
+ [RK in ReasonTags<ExtractTag<E, K>>]+?: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<any, any, any>;
4482
+ }, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): Effect<A | Exclude<A2, unassigned> | {
4072
4483
  [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
4073
4484
  }[keyof Cases], (A2 extends unassigned ? E : ExcludeTag<E, K>) | E2 | {
4074
4485
  [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
@@ -4469,15 +4880,14 @@ export declare const catchDefect: {
4469
4880
  <A, E, R, A2, E2, R2>(self: Effect<A, E, R>, f: (defect: unknown) => Effect<A2, E2, R2>): Effect<A | A2, E | E2, R | R2>;
4470
4881
  };
4471
4882
  /**
4472
- * Recovers from specific errors using a `Filter`, `Predicate`, or
4473
- * `Refinement`.
4883
+ * Recovers from specific errors using a `Predicate` or `Refinement`.
4474
4884
  *
4475
4885
  * **When to Use**
4476
4886
  *
4477
- * `catchIf` lets you recover from errors that match a condition. Pass a
4478
- * `Filter` for transformation, a `Refinement` for type narrowing, or a
4479
- * `Predicate` for simple boolean matching. Non-matching errors re-fail with
4480
- * the original cause. Defects and interrupts are not caught.
4887
+ * `catchIf` lets you recover from errors that match a condition. Use a
4888
+ * `Refinement` for type narrowing or a `Predicate` for simple boolean
4889
+ * matching. Non-matching errors re-fail with the original cause. Defects and
4890
+ * interrupts are not caught.
4481
4891
  *
4482
4892
  * **Previously Known As**
4483
4893
  *
@@ -4504,7 +4914,7 @@ export declare const catchDefect: {
4504
4914
  *
4505
4915
  * // With a Filter
4506
4916
  * const recovered2 = program.pipe(
4507
- * Effect.catchIf(
4917
+ * Effect.catchFilter(
4508
4918
  * Filter.tagged("NotFound"),
4509
4919
  * (error) => Effect.succeed(`missing:${error.id}`)
4510
4920
  * )
@@ -4516,15 +4926,14 @@ export declare const catchDefect: {
4516
4926
  */
4517
4927
  export declare const catchIf: {
4518
4928
  /**
4519
- * Recovers from specific errors using a `Filter`, `Predicate`, or
4520
- * `Refinement`.
4929
+ * Recovers from specific errors using a `Predicate` or `Refinement`.
4521
4930
  *
4522
4931
  * **When to Use**
4523
4932
  *
4524
- * `catchIf` lets you recover from errors that match a condition. Pass a
4525
- * `Filter` for transformation, a `Refinement` for type narrowing, or a
4526
- * `Predicate` for simple boolean matching. Non-matching errors re-fail with
4527
- * the original cause. Defects and interrupts are not caught.
4933
+ * `catchIf` lets you recover from errors that match a condition. Use a
4934
+ * `Refinement` for type narrowing or a `Predicate` for simple boolean
4935
+ * matching. Non-matching errors re-fail with the original cause. Defects and
4936
+ * interrupts are not caught.
4528
4937
  *
4529
4938
  * **Previously Known As**
4530
4939
  *
@@ -4551,7 +4960,7 @@ export declare const catchIf: {
4551
4960
  *
4552
4961
  * // With a Filter
4553
4962
  * const recovered2 = program.pipe(
4554
- * Effect.catchIf(
4963
+ * Effect.catchFilter(
4555
4964
  * Filter.tagged("NotFound"),
4556
4965
  * (error) => Effect.succeed(`missing:${error.id}`)
4557
4966
  * )
@@ -4563,15 +4972,14 @@ export declare const catchIf: {
4563
4972
  */
4564
4973
  <E, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(refinement: Predicate.Refinement<NoInfer<E>, EB>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
4565
4974
  /**
4566
- * Recovers from specific errors using a `Filter`, `Predicate`, or
4567
- * `Refinement`.
4975
+ * Recovers from specific errors using a `Predicate` or `Refinement`.
4568
4976
  *
4569
4977
  * **When to Use**
4570
4978
  *
4571
- * `catchIf` lets you recover from errors that match a condition. Pass a
4572
- * `Filter` for transformation, a `Refinement` for type narrowing, or a
4573
- * `Predicate` for simple boolean matching. Non-matching errors re-fail with
4574
- * the original cause. Defects and interrupts are not caught.
4979
+ * `catchIf` lets you recover from errors that match a condition. Use a
4980
+ * `Refinement` for type narrowing or a `Predicate` for simple boolean
4981
+ * matching. Non-matching errors re-fail with the original cause. Defects and
4982
+ * interrupts are not caught.
4575
4983
  *
4576
4984
  * **Previously Known As**
4577
4985
  *
@@ -4598,7 +5006,7 @@ export declare const catchIf: {
4598
5006
  *
4599
5007
  * // With a Filter
4600
5008
  * const recovered2 = program.pipe(
4601
- * Effect.catchIf(
5009
+ * Effect.catchFilter(
4602
5010
  * Filter.tagged("NotFound"),
4603
5011
  * (error) => Effect.succeed(`missing:${error.id}`)
4604
5012
  * )
@@ -4608,17 +5016,16 @@ export declare const catchIf: {
4608
5016
  * @since 2.0.0
4609
5017
  * @category Error Handling
4610
5018
  */
4611
- <E, Result extends Filter.ResultOrBool, A2, E2, R2, A3 = never, E3 = Filter.Fail<E, Result>, R3 = never>(filter: Filter.OrPredicate<NoInfer<E>, Result>, f: (e: Filter.Pass<E, Result>) => Effect<A2, E2, R2>, orElse?: ((e: Filter.Fail<E, Result>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
5019
+ <E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(predicate: Predicate.Predicate<NoInfer<E>>, f: (e: NoInfer<E>) => Effect<A2, E2, R2>, orElse?: ((e: NoInfer<E>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
4612
5020
  /**
4613
- * Recovers from specific errors using a `Filter`, `Predicate`, or
4614
- * `Refinement`.
5021
+ * Recovers from specific errors using a `Predicate` or `Refinement`.
4615
5022
  *
4616
5023
  * **When to Use**
4617
5024
  *
4618
- * `catchIf` lets you recover from errors that match a condition. Pass a
4619
- * `Filter` for transformation, a `Refinement` for type narrowing, or a
4620
- * `Predicate` for simple boolean matching. Non-matching errors re-fail with
4621
- * the original cause. Defects and interrupts are not caught.
5025
+ * `catchIf` lets you recover from errors that match a condition. Use a
5026
+ * `Refinement` for type narrowing or a `Predicate` for simple boolean
5027
+ * matching. Non-matching errors re-fail with the original cause. Defects and
5028
+ * interrupts are not caught.
4622
5029
  *
4623
5030
  * **Previously Known As**
4624
5031
  *
@@ -4645,7 +5052,7 @@ export declare const catchIf: {
4645
5052
  *
4646
5053
  * // With a Filter
4647
5054
  * const recovered2 = program.pipe(
4648
- * Effect.catchIf(
5055
+ * Effect.catchFilter(
4649
5056
  * Filter.tagged("NotFound"),
4650
5057
  * (error) => Effect.succeed(`missing:${error.id}`)
4651
5058
  * )
@@ -4657,15 +5064,14 @@ export declare const catchIf: {
4657
5064
  */
4658
5065
  <A, E, R, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(self: Effect<A, E, R>, refinement: Predicate.Refinement<E, EB>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
4659
5066
  /**
4660
- * Recovers from specific errors using a `Filter`, `Predicate`, or
4661
- * `Refinement`.
5067
+ * Recovers from specific errors using a `Predicate` or `Refinement`.
4662
5068
  *
4663
5069
  * **When to Use**
4664
5070
  *
4665
- * `catchIf` lets you recover from errors that match a condition. Pass a
4666
- * `Filter` for transformation, a `Refinement` for type narrowing, or a
4667
- * `Predicate` for simple boolean matching. Non-matching errors re-fail with
4668
- * the original cause. Defects and interrupts are not caught.
5071
+ * `catchIf` lets you recover from errors that match a condition. Use a
5072
+ * `Refinement` for type narrowing or a `Predicate` for simple boolean
5073
+ * matching. Non-matching errors re-fail with the original cause. Defects and
5074
+ * interrupts are not caught.
4669
5075
  *
4670
5076
  * **Previously Known As**
4671
5077
  *
@@ -4692,7 +5098,7 @@ export declare const catchIf: {
4692
5098
  *
4693
5099
  * // With a Filter
4694
5100
  * const recovered2 = program.pipe(
4695
- * Effect.catchIf(
5101
+ * Effect.catchFilter(
4696
5102
  * Filter.tagged("NotFound"),
4697
5103
  * (error) => Effect.succeed(`missing:${error.id}`)
4698
5104
  * )
@@ -4702,7 +5108,29 @@ export declare const catchIf: {
4702
5108
  * @since 2.0.0
4703
5109
  * @category Error Handling
4704
5110
  */
4705
- <A, E, R, Result extends Filter.ResultOrBool, A2, E2, R2, A3 = never, E3 = Filter.Fail<E, Result>, R3 = never>(self: Effect<A, E, R>, filter: Filter.OrPredicate<NoInfer<E>, Result>, f: (e: Filter.Pass<E, Result>) => Effect<A2, E2, R2>, orElse?: ((e: Filter.Fail<E, Result>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
5111
+ <A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(self: Effect<A, E, R>, predicate: Predicate.Predicate<E>, f: (e: E) => Effect<A2, E2, R2>, orElse?: ((e: E) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
5112
+ };
5113
+ /**
5114
+ * Recovers from specific errors using a `Filter`.
5115
+ *
5116
+ * @since 4.0.0
5117
+ * @category Error Handling
5118
+ */
5119
+ export declare const catchFilter: {
5120
+ /**
5121
+ * Recovers from specific errors using a `Filter`.
5122
+ *
5123
+ * @since 4.0.0
5124
+ * @category Error Handling
5125
+ */
5126
+ <E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(filter: Filter.Filter<NoInfer<E>, EB, X>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
5127
+ /**
5128
+ * Recovers from specific errors using a `Filter`.
5129
+ *
5130
+ * @since 4.0.0
5131
+ * @category Error Handling
5132
+ */
5133
+ <A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(self: Effect<A, E, R>, filter: Filter.Filter<NoInfer<E>, EB, X>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
4706
5134
  };
4707
5135
  /**
4708
5136
  * Catches `NoSuchElementError` failures and converts them to `Option.none`.
@@ -4808,7 +5236,7 @@ export declare const catchCauseIf: {
4808
5236
  * @since 4.0.0
4809
5237
  * @category Error Handling
4810
5238
  */
4811
- <E, Result extends Filter.ResultOrBool<Cause.Cause<any>>, B, E2, R2>(filter: Filter.OrPredicate<Cause.Cause<E>, Result>, f: (failure: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, Cause.Cause.Error<Filter.Fail<Cause.Cause<E>, Result>> | E2, R | R2>;
5239
+ <E, B, E2, R2>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, E | E2, R | R2>;
4812
5240
  /**
4813
5241
  * Recovers from specific failures based on a predicate.
4814
5242
  *
@@ -4847,7 +5275,29 @@ export declare const catchCauseIf: {
4847
5275
  * @since 4.0.0
4848
5276
  * @category Error Handling
4849
5277
  */
4850
- <A, E, R, B, E2, R2, Result extends Filter.ResultOrBool<Cause.Cause<any>>>(self: Effect<A, E, R>, filter: Filter.OrPredicate<Cause.Cause<E>, Result>, f: (failure: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, Cause.Cause.Error<Filter.Fail<Cause.Cause<E>, Result>> | E2, R | R2>;
5278
+ <A, E, R, B, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, E | E2, R | R2>;
5279
+ };
5280
+ /**
5281
+ * Recovers from specific failures based on a `Filter`.
5282
+ *
5283
+ * @since 4.0.0
5284
+ * @category Error Handling
5285
+ */
5286
+ export declare const catchCauseFilter: {
5287
+ /**
5288
+ * Recovers from specific failures based on a `Filter`.
5289
+ *
5290
+ * @since 4.0.0
5291
+ * @category Error Handling
5292
+ */
5293
+ <E, B, E2, R2, EB, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>;
5294
+ /**
5295
+ * Recovers from specific failures based on a `Filter`.
5296
+ *
5297
+ * @since 4.0.0
5298
+ * @category Error Handling
5299
+ */
5300
+ <A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>;
4851
5301
  };
4852
5302
  /**
4853
5303
  * The `mapError` function is used to transform or modify the error
@@ -4864,17 +5314,19 @@ export declare const catchCauseIf: {
4864
5314
  *
4865
5315
  * @example
4866
5316
  * ```ts
4867
- * import { Effect } from "effect"
5317
+ * import { Data, Effect } from "effect"
5318
+ *
5319
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
4868
5320
  *
4869
5321
  * // ┌─── Effect<number, string, never>
4870
5322
  * // ▼
4871
5323
  * const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
4872
5324
  *
4873
- * // ┌─── Effect<number, Error, never>
5325
+ * // ┌─── Effect<number, TaskError, never>
4874
5326
  * // ▼
4875
5327
  * const mapped = Effect.mapError(
4876
5328
  * simulatedTask,
4877
- * (message) => new Error(message)
5329
+ * (message) => new TaskError({ message })
4878
5330
  * )
4879
5331
  * ```
4880
5332
  *
@@ -4897,17 +5349,19 @@ export declare const mapError: {
4897
5349
  *
4898
5350
  * @example
4899
5351
  * ```ts
4900
- * import { Effect } from "effect"
5352
+ * import { Data, Effect } from "effect"
5353
+ *
5354
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
4901
5355
  *
4902
5356
  * // ┌─── Effect<number, string, never>
4903
5357
  * // ▼
4904
5358
  * const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
4905
5359
  *
4906
- * // ┌─── Effect<number, Error, never>
5360
+ * // ┌─── Effect<number, TaskError, never>
4907
5361
  * // ▼
4908
5362
  * const mapped = Effect.mapError(
4909
5363
  * simulatedTask,
4910
- * (message) => new Error(message)
5364
+ * (message) => new TaskError({ message })
4911
5365
  * )
4912
5366
  * ```
4913
5367
  *
@@ -4930,17 +5384,19 @@ export declare const mapError: {
4930
5384
  *
4931
5385
  * @example
4932
5386
  * ```ts
4933
- * import { Effect } from "effect"
5387
+ * import { Data, Effect } from "effect"
5388
+ *
5389
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
4934
5390
  *
4935
5391
  * // ┌─── Effect<number, string, never>
4936
5392
  * // ▼
4937
5393
  * const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
4938
5394
  *
4939
- * // ┌─── Effect<number, Error, never>
5395
+ * // ┌─── Effect<number, TaskError, never>
4940
5396
  * // ▼
4941
5397
  * const mapped = Effect.mapError(
4942
5398
  * simulatedTask,
4943
- * (message) => new Error(message)
5399
+ * (message) => new TaskError({ message })
4944
5400
  * )
4945
5401
  * ```
4946
5402
  *
@@ -4961,16 +5417,18 @@ export declare const mapError: {
4961
5417
  *
4962
5418
  * @example
4963
5419
  * ```ts
4964
- * import { Effect } from "effect"
5420
+ * import { Data, Effect } from "effect"
5421
+ *
5422
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
4965
5423
  *
4966
5424
  * // ┌─── Effect<number, string, never>
4967
5425
  * // ▼
4968
5426
  * const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
4969
5427
  *
4970
- * // ┌─── Effect<boolean, Error, never>
5428
+ * // ┌─── Effect<boolean, TaskError, never>
4971
5429
  * // ▼
4972
5430
  * const modified = Effect.mapBoth(simulatedTask, {
4973
- * onFailure: (message) => new Error(message),
5431
+ * onFailure: (message) => new TaskError({ message }),
4974
5432
  * onSuccess: (n) => n > 0
4975
5433
  * })
4976
5434
  * ```
@@ -4994,16 +5452,18 @@ export declare const mapBoth: {
4994
5452
  *
4995
5453
  * @example
4996
5454
  * ```ts
4997
- * import { Effect } from "effect"
5455
+ * import { Data, Effect } from "effect"
5456
+ *
5457
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
4998
5458
  *
4999
5459
  * // ┌─── Effect<number, string, never>
5000
5460
  * // ▼
5001
5461
  * const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
5002
5462
  *
5003
- * // ┌─── Effect<boolean, Error, never>
5463
+ * // ┌─── Effect<boolean, TaskError, never>
5004
5464
  * // ▼
5005
5465
  * const modified = Effect.mapBoth(simulatedTask, {
5006
- * onFailure: (message) => new Error(message),
5466
+ * onFailure: (message) => new TaskError({ message }),
5007
5467
  * onSuccess: (n) => n > 0
5008
5468
  * })
5009
5469
  * ```
@@ -5030,16 +5490,18 @@ export declare const mapBoth: {
5030
5490
  *
5031
5491
  * @example
5032
5492
  * ```ts
5033
- * import { Effect } from "effect"
5493
+ * import { Data, Effect } from "effect"
5494
+ *
5495
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
5034
5496
  *
5035
5497
  * // ┌─── Effect<number, string, never>
5036
5498
  * // ▼
5037
5499
  * const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
5038
5500
  *
5039
- * // ┌─── Effect<boolean, Error, never>
5501
+ * // ┌─── Effect<boolean, TaskError, never>
5040
5502
  * // ▼
5041
5503
  * const modified = Effect.mapBoth(simulatedTask, {
5042
- * onFailure: (message) => new Error(message),
5504
+ * onFailure: (message) => new TaskError({ message }),
5043
5505
  * onSuccess: (n) => n > 0
5044
5506
  * })
5045
5507
  * ```
@@ -5073,11 +5535,13 @@ export declare const mapBoth: {
5073
5535
  * @example
5074
5536
  * ```ts
5075
5537
  * // Title: Propagating an Error as a Defect
5076
- * import { Effect } from "effect"
5538
+ * import { Data, Effect } from "effect"
5539
+ *
5540
+ * class DivideByZeroError extends Data.TaggedError("DivideByZeroError")<{}> {}
5077
5541
  *
5078
5542
  * const divide = (a: number, b: number) =>
5079
5543
  * b === 0
5080
- * ? Effect.fail(new Error("Cannot divide by zero"))
5544
+ * ? Effect.fail(new DivideByZeroError())
5081
5545
  * : Effect.succeed(a / b)
5082
5546
  *
5083
5547
  * // ┌─── Effect<number, never, never>
@@ -5086,7 +5550,7 @@ export declare const mapBoth: {
5086
5550
  *
5087
5551
  * Effect.runPromise(program).catch(console.error)
5088
5552
  * // Output:
5089
- * // (FiberFailure) Error: Cannot divide by zero
5553
+ * // (FiberFailure) DivideByZeroError
5090
5554
  * // ...stack trace...
5091
5555
  * ```
5092
5556
  *
@@ -5454,7 +5918,7 @@ export declare const tapCauseIf: {
5454
5918
  * @since 4.0.0
5455
5919
  * @category Sequencing
5456
5920
  */
5457
- <E, Result extends Filter.ResultOrBool, B, E2, R2>(filter: Filter.OrPredicate<Cause.Cause<E>, Result>, f: (a: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
5921
+ <E, B, E2, R2>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
5458
5922
  /**
5459
5923
  * Conditionally executes a side effect based on the cause of a failed effect.
5460
5924
  *
@@ -5483,7 +5947,29 @@ export declare const tapCauseIf: {
5483
5947
  * @since 4.0.0
5484
5948
  * @category Sequencing
5485
5949
  */
5486
- <A, E, R, Result extends Filter.ResultOrBool, B, E2, R2>(self: Effect<A, E, R>, filter: Filter.OrPredicate<Cause.Cause<E>, Result>, f: (a: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
5950
+ <A, E, R, B, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
5951
+ };
5952
+ /**
5953
+ * Conditionally executes a side effect based on the cause of a failed effect.
5954
+ *
5955
+ * @since 4.0.0
5956
+ * @category Sequencing
5957
+ */
5958
+ export declare const tapCauseFilter: {
5959
+ /**
5960
+ * Conditionally executes a side effect based on the cause of a failed effect.
5961
+ *
5962
+ * @since 4.0.0
5963
+ * @category Sequencing
5964
+ */
5965
+ <E, B, E2, R2, EB, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
5966
+ /**
5967
+ * Conditionally executes a side effect based on the cause of a failed effect.
5968
+ *
5969
+ * @since 4.0.0
5970
+ * @category Sequencing
5971
+ */
5972
+ <A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
5487
5973
  };
5488
5974
  /**
5489
5975
  * Inspect severe errors or defects (non-recoverable failures) in an effect.
@@ -5660,7 +6146,7 @@ export declare const tapDefect: {
5660
6146
  * attempts++
5661
6147
  * yield* Console.log(`Attempt ${attempts}`)
5662
6148
  * if (attempts < 3) {
5663
- * yield* Effect.fail("Not ready")
6149
+ * return yield* Effect.fail("Not ready")
5664
6150
  * }
5665
6151
  * return "Ready"
5666
6152
  * })
@@ -5708,9 +6194,11 @@ export declare namespace Retry {
5708
6194
  */
5709
6195
  type Return<R, E, A, O extends Options<E>> = Effect<A, (O extends {
5710
6196
  schedule: Schedule<infer _O, infer _I, infer _E1, infer _R>;
5711
- } ? E | _E1 : O extends {
6197
+ } ? E : O extends {
5712
6198
  until: Predicate.Refinement<E, infer E2>;
5713
- } ? E2 : E) | (O extends {
6199
+ } ? E2 : O extends {
6200
+ while: Predicate.Refinement<E, infer E2>;
6201
+ } ? Exclude<E, E2> : E) | (O extends {
5714
6202
  schedule: Schedule<infer _O, infer _I, infer E, infer _R>;
5715
6203
  } ? E : never) | (O extends {
5716
6204
  while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>;
@@ -5769,13 +6257,15 @@ export declare namespace Retry {
5769
6257
  *
5770
6258
  * @example
5771
6259
  * ```ts
5772
- * import { Effect, Schedule } from "effect"
6260
+ * import { Data, Effect, Schedule } from "effect"
6261
+ *
6262
+ * class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
5773
6263
  *
5774
6264
  * let attempt = 0
5775
- * const task = Effect.callback<string, Error>((resume) => {
6265
+ * const task = Effect.callback<string, AttemptError>((resume) => {
5776
6266
  * attempt++
5777
6267
  * if (attempt <= 2) {
5778
- * resume(Effect.fail(new Error(`Attempt ${attempt} failed`)))
6268
+ * resume(Effect.fail(new AttemptError({ attempt })))
5779
6269
  * } else {
5780
6270
  * resume(Effect.succeed("Success!"))
5781
6271
  * }
@@ -5818,13 +6308,15 @@ export declare const retry: {
5818
6308
  *
5819
6309
  * @example
5820
6310
  * ```ts
5821
- * import { Effect, Schedule } from "effect"
6311
+ * import { Data, Effect, Schedule } from "effect"
6312
+ *
6313
+ * class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
5822
6314
  *
5823
6315
  * let attempt = 0
5824
- * const task = Effect.callback<string, Error>((resume) => {
6316
+ * const task = Effect.callback<string, AttemptError>((resume) => {
5825
6317
  * attempt++
5826
6318
  * if (attempt <= 2) {
5827
- * resume(Effect.fail(new Error(`Attempt ${attempt} failed`)))
6319
+ * resume(Effect.fail(new AttemptError({ attempt })))
5828
6320
  * } else {
5829
6321
  * resume(Effect.succeed("Success!"))
5830
6322
  * }
@@ -5867,13 +6359,15 @@ export declare const retry: {
5867
6359
  *
5868
6360
  * @example
5869
6361
  * ```ts
5870
- * import { Effect, Schedule } from "effect"
6362
+ * import { Data, Effect, Schedule } from "effect"
6363
+ *
6364
+ * class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
5871
6365
  *
5872
6366
  * let attempt = 0
5873
- * const task = Effect.callback<string, Error>((resume) => {
6367
+ * const task = Effect.callback<string, AttemptError>((resume) => {
5874
6368
  * attempt++
5875
6369
  * if (attempt <= 2) {
5876
- * resume(Effect.fail(new Error(`Attempt ${attempt} failed`)))
6370
+ * resume(Effect.fail(new AttemptError({ attempt })))
5877
6371
  * } else {
5878
6372
  * resume(Effect.succeed("Success!"))
5879
6373
  * }
@@ -5916,13 +6410,15 @@ export declare const retry: {
5916
6410
  *
5917
6411
  * @example
5918
6412
  * ```ts
5919
- * import { Effect, Schedule } from "effect"
6413
+ * import { Data, Effect, Schedule } from "effect"
6414
+ *
6415
+ * class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
5920
6416
  *
5921
6417
  * let attempt = 0
5922
- * const task = Effect.callback<string, Error>((resume) => {
6418
+ * const task = Effect.callback<string, AttemptError>((resume) => {
5923
6419
  * attempt++
5924
6420
  * if (attempt <= 2) {
5925
- * resume(Effect.fail(new Error(`Attempt ${attempt} failed`)))
6421
+ * resume(Effect.fail(new AttemptError({ attempt })))
5926
6422
  * } else {
5927
6423
  * resume(Effect.succeed("Success!"))
5928
6424
  * }
@@ -5965,13 +6461,15 @@ export declare const retry: {
5965
6461
  *
5966
6462
  * @example
5967
6463
  * ```ts
5968
- * import { Effect, Schedule } from "effect"
6464
+ * import { Data, Effect, Schedule } from "effect"
6465
+ *
6466
+ * class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
5969
6467
  *
5970
6468
  * let attempt = 0
5971
- * const task = Effect.callback<string, Error>((resume) => {
6469
+ * const task = Effect.callback<string, AttemptError>((resume) => {
5972
6470
  * attempt++
5973
6471
  * if (attempt <= 2) {
5974
- * resume(Effect.fail(new Error(`Attempt ${attempt} failed`)))
6472
+ * resume(Effect.fail(new AttemptError({ attempt })))
5975
6473
  * } else {
5976
6474
  * resume(Effect.succeed("Success!"))
5977
6475
  * }
@@ -6014,13 +6512,15 @@ export declare const retry: {
6014
6512
  *
6015
6513
  * @example
6016
6514
  * ```ts
6017
- * import { Effect, Schedule } from "effect"
6515
+ * import { Data, Effect, Schedule } from "effect"
6516
+ *
6517
+ * class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
6018
6518
  *
6019
6519
  * let attempt = 0
6020
- * const task = Effect.callback<string, Error>((resume) => {
6520
+ * const task = Effect.callback<string, AttemptError>((resume) => {
6021
6521
  * attempt++
6022
6522
  * if (attempt <= 2) {
6023
- * resume(Effect.fail(new Error(`Attempt ${attempt} failed`)))
6523
+ * resume(Effect.fail(new AttemptError({ attempt })))
6024
6524
  * } else {
6025
6525
  * resume(Effect.succeed("Success!"))
6026
6526
  * }
@@ -6063,13 +6563,15 @@ export declare const retry: {
6063
6563
  *
6064
6564
  * @example
6065
6565
  * ```ts
6066
- * import { Effect, Schedule } from "effect"
6566
+ * import { Data, Effect, Schedule } from "effect"
6567
+ *
6568
+ * class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
6067
6569
  *
6068
6570
  * let attempt = 0
6069
- * const task = Effect.callback<string, Error>((resume) => {
6571
+ * const task = Effect.callback<string, AttemptError>((resume) => {
6070
6572
  * attempt++
6071
6573
  * if (attempt <= 2) {
6072
- * resume(Effect.fail(new Error(`Attempt ${attempt} failed`)))
6574
+ * resume(Effect.fail(new AttemptError({ attempt })))
6073
6575
  * } else {
6074
6576
  * resume(Effect.succeed("Success!"))
6075
6577
  * }
@@ -6110,14 +6612,16 @@ export declare const retry: {
6110
6612
  *
6111
6613
  * @example
6112
6614
  * ```ts
6113
- * import { Console, Effect, Schedule } from "effect"
6615
+ * import { Console, Data, Effect, Schedule } from "effect"
6616
+ *
6617
+ * class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
6114
6618
  *
6115
6619
  * let attempt = 0
6116
6620
  * const networkRequest = Effect.gen(function*() {
6117
6621
  * attempt++
6118
6622
  * yield* Console.log(`Network attempt ${attempt}`)
6119
6623
  * if (attempt < 3) {
6120
- * return yield* Effect.fail(new Error("Network timeout"))
6624
+ * return yield* Effect.fail(new NetworkTimeoutError())
6121
6625
  * }
6122
6626
  * return "Network data"
6123
6627
  * })
@@ -6165,14 +6669,16 @@ export declare const retryOrElse: {
6165
6669
  *
6166
6670
  * @example
6167
6671
  * ```ts
6168
- * import { Console, Effect, Schedule } from "effect"
6672
+ * import { Console, Data, Effect, Schedule } from "effect"
6673
+ *
6674
+ * class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
6169
6675
  *
6170
6676
  * let attempt = 0
6171
6677
  * const networkRequest = Effect.gen(function*() {
6172
6678
  * attempt++
6173
6679
  * yield* Console.log(`Network attempt ${attempt}`)
6174
6680
  * if (attempt < 3) {
6175
- * return yield* Effect.fail(new Error("Network timeout"))
6681
+ * return yield* Effect.fail(new NetworkTimeoutError())
6176
6682
  * }
6177
6683
  * return "Network data"
6178
6684
  * })
@@ -6220,14 +6726,16 @@ export declare const retryOrElse: {
6220
6726
  *
6221
6727
  * @example
6222
6728
  * ```ts
6223
- * import { Console, Effect, Schedule } from "effect"
6729
+ * import { Console, Data, Effect, Schedule } from "effect"
6730
+ *
6731
+ * class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
6224
6732
  *
6225
6733
  * let attempt = 0
6226
6734
  * const networkRequest = Effect.gen(function*() {
6227
6735
  * attempt++
6228
6736
  * yield* Console.log(`Network attempt ${attempt}`)
6229
6737
  * if (attempt < 3) {
6230
- * return yield* Effect.fail(new Error("Network timeout"))
6738
+ * return yield* Effect.fail(new NetworkTimeoutError())
6231
6739
  * }
6232
6740
  * return "Network data"
6233
6741
  * })
@@ -6300,7 +6808,8 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
6300
6808
  * it succeeds or fails. This is useful when you only care about the side
6301
6809
  * effects of the effect and do not need to handle or process its outcome.
6302
6810
  *
6303
- * Use the `log` option to emit the full {@link Cause} when the effect fails.
6811
+ * Use the `log` option to emit the full {@link Cause} when the effect fails,
6812
+ * and `message` to prepend a custom log message.
6304
6813
  *
6305
6814
  * @example
6306
6815
  * ```ts
@@ -6324,7 +6833,7 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
6324
6833
  * const task = Effect.fail("Uh oh!")
6325
6834
  *
6326
6835
  * const program = task.pipe(Effect.ignore({ log: true }))
6327
- * const programWarn = task.pipe(Effect.ignore({ log: "Warn" }))
6836
+ * const programWarn = task.pipe(Effect.ignore({ log: "Warn", message: "Ignoring task failure" }))
6328
6837
  * ```
6329
6838
  *
6330
6839
  * **Previously Known As**
@@ -6337,16 +6846,20 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
6337
6846
  * @category Error Handling
6338
6847
  */
6339
6848
  export declare const ignore: <Arg extends Effect<any, any, any> | {
6340
- readonly log?: boolean | LogLevel | undefined;
6849
+ readonly log?: boolean | Severity | undefined;
6850
+ readonly message?: string | undefined;
6341
6851
  } | undefined = {
6342
- readonly log?: boolean | LogLevel | undefined;
6852
+ readonly log?: boolean | Severity | undefined;
6853
+ readonly message?: string | undefined;
6343
6854
  }>(effectOrOptions?: Arg, options?: {
6344
- readonly log?: boolean | LogLevel | undefined;
6855
+ readonly log?: boolean | Severity | undefined;
6856
+ readonly message?: string | undefined;
6345
6857
  } | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R>;
6346
6858
  /**
6347
6859
  * Ignores the effect's failure cause, including defects and interruptions.
6348
6860
  *
6349
- * Use the `log` option to emit the full {@link Cause} when the effect fails.
6861
+ * Use the `log` option to emit the full {@link Cause} when the effect fails,
6862
+ * and `message` to prepend a custom log message.
6350
6863
  *
6351
6864
  * @example
6352
6865
  * ```ts
@@ -6355,18 +6868,21 @@ export declare const ignore: <Arg extends Effect<any, any, any> | {
6355
6868
  * const task = Effect.fail("boom")
6356
6869
  *
6357
6870
  * const program = task.pipe(Effect.ignoreCause)
6358
- * const programLog = task.pipe(Effect.ignoreCause({ log: true }))
6871
+ * const programLog = task.pipe(Effect.ignoreCause({ log: true, message: "Ignoring failure cause" }))
6359
6872
  * ```
6360
6873
  *
6361
6874
  * @since 4.0.0
6362
6875
  * @category Error Handling
6363
6876
  */
6364
6877
  export declare const ignoreCause: <Arg extends Effect<any, any, any> | {
6365
- readonly log?: boolean | LogLevel | undefined;
6878
+ readonly log?: boolean | Severity | undefined;
6879
+ readonly message?: string | undefined;
6366
6880
  } | undefined = {
6367
- readonly log?: boolean | LogLevel | undefined;
6881
+ readonly log?: boolean | Severity | undefined;
6882
+ readonly message?: string | undefined;
6368
6883
  }>(effectOrOptions?: Arg, options?: {
6369
- readonly log?: boolean | LogLevel | undefined;
6884
+ readonly log?: boolean | Severity | undefined;
6885
+ readonly message?: string | undefined;
6370
6886
  } | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R>;
6371
6887
  /**
6372
6888
  * Apply an `ExecutionPlan` to an effect, retrying with step-provided resources
@@ -6384,7 +6900,10 @@ export declare const ignoreCause: <Arg extends Effect<any, any, any> | {
6384
6900
  *
6385
6901
  * const fetchUrl = Effect.gen(function*() {
6386
6902
  * const endpoint = yield* Effect.service(Endpoint)
6387
- * return endpoint.url === "bad" ? yield* Effect.fail("Unavailable") : endpoint.url
6903
+ * if (endpoint.url === "bad") {
6904
+ * return yield* Effect.fail("Unavailable")
6905
+ * }
6906
+ * return endpoint.url
6388
6907
  * })
6389
6908
  *
6390
6909
  * const plan = ExecutionPlan.make(
@@ -6415,7 +6934,10 @@ export declare const withExecutionPlan: {
6415
6934
  *
6416
6935
  * const fetchUrl = Effect.gen(function*() {
6417
6936
  * const endpoint = yield* Effect.service(Endpoint)
6418
- * return endpoint.url === "bad" ? yield* Effect.fail("Unavailable") : endpoint.url
6937
+ * if (endpoint.url === "bad") {
6938
+ * return yield* Effect.fail("Unavailable")
6939
+ * }
6940
+ * return endpoint.url
6419
6941
  * })
6420
6942
  *
6421
6943
  * const plan = ExecutionPlan.make(
@@ -6451,7 +6973,10 @@ export declare const withExecutionPlan: {
6451
6973
  *
6452
6974
  * const fetchUrl = Effect.gen(function*() {
6453
6975
  * const endpoint = yield* Effect.service(Endpoint)
6454
- * return endpoint.url === "bad" ? yield* Effect.fail("Unavailable") : endpoint.url
6976
+ * if (endpoint.url === "bad") {
6977
+ * return yield* Effect.fail("Unavailable")
6978
+ * }
6979
+ * return endpoint.url
6455
6980
  * })
6456
6981
  *
6457
6982
  * const plan = ExecutionPlan.make(
@@ -6472,6 +6997,22 @@ export declare const withExecutionPlan: {
6472
6997
  requirements: PlanR;
6473
6998
  }>): Effect<A, E | PlanE, Exclude<R, Provides> | PlanR>;
6474
6999
  };
7000
+ /**
7001
+ * Runs an effect and reports any errors to the configured `ErrorReporter`s.
7002
+ *
7003
+ * If the `defectsOnly` option is set to `true`, only defects (unrecoverable
7004
+ * errors) will be reported, while regular failures will be ignored.
7005
+ *
7006
+ * @since 4.0.0
7007
+ * @category Error Handling
7008
+ */
7009
+ export declare const withErrorReporting: <Arg extends Effect<any, any, any> | {
7010
+ readonly defectsOnly?: boolean | undefined;
7011
+ } | undefined = {
7012
+ readonly defectsOnly?: boolean | undefined;
7013
+ }>(effectOrOptions: Arg, options?: {
7014
+ readonly defectsOnly?: boolean | undefined;
7015
+ } | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Arg : <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
6475
7016
  /**
6476
7017
  * Replaces the original failure with a success value, ensuring the effect
6477
7018
  * cannot fail.
@@ -6692,7 +7233,7 @@ export declare const timeout: {
6692
7233
  * @since 2.0.0
6693
7234
  * @category Delays & Timeouts
6694
7235
  */
6695
- (duration: Duration.DurationInput): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | Cause.TimeoutError, R>;
7236
+ (duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | Cause.TimeoutError, R>;
6696
7237
  /**
6697
7238
  * Adds a time limit to an effect, triggering a timeout if the effect exceeds
6698
7239
  * the duration.
@@ -6739,7 +7280,7 @@ export declare const timeout: {
6739
7280
  * @since 2.0.0
6740
7281
  * @category Delays & Timeouts
6741
7282
  */
6742
- <A, E, R>(self: Effect<A, E, R>, duration: Duration.DurationInput): Effect<A, E | Cause.TimeoutError, R>;
7283
+ <A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E | Cause.TimeoutError, R>;
6743
7284
  };
6744
7285
  /**
6745
7286
  * Handles timeouts by returning an `Option` that represents either the result
@@ -6840,7 +7381,7 @@ export declare const timeoutOption: {
6840
7381
  * @since 3.1.0
6841
7382
  * @category Delays & Timeouts
6842
7383
  */
6843
- (duration: Duration.DurationInput): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>;
7384
+ (duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>;
6844
7385
  /**
6845
7386
  * Handles timeouts by returning an `Option` that represents either the result
6846
7387
  * or a timeout.
@@ -6890,7 +7431,7 @@ export declare const timeoutOption: {
6890
7431
  * @since 3.1.0
6891
7432
  * @category Delays & Timeouts
6892
7433
  */
6893
- <A, E, R>(self: Effect<A, E, R>, duration: Duration.DurationInput): Effect<Option<A>, E, R>;
7434
+ <A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<Option<A>, E, R>;
6894
7435
  };
6895
7436
  /**
6896
7437
  * Applies a timeout to an effect, with a fallback effect executed if the timeout is reached.
@@ -6911,7 +7452,7 @@ export declare const timeoutOption: {
6911
7452
  * // Use cached data as fallback when timeout is reached
6912
7453
  * const program = Effect.timeoutOrElse(slowQuery, {
6913
7454
  * duration: "2 seconds",
6914
- * onTimeout: () =>
7455
+ * orElse: () =>
6915
7456
  * Effect.gen(function*() {
6916
7457
  * yield* Console.log("Query timed out, using cached data")
6917
7458
  * return "Cached result"
@@ -6948,7 +7489,7 @@ export declare const timeoutOrElse: {
6948
7489
  * // Use cached data as fallback when timeout is reached
6949
7490
  * const program = Effect.timeoutOrElse(slowQuery, {
6950
7491
  * duration: "2 seconds",
6951
- * onTimeout: () =>
7492
+ * orElse: () =>
6952
7493
  * Effect.gen(function*() {
6953
7494
  * yield* Console.log("Query timed out, using cached data")
6954
7495
  * return "Cached result"
@@ -6966,8 +7507,8 @@ export declare const timeoutOrElse: {
6966
7507
  * @category Delays & Timeouts
6967
7508
  */
6968
7509
  <A2, E2, R2>(options: {
6969
- readonly duration: Duration.DurationInput;
6970
- readonly onTimeout: LazyArg<Effect<A2, E2, R2>>;
7510
+ readonly duration: Duration.Input;
7511
+ readonly orElse: LazyArg<Effect<A2, E2, R2>>;
6971
7512
  }): <A, E, R>(self: Effect<A, E, R>) => Effect<A | A2, E | E2, R | R2>;
6972
7513
  /**
6973
7514
  * Applies a timeout to an effect, with a fallback effect executed if the timeout is reached.
@@ -6988,7 +7529,7 @@ export declare const timeoutOrElse: {
6988
7529
  * // Use cached data as fallback when timeout is reached
6989
7530
  * const program = Effect.timeoutOrElse(slowQuery, {
6990
7531
  * duration: "2 seconds",
6991
- * onTimeout: () =>
7532
+ * orElse: () =>
6992
7533
  * Effect.gen(function*() {
6993
7534
  * yield* Console.log("Query timed out, using cached data")
6994
7535
  * return "Cached result"
@@ -7006,8 +7547,8 @@ export declare const timeoutOrElse: {
7006
7547
  * @category Delays & Timeouts
7007
7548
  */
7008
7549
  <A, E, R, A2, E2, R2>(self: Effect<A, E, R>, options: {
7009
- readonly duration: Duration.DurationInput;
7010
- readonly onTimeout: LazyArg<Effect<A2, E2, R2>>;
7550
+ readonly duration: Duration.Input;
7551
+ readonly orElse: LazyArg<Effect<A2, E2, R2>>;
7011
7552
  }): Effect<A | A2, E | E2, R | R2>;
7012
7553
  };
7013
7554
  /**
@@ -7051,7 +7592,7 @@ export declare const delay: {
7051
7592
  * @since 2.0.0
7052
7593
  * @category Delays & Timeouts
7053
7594
  */
7054
- (duration: Duration.DurationInput): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
7595
+ (duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
7055
7596
  /**
7056
7597
  * Returns an effect that is delayed from this effect by the specified
7057
7598
  * `Duration`.
@@ -7072,7 +7613,7 @@ export declare const delay: {
7072
7613
  * @since 2.0.0
7073
7614
  * @category Delays & Timeouts
7074
7615
  */
7075
- <A, E, R>(self: Effect<A, E, R>, duration: Duration.DurationInput): Effect<A, E, R>;
7616
+ <A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E, R>;
7076
7617
  };
7077
7618
  /**
7078
7619
  * Returns an effect that suspends for the specified duration. This method is
@@ -7096,7 +7637,7 @@ export declare const delay: {
7096
7637
  * @since 2.0.0
7097
7638
  * @category Delays & Timeouts
7098
7639
  */
7099
- export declare const sleep: (duration: Duration.DurationInput) => Effect<void>;
7640
+ export declare const sleep: (duration: Duration.Input) => Effect<void>;
7100
7641
  /**
7101
7642
  * Measures the runtime of an effect and returns the duration with its result.
7102
7643
  *
@@ -7389,12 +7930,12 @@ export declare const raceFirst: {
7389
7930
  }): Effect<A | A2, E | E2, R | R2>;
7390
7931
  };
7391
7932
  /**
7392
- * Filters elements of an iterable using a predicate, refinement, effectful
7393
- * predicate, or `Filter.FilterEffect`.
7933
+ * Filters elements of an iterable using a predicate, refinement, or effectful
7934
+ * predicate.
7394
7935
  *
7395
7936
  * @example
7396
7937
  * ```ts
7397
- * import { Effect, Filter, Result } from "effect"
7938
+ * import { Effect } from "effect"
7398
7939
  *
7399
7940
  * // Sync predicate
7400
7941
  * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
@@ -7402,10 +7943,7 @@ export declare const raceFirst: {
7402
7943
  * // Effectful predicate
7403
7944
  * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7404
7945
  *
7405
- * // FilterEffect
7406
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7407
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7408
- * )
7946
+ * // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
7409
7947
  * ```
7410
7948
  *
7411
7949
  * @since 2.0.0
@@ -7413,12 +7951,12 @@ export declare const raceFirst: {
7413
7951
  */
7414
7952
  export declare const filter: {
7415
7953
  /**
7416
- * Filters elements of an iterable using a predicate, refinement, effectful
7417
- * predicate, or `Filter.FilterEffect`.
7954
+ * Filters elements of an iterable using a predicate, refinement, or effectful
7955
+ * predicate.
7418
7956
  *
7419
7957
  * @example
7420
7958
  * ```ts
7421
- * import { Effect, Filter, Result } from "effect"
7959
+ * import { Effect } from "effect"
7422
7960
  *
7423
7961
  * // Sync predicate
7424
7962
  * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
@@ -7426,10 +7964,7 @@ export declare const filter: {
7426
7964
  * // Effectful predicate
7427
7965
  * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7428
7966
  *
7429
- * // FilterEffect
7430
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7431
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7432
- * )
7967
+ * // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
7433
7968
  * ```
7434
7969
  *
7435
7970
  * @since 2.0.0
@@ -7437,12 +7972,12 @@ export declare const filter: {
7437
7972
  */
7438
7973
  <A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): (elements: Iterable<A>) => Effect<Array<B>>;
7439
7974
  /**
7440
- * Filters elements of an iterable using a predicate, refinement, effectful
7441
- * predicate, or `Filter.FilterEffect`.
7975
+ * Filters elements of an iterable using a predicate, refinement, or effectful
7976
+ * predicate.
7442
7977
  *
7443
7978
  * @example
7444
7979
  * ```ts
7445
- * import { Effect, Filter, Result } from "effect"
7980
+ * import { Effect } from "effect"
7446
7981
  *
7447
7982
  * // Sync predicate
7448
7983
  * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
@@ -7450,10 +7985,7 @@ export declare const filter: {
7450
7985
  * // Effectful predicate
7451
7986
  * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7452
7987
  *
7453
- * // FilterEffect
7454
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7455
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7456
- * )
7988
+ * // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
7457
7989
  * ```
7458
7990
  *
7459
7991
  * @since 2.0.0
@@ -7461,64 +7993,12 @@ export declare const filter: {
7461
7993
  */
7462
7994
  <A>(predicate: Predicate.Predicate<NoInfer<A>>): (elements: Iterable<A>) => Effect<Array<A>>;
7463
7995
  /**
7464
- * Filters elements of an iterable using a predicate, refinement, effectful
7465
- * predicate, or `Filter.FilterEffect`.
7466
- *
7467
- * @example
7468
- * ```ts
7469
- * import { Effect, Filter, Result } from "effect"
7470
- *
7471
- * // Sync predicate
7472
- * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
7473
- *
7474
- * // Effectful predicate
7475
- * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7476
- *
7477
- * // FilterEffect
7478
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7479
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7480
- * )
7481
- * ```
7482
- *
7483
- * @since 2.0.0
7484
- * @category Filtering
7485
- */
7486
- <A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>, options?: {
7487
- readonly concurrency?: Concurrency | undefined;
7488
- }): (elements: Iterable<A>) => Effect<Array<B>>;
7489
- /**
7490
- * Filters elements of an iterable using a predicate, refinement, effectful
7491
- * predicate, or `Filter.FilterEffect`.
7492
- *
7493
- * @example
7494
- * ```ts
7495
- * import { Effect, Filter, Result } from "effect"
7496
- *
7497
- * // Sync predicate
7498
- * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
7499
- *
7500
- * // Effectful predicate
7501
- * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7502
- *
7503
- * // FilterEffect
7504
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7505
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7506
- * )
7507
- * ```
7508
- *
7509
- * @since 2.0.0
7510
- * @category Filtering
7511
- */
7512
- <A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
7513
- readonly concurrency?: Concurrency | undefined;
7514
- }): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
7515
- /**
7516
- * Filters elements of an iterable using a predicate, refinement, effectful
7517
- * predicate, or `Filter.FilterEffect`.
7996
+ * Filters elements of an iterable using a predicate, refinement, or effectful
7997
+ * predicate.
7518
7998
  *
7519
7999
  * @example
7520
8000
  * ```ts
7521
- * import { Effect, Filter, Result } from "effect"
8001
+ * import { Effect } from "effect"
7522
8002
  *
7523
8003
  * // Sync predicate
7524
8004
  * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
@@ -7526,10 +8006,7 @@ export declare const filter: {
7526
8006
  * // Effectful predicate
7527
8007
  * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7528
8008
  *
7529
- * // FilterEffect
7530
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7531
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7532
- * )
8009
+ * // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
7533
8010
  * ```
7534
8011
  *
7535
8012
  * @since 2.0.0
@@ -7539,12 +8016,12 @@ export declare const filter: {
7539
8016
  readonly concurrency?: Concurrency | undefined;
7540
8017
  }): (iterable: Iterable<A>) => Effect<Array<A>, E, R>;
7541
8018
  /**
7542
- * Filters elements of an iterable using a predicate, refinement, effectful
7543
- * predicate, or `Filter.FilterEffect`.
8019
+ * Filters elements of an iterable using a predicate, refinement, or effectful
8020
+ * predicate.
7544
8021
  *
7545
8022
  * @example
7546
8023
  * ```ts
7547
- * import { Effect, Filter, Result } from "effect"
8024
+ * import { Effect } from "effect"
7548
8025
  *
7549
8026
  * // Sync predicate
7550
8027
  * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
@@ -7552,10 +8029,7 @@ export declare const filter: {
7552
8029
  * // Effectful predicate
7553
8030
  * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7554
8031
  *
7555
- * // FilterEffect
7556
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7557
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7558
- * )
8032
+ * // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
7559
8033
  * ```
7560
8034
  *
7561
8035
  * @since 2.0.0
@@ -7563,12 +8037,12 @@ export declare const filter: {
7563
8037
  */
7564
8038
  <A, B extends A>(elements: Iterable<A>, refinement: Predicate.Refinement<A, B>): Effect<Array<B>>;
7565
8039
  /**
7566
- * Filters elements of an iterable using a predicate, refinement, effectful
7567
- * predicate, or `Filter.FilterEffect`.
8040
+ * Filters elements of an iterable using a predicate, refinement, or effectful
8041
+ * predicate.
7568
8042
  *
7569
8043
  * @example
7570
8044
  * ```ts
7571
- * import { Effect, Filter, Result } from "effect"
8045
+ * import { Effect } from "effect"
7572
8046
  *
7573
8047
  * // Sync predicate
7574
8048
  * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
@@ -7576,10 +8050,7 @@ export declare const filter: {
7576
8050
  * // Effectful predicate
7577
8051
  * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7578
8052
  *
7579
- * // FilterEffect
7580
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7581
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7582
- * )
8053
+ * // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
7583
8054
  * ```
7584
8055
  *
7585
8056
  * @since 2.0.0
@@ -7587,12 +8058,12 @@ export declare const filter: {
7587
8058
  */
7588
8059
  <A>(elements: Iterable<A>, predicate: Predicate.Predicate<A>): Effect<Array<A>>;
7589
8060
  /**
7590
- * Filters elements of an iterable using a predicate, refinement, effectful
7591
- * predicate, or `Filter.FilterEffect`.
8061
+ * Filters elements of an iterable using a predicate, refinement, or effectful
8062
+ * predicate.
7592
8063
  *
7593
8064
  * @example
7594
8065
  * ```ts
7595
- * import { Effect, Filter, Result } from "effect"
8066
+ * import { Effect } from "effect"
7596
8067
  *
7597
8068
  * // Sync predicate
7598
8069
  * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
@@ -7600,68 +8071,63 @@ export declare const filter: {
7600
8071
  * // Effectful predicate
7601
8072
  * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7602
8073
  *
7603
- * // FilterEffect
7604
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7605
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7606
- * )
8074
+ * // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
7607
8075
  * ```
7608
8076
  *
7609
8077
  * @since 2.0.0
7610
8078
  * @category Filtering
7611
8079
  */
7612
- <A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>;
8080
+ <A, E, R>(iterable: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
8081
+ readonly concurrency?: Concurrency | undefined;
8082
+ }): Effect<Array<A>, E, R>;
8083
+ };
8084
+ /**
8085
+ * Filters and maps elements of an iterable with a `Filter`.
8086
+ *
8087
+ * @since 4.0.0
8088
+ * @category Filtering
8089
+ */
8090
+ export declare const filterMap: {
7613
8091
  /**
7614
- * Filters elements of an iterable using a predicate, refinement, effectful
7615
- * predicate, or `Filter.FilterEffect`.
7616
- *
7617
- * @example
7618
- * ```ts
7619
- * import { Effect, Filter, Result } from "effect"
7620
- *
7621
- * // Sync predicate
7622
- * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
7623
- *
7624
- * // Effectful predicate
7625
- * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
7626
- *
7627
- * // FilterEffect
7628
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7629
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7630
- * )
7631
- * ```
8092
+ * Filters and maps elements of an iterable with a `Filter`.
7632
8093
  *
7633
- * @since 2.0.0
8094
+ * @since 4.0.0
7634
8095
  * @category Filtering
7635
8096
  */
7636
- <A, B, X, E, R>(elements: Iterable<A>, filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
7637
- readonly concurrency?: Concurrency | undefined;
7638
- }): Effect<Array<B>, E, R>;
8097
+ <A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): (elements: Iterable<A>) => Effect<Array<B>>;
7639
8098
  /**
7640
- * Filters elements of an iterable using a predicate, refinement, effectful
7641
- * predicate, or `Filter.FilterEffect`.
7642
- *
7643
- * @example
7644
- * ```ts
7645
- * import { Effect, Filter, Result } from "effect"
8099
+ * Filters and maps elements of an iterable with a `Filter`.
7646
8100
  *
7647
- * // Sync predicate
7648
- * const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
7649
- *
7650
- * // Effectful predicate
7651
- * const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
8101
+ * @since 4.0.0
8102
+ * @category Filtering
8103
+ */
8104
+ <A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>;
8105
+ };
8106
+ /**
8107
+ * Effectfully filters and maps elements of an iterable with a `FilterEffect`.
8108
+ *
8109
+ * @since 4.0.0
8110
+ * @category Filtering
8111
+ */
8112
+ export declare const filterMapEffect: {
8113
+ /**
8114
+ * Effectfully filters and maps elements of an iterable with a `FilterEffect`.
7652
8115
  *
7653
- * // FilterEffect
7654
- * const mapped = Effect.filter([1, 2, 3, 4], (n) =>
7655
- * Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
7656
- * )
7657
- * ```
8116
+ * @since 4.0.0
8117
+ * @category Filtering
8118
+ */
8119
+ <A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
8120
+ readonly concurrency?: Concurrency | undefined;
8121
+ }): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
8122
+ /**
8123
+ * Effectfully filters and maps elements of an iterable with a `FilterEffect`.
7658
8124
  *
7659
- * @since 2.0.0
8125
+ * @since 4.0.0
7660
8126
  * @category Filtering
7661
8127
  */
7662
- <A, E, R>(iterable: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
8128
+ <A, B, X, E, R>(elements: Iterable<A>, filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
7663
8129
  readonly concurrency?: Concurrency | undefined;
7664
- }): Effect<Array<A>, E, R>;
8130
+ }): Effect<Array<B>, E, R>;
7665
8131
  };
7666
8132
  /**
7667
8133
  * Filters an effect, providing an alternative effect if the predicate fails.
@@ -7755,7 +8221,7 @@ export declare const filterOrElse: {
7755
8221
  * @since 2.0.0
7756
8222
  * @category Filtering
7757
8223
  */
7758
- <A, Result extends Filter.ResultOrBool, C, E2, R2>(filter: Filter.OrPredicate<NoInfer<A>, Result>, orElse: (a: Filter.Fail<A, Result>) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<Filter.Pass<A, Result> | C, E2 | E, R2 | R>;
8224
+ <A, C, E2, R2>(predicate: Predicate.Predicate<NoInfer<A>>, orElse: (a: NoInfer<A>) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<A | C, E2 | E, R2 | R>;
7759
8225
  /**
7760
8226
  * Filters an effect, providing an alternative effect if the predicate fails.
7761
8227
  *
@@ -7817,7 +8283,29 @@ export declare const filterOrElse: {
7817
8283
  * @since 2.0.0
7818
8284
  * @category Filtering
7819
8285
  */
7820
- <A, E, R, Result extends Filter.ResultOrBool, C, E2, R2>(self: Effect<A, E, R>, filter: Filter.OrPredicate<NoInfer<A>, Result>, orElse: (a: Filter.Fail<A, Result>) => Effect<C, E2, R2>): Effect<Filter.Pass<A, Result> | C, E | E2, R | R2>;
8286
+ <A, E, R, C, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orElse: (a: NoInfer<A>) => Effect<C, E2, R2>): Effect<A | C, E | E2, R | R2>;
8287
+ };
8288
+ /**
8289
+ * Filters an effect with a `Filter`, providing an alternative effect on failure.
8290
+ *
8291
+ * @since 4.0.0
8292
+ * @category Filtering
8293
+ */
8294
+ export declare const filterMapOrElse: {
8295
+ /**
8296
+ * Filters an effect with a `Filter`, providing an alternative effect on failure.
8297
+ *
8298
+ * @since 4.0.0
8299
+ * @category Filtering
8300
+ */
8301
+ <A, B, X, C, E2, R2>(filter: Filter.Filter<NoInfer<A>, B, X>, orElse: (x: X) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<B | C, E2 | E, R2 | R>;
8302
+ /**
8303
+ * Filters an effect with a `Filter`, providing an alternative effect on failure.
8304
+ *
8305
+ * @since 4.0.0
8306
+ * @category Filtering
8307
+ */
8308
+ <A, E, R, B, X, C, E2, R2>(self: Effect<A, E, R>, filter: Filter.Filter<NoInfer<A>, B, X>, orElse: (x: X) => Effect<C, E2, R2>): Effect<B | C, E | E2, R | R2>;
7821
8309
  };
7822
8310
  /**
7823
8311
  * Filters an effect, failing with a custom error if the predicate fails.
@@ -7938,7 +8426,7 @@ export declare const filterOrFail: {
7938
8426
  * @since 2.0.0
7939
8427
  * @category Filtering
7940
8428
  */
7941
- <A, B, X, E2>(filter: Filter.Filter<NoInfer<A>, B, X>, orFailWith: (x: X) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>;
8429
+ <A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
7942
8430
  /**
7943
8431
  * Filters an effect, failing with a custom error if the predicate fails.
7944
8432
  *
@@ -7968,7 +8456,7 @@ export declare const filterOrFail: {
7968
8456
  * @since 2.0.0
7969
8457
  * @category Filtering
7970
8458
  */
7971
- <A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
8459
+ <A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>;
7972
8460
  /**
7973
8461
  * Filters an effect, failing with a custom error if the predicate fails.
7974
8462
  *
@@ -7998,7 +8486,7 @@ export declare const filterOrFail: {
7998
8486
  * @since 2.0.0
7999
8487
  * @category Filtering
8000
8488
  */
8001
- <A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>;
8489
+ <A, E, R, E2, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>, orFailWith: (a: NoInfer<A>) => E2): Effect<B, E2 | E, R>;
8002
8490
  /**
8003
8491
  * Filters an effect, failing with a custom error if the predicate fails.
8004
8492
  *
@@ -8028,7 +8516,7 @@ export declare const filterOrFail: {
8028
8516
  * @since 2.0.0
8029
8517
  * @category Filtering
8030
8518
  */
8031
- <A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
8519
+ <A, E, R, E2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => E2): Effect<A, E2 | E, R>;
8032
8520
  /**
8033
8521
  * Filters an effect, failing with a custom error if the predicate fails.
8034
8522
  *
@@ -8058,7 +8546,7 @@ export declare const filterOrFail: {
8058
8546
  * @since 2.0.0
8059
8547
  * @category Filtering
8060
8548
  */
8061
- <A, E, R, E2, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>, orFailWith: (a: NoInfer<A>) => E2): Effect<B, E2 | E, R>;
8549
+ <A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>): Effect<B, E | Cause.NoSuchElementError, R>;
8062
8550
  /**
8063
8551
  * Filters an effect, failing with a custom error if the predicate fails.
8064
8552
  *
@@ -8088,127 +8576,43 @@ export declare const filterOrFail: {
8088
8576
  * @since 2.0.0
8089
8577
  * @category Filtering
8090
8578
  */
8091
- <A, E, R, E2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => E2): Effect<A, E2 | E, R>;
8579
+ <A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>;
8580
+ };
8581
+ /**
8582
+ * Filters an effect with a `Filter`, failing when the filter fails.
8583
+ *
8584
+ * @since 4.0.0
8585
+ * @category Filtering
8586
+ */
8587
+ export declare const filterMapOrFail: {
8092
8588
  /**
8093
- * Filters an effect, failing with a custom error if the predicate fails.
8094
- *
8095
- * **Details**
8096
- *
8097
- * This function applies a predicate to the result of an effect. If the
8098
- * predicate evaluates to `false`, the effect fails with either a custom
8099
- * error (if `orFailWith` is provided) or a `NoSuchElementError`.
8100
- *
8101
- * @example
8102
- * ```ts
8103
- * import { Effect } from "effect"
8104
- *
8105
- * // An effect that produces a number
8106
- * const program = Effect.succeed(5)
8107
- *
8108
- * // Filter for even numbers, fail for odd numbers
8109
- * const filtered = Effect.filterOrFail(
8110
- * program,
8111
- * (n) => n % 2 === 0,
8112
- * (n) => `Expected even number, got ${n}`
8113
- * )
8114
- *
8115
- * // Result: Effect.fail("Expected even number, got 5")
8116
- * ```
8589
+ * Filters an effect with a `Filter`, failing when the filter fails.
8117
8590
  *
8118
- * @since 2.0.0
8591
+ * @since 4.0.0
8119
8592
  * @category Filtering
8120
8593
  */
8121
- <A, E, R, B, X, E2>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>, orFailWith: (x: X) => E2): Effect<B, E2 | E, R>;
8594
+ <A, B, X, E2>(filter: Filter.Filter<NoInfer<A>, B, X>, orFailWith: (x: X) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>;
8122
8595
  /**
8123
- * Filters an effect, failing with a custom error if the predicate fails.
8124
- *
8125
- * **Details**
8126
- *
8127
- * This function applies a predicate to the result of an effect. If the
8128
- * predicate evaluates to `false`, the effect fails with either a custom
8129
- * error (if `orFailWith` is provided) or a `NoSuchElementError`.
8130
- *
8131
- * @example
8132
- * ```ts
8133
- * import { Effect } from "effect"
8596
+ * Filters an effect with a `Filter`, failing when the filter fails.
8134
8597
  *
8135
- * // An effect that produces a number
8136
- * const program = Effect.succeed(5)
8137
- *
8138
- * // Filter for even numbers, fail for odd numbers
8139
- * const filtered = Effect.filterOrFail(
8140
- * program,
8141
- * (n) => n % 2 === 0,
8142
- * (n) => `Expected even number, got ${n}`
8143
- * )
8144
- *
8145
- * // Result: Effect.fail("Expected even number, got 5")
8146
- * ```
8147
- *
8148
- * @since 2.0.0
8598
+ * @since 4.0.0
8149
8599
  * @category Filtering
8150
8600
  */
8151
- <A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>): Effect<B, E | Cause.NoSuchElementError, R>;
8601
+ <A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
8152
8602
  /**
8153
- * Filters an effect, failing with a custom error if the predicate fails.
8154
- *
8155
- * **Details**
8156
- *
8157
- * This function applies a predicate to the result of an effect. If the
8158
- * predicate evaluates to `false`, the effect fails with either a custom
8159
- * error (if `orFailWith` is provided) or a `NoSuchElementError`.
8160
- *
8161
- * @example
8162
- * ```ts
8163
- * import { Effect } from "effect"
8164
- *
8165
- * // An effect that produces a number
8166
- * const program = Effect.succeed(5)
8167
- *
8168
- * // Filter for even numbers, fail for odd numbers
8169
- * const filtered = Effect.filterOrFail(
8170
- * program,
8171
- * (n) => n % 2 === 0,
8172
- * (n) => `Expected even number, got ${n}`
8173
- * )
8174
- *
8175
- * // Result: Effect.fail("Expected even number, got 5")
8176
- * ```
8603
+ * Filters an effect with a `Filter`, failing when the filter fails.
8177
8604
  *
8178
- * @since 2.0.0
8605
+ * @since 4.0.0
8179
8606
  * @category Filtering
8180
8607
  */
8181
- <A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>;
8608
+ <A, E, R, B, X, E2>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>, orFailWith: (x: X) => E2): Effect<B, E2 | E, R>;
8182
8609
  /**
8183
- * Filters an effect, failing with a custom error if the predicate fails.
8184
- *
8185
- * **Details**
8610
+ * Filters an effect with a `Filter`, failing when the filter fails.
8186
8611
  *
8187
- * This function applies a predicate to the result of an effect. If the
8188
- * predicate evaluates to `false`, the effect fails with either a custom
8189
- * error (if `orFailWith` is provided) or a `NoSuchElementError`.
8190
- *
8191
- * @example
8192
- * ```ts
8193
- * import { Effect } from "effect"
8194
- *
8195
- * // An effect that produces a number
8196
- * const program = Effect.succeed(5)
8197
- *
8198
- * // Filter for even numbers, fail for odd numbers
8199
- * const filtered = Effect.filterOrFail(
8200
- * program,
8201
- * (n) => n % 2 === 0,
8202
- * (n) => `Expected even number, got ${n}`
8203
- * )
8204
- *
8205
- * // Result: Effect.fail("Expected even number, got 5")
8206
- * ```
8207
- *
8208
- * @since 2.0.0
8612
+ * @since 4.0.0
8209
8613
  * @category Filtering
8210
8614
  */
8211
- <A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, E | Cause.NoSuchElementError, R>;
8615
+ <A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, Cause.NoSuchElementError | E, R>;
8212
8616
  };
8213
8617
  /**
8214
8618
  * Conditionally executes an effect based on a boolean condition.
@@ -8349,9 +8753,11 @@ export declare const when: {
8349
8753
  * @example
8350
8754
  * ```ts
8351
8755
  * // Title: Handling Both Success and Failure Cases
8352
- * import { Effect } from "effect"
8756
+ * import { Data, Effect } from "effect"
8757
+ *
8758
+ * class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
8353
8759
  *
8354
- * const success: Effect.Effect<number, Error> = Effect.succeed(42)
8760
+ * const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
8355
8761
  *
8356
8762
  * const program1 = Effect.match(success, {
8357
8763
  * onFailure: (error) => `failure: ${error.message}`,
@@ -8362,8 +8768,8 @@ export declare const when: {
8362
8768
  * Effect.runPromise(program1).then(console.log)
8363
8769
  * // Output: "success: 42"
8364
8770
  *
8365
- * const failure: Effect.Effect<number, Error> = Effect.fail(
8366
- * new Error("Uh oh!")
8771
+ * const failure: Effect.Effect<number, ExampleError> = Effect.fail(
8772
+ * new ExampleError({ message: "Uh oh!" })
8367
8773
  * )
8368
8774
  *
8369
8775
  * const program2 = Effect.match(failure, {
@@ -8401,9 +8807,11 @@ export declare const match: {
8401
8807
  * @example
8402
8808
  * ```ts
8403
8809
  * // Title: Handling Both Success and Failure Cases
8404
- * import { Effect } from "effect"
8810
+ * import { Data, Effect } from "effect"
8405
8811
  *
8406
- * const success: Effect.Effect<number, Error> = Effect.succeed(42)
8812
+ * class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
8813
+ *
8814
+ * const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
8407
8815
  *
8408
8816
  * const program1 = Effect.match(success, {
8409
8817
  * onFailure: (error) => `failure: ${error.message}`,
@@ -8414,8 +8822,8 @@ export declare const match: {
8414
8822
  * Effect.runPromise(program1).then(console.log)
8415
8823
  * // Output: "success: 42"
8416
8824
  *
8417
- * const failure: Effect.Effect<number, Error> = Effect.fail(
8418
- * new Error("Uh oh!")
8825
+ * const failure: Effect.Effect<number, ExampleError> = Effect.fail(
8826
+ * new ExampleError({ message: "Uh oh!" })
8419
8827
  * )
8420
8828
  *
8421
8829
  * const program2 = Effect.match(failure, {
@@ -8456,9 +8864,11 @@ export declare const match: {
8456
8864
  * @example
8457
8865
  * ```ts
8458
8866
  * // Title: Handling Both Success and Failure Cases
8459
- * import { Effect } from "effect"
8867
+ * import { Data, Effect } from "effect"
8868
+ *
8869
+ * class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
8460
8870
  *
8461
- * const success: Effect.Effect<number, Error> = Effect.succeed(42)
8871
+ * const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
8462
8872
  *
8463
8873
  * const program1 = Effect.match(success, {
8464
8874
  * onFailure: (error) => `failure: ${error.message}`,
@@ -8469,8 +8879,8 @@ export declare const match: {
8469
8879
  * Effect.runPromise(program1).then(console.log)
8470
8880
  * // Output: "success: 42"
8471
8881
  *
8472
- * const failure: Effect.Effect<number, Error> = Effect.fail(
8473
- * new Error("Uh oh!")
8882
+ * const failure: Effect.Effect<number, ExampleError> = Effect.fail(
8883
+ * new ExampleError({ message: "Uh oh!" })
8474
8884
  * )
8475
8885
  *
8476
8886
  * const program2 = Effect.match(failure, {
@@ -8872,9 +9282,11 @@ export declare const matchCauseEffectEager: {
8872
9282
  *
8873
9283
  * @example
8874
9284
  * ```ts
8875
- * import { Cause, Console, Effect, Result } from "effect"
9285
+ * import { Cause, Console, Data, Effect, Result } from "effect"
8876
9286
  *
8877
- * const task = Effect.fail(new Error("Task failed"))
9287
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
9288
+ *
9289
+ * const task = Effect.fail(new TaskError({ message: "Task failed" }))
8878
9290
  *
8879
9291
  * const program = Effect.matchCauseEffect(task, {
8880
9292
  * onFailure: (cause) =>
@@ -8924,9 +9336,11 @@ export declare const matchCauseEffect: {
8924
9336
  *
8925
9337
  * @example
8926
9338
  * ```ts
8927
- * import { Cause, Console, Effect, Result } from "effect"
9339
+ * import { Cause, Console, Data, Effect, Result } from "effect"
9340
+ *
9341
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
8928
9342
  *
8929
- * const task = Effect.fail(new Error("Task failed"))
9343
+ * const task = Effect.fail(new TaskError({ message: "Task failed" }))
8930
9344
  *
8931
9345
  * const program = Effect.matchCauseEffect(task, {
8932
9346
  * onFailure: (cause) =>
@@ -8979,9 +9393,11 @@ export declare const matchCauseEffect: {
8979
9393
  *
8980
9394
  * @example
8981
9395
  * ```ts
8982
- * import { Cause, Console, Effect, Result } from "effect"
9396
+ * import { Cause, Console, Data, Effect, Result } from "effect"
8983
9397
  *
8984
- * const task = Effect.fail(new Error("Task failed"))
9398
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
9399
+ *
9400
+ * const task = Effect.fail(new TaskError({ message: "Task failed" }))
8985
9401
  *
8986
9402
  * const program = Effect.matchCauseEffect(task, {
8987
9403
  * onFailure: (cause) =>
@@ -9041,11 +9457,13 @@ export declare const matchCauseEffect: {
9041
9457
  * @example
9042
9458
  * ```ts
9043
9459
  * // Title: Handling Both Success and Failure Cases with Side Effects
9044
- * import { Effect } from "effect"
9460
+ * import { Data, Effect } from "effect"
9461
+ *
9462
+ * class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
9045
9463
  *
9046
- * const success: Effect.Effect<number, Error> = Effect.succeed(42)
9047
- * const failure: Effect.Effect<number, Error> = Effect.fail(
9048
- * new Error("Uh oh!")
9464
+ * const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
9465
+ * const failure: Effect.Effect<number, ExampleError> = Effect.fail(
9466
+ * new ExampleError({ message: "Uh oh!" })
9049
9467
  * )
9050
9468
  *
9051
9469
  * const program1 = Effect.matchEffect(success, {
@@ -9101,11 +9519,13 @@ export declare const matchEffect: {
9101
9519
  * @example
9102
9520
  * ```ts
9103
9521
  * // Title: Handling Both Success and Failure Cases with Side Effects
9104
- * import { Effect } from "effect"
9522
+ * import { Data, Effect } from "effect"
9105
9523
  *
9106
- * const success: Effect.Effect<number, Error> = Effect.succeed(42)
9107
- * const failure: Effect.Effect<number, Error> = Effect.fail(
9108
- * new Error("Uh oh!")
9524
+ * class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
9525
+ *
9526
+ * const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
9527
+ * const failure: Effect.Effect<number, ExampleError> = Effect.fail(
9528
+ * new ExampleError({ message: "Uh oh!" })
9109
9529
  * )
9110
9530
  *
9111
9531
  * const program1 = Effect.matchEffect(success, {
@@ -9164,11 +9584,13 @@ export declare const matchEffect: {
9164
9584
  * @example
9165
9585
  * ```ts
9166
9586
  * // Title: Handling Both Success and Failure Cases with Side Effects
9167
- * import { Effect } from "effect"
9587
+ * import { Data, Effect } from "effect"
9588
+ *
9589
+ * class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
9168
9590
  *
9169
- * const success: Effect.Effect<number, Error> = Effect.succeed(42)
9170
- * const failure: Effect.Effect<number, Error> = Effect.fail(
9171
- * new Error("Uh oh!")
9591
+ * const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
9592
+ * const failure: Effect.Effect<number, ExampleError> = Effect.fail(
9593
+ * new ExampleError({ message: "Uh oh!" })
9172
9594
  * )
9173
9595
  *
9174
9596
  * const program1 = Effect.matchEffect(success, {
@@ -9297,7 +9719,7 @@ export declare const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boole
9297
9719
  * @since 2.0.0
9298
9720
  * @category Environment
9299
9721
  */
9300
- export declare const services: <R>() => Effect<ServiceMap.ServiceMap<R>, never, R>;
9722
+ export declare const services: <R = never>() => Effect<ServiceMap.ServiceMap<R>, never, R>;
9301
9723
  /**
9302
9724
  * Transforms the current service map using the provided function.
9303
9725
  *
@@ -9359,7 +9781,7 @@ export declare const servicesWith: <R, A, E, R2>(f: (services: ServiceMap.Servic
9359
9781
  * const Database = ServiceMap.Service<Database>("Database")
9360
9782
  *
9361
9783
  * const DatabaseLive = Layer.succeed(Database)({
9362
- * query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
9784
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
9363
9785
  * })
9364
9786
  *
9365
9787
  * const program = Effect.gen(function*() {
@@ -9393,7 +9815,7 @@ export declare const provide: {
9393
9815
  * const Database = ServiceMap.Service<Database>("Database")
9394
9816
  *
9395
9817
  * const DatabaseLive = Layer.succeed(Database)({
9396
- * query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
9818
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
9397
9819
  * })
9398
9820
  *
9399
9821
  * const program = Effect.gen(function*() {
@@ -9429,7 +9851,7 @@ export declare const provide: {
9429
9851
  * const Database = ServiceMap.Service<Database>("Database")
9430
9852
  *
9431
9853
  * const DatabaseLive = Layer.succeed(Database)({
9432
- * query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
9854
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
9433
9855
  * })
9434
9856
  *
9435
9857
  * const program = Effect.gen(function*() {
@@ -9465,7 +9887,7 @@ export declare const provide: {
9465
9887
  * const Database = ServiceMap.Service<Database>("Database")
9466
9888
  *
9467
9889
  * const DatabaseLive = Layer.succeed(Database)({
9468
- * query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
9890
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
9469
9891
  * })
9470
9892
  *
9471
9893
  * const program = Effect.gen(function*() {
@@ -9499,7 +9921,7 @@ export declare const provide: {
9499
9921
  * const Database = ServiceMap.Service<Database>("Database")
9500
9922
  *
9501
9923
  * const DatabaseLive = Layer.succeed(Database)({
9502
- * query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
9924
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
9503
9925
  * })
9504
9926
  *
9505
9927
  * const program = Effect.gen(function*() {
@@ -9535,7 +9957,7 @@ export declare const provide: {
9535
9957
  * const Database = ServiceMap.Service<Database>("Database")
9536
9958
  *
9537
9959
  * const DatabaseLive = Layer.succeed(Database)({
9538
- * query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
9960
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
9539
9961
  * })
9540
9962
  *
9541
9963
  * const program = Effect.gen(function*() {
@@ -9571,7 +9993,7 @@ export declare const provide: {
9571
9993
  * const Database = ServiceMap.Service<Database>("Database")
9572
9994
  *
9573
9995
  * const DatabaseLive = Layer.succeed(Database)({
9574
- * query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
9996
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
9575
9997
  * })
9576
9998
  *
9577
9999
  * const program = Effect.gen(function*() {
@@ -9733,7 +10155,7 @@ export declare const provideServices: {
9733
10155
  * @since 4.0.0
9734
10156
  * @category ServiceMap
9735
10157
  */
9736
- export declare const service: <I, S>(service: ServiceMap.Service<I, S>) => Effect<S, never, I>;
10158
+ export declare const service: <I, S>(service: ServiceMap.Key<I, S>) => Effect<S, never, I>;
9737
10159
  /**
9738
10160
  * Optionally accesses a service from the environment.
9739
10161
  *
@@ -9768,7 +10190,7 @@ export declare const service: <I, S>(service: ServiceMap.Service<I, S>) => Effec
9768
10190
  * @since 2.0.0
9769
10191
  * @category ServiceMap
9770
10192
  */
9771
- export declare const serviceOption: <I, S>(key: ServiceMap.Service<I, S>) => Effect<Option<S>>;
10193
+ export declare const serviceOption: <I, S>(key: ServiceMap.Key<I, S>) => Effect<Option<S>>;
9772
10194
  /**
9773
10195
  * Provides part of the required context while leaving the rest unchanged.
9774
10196
  *
@@ -9950,7 +10372,7 @@ export declare const updateService: {
9950
10372
  * @since 2.0.0
9951
10373
  * @category ServiceMap
9952
10374
  */
9953
- <I, A>(service: ServiceMap.Service<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>;
10375
+ <I, A>(service: ServiceMap.Key<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>;
9954
10376
  /**
9955
10377
  * Updates the service with the required service entry.
9956
10378
  *
@@ -9979,7 +10401,7 @@ export declare const updateService: {
9979
10401
  * @since 2.0.0
9980
10402
  * @category ServiceMap
9981
10403
  */
9982
- <XA, E, R, I, A>(self: Effect<XA, E, R>, service: ServiceMap.Service<I, A>, f: (value: A) => A): Effect<XA, E, R | I>;
10404
+ <XA, E, R, I, A>(self: Effect<XA, E, R>, service: ServiceMap.Key<I, A>, f: (value: A) => A): Effect<XA, E, R | I>;
9983
10405
  };
9984
10406
  /**
9985
10407
  * The `provideService` function is used to provide an actual
@@ -10072,7 +10494,7 @@ export declare const provideService: {
10072
10494
  * @since 2.0.0
10073
10495
  * @category ServiceMap
10074
10496
  */
10075
- <I, S>(service: ServiceMap.Service<I, S>): {
10497
+ <I, S>(service: ServiceMap.Key<I, S>): {
10076
10498
  /**
10077
10499
  * The `provideService` function is used to provide an actual
10078
10500
  * implementation for a service in the context of an effect.
@@ -10211,7 +10633,7 @@ export declare const provideService: {
10211
10633
  * @since 2.0.0
10212
10634
  * @category ServiceMap
10213
10635
  */
10214
- <I, S>(service: ServiceMap.Service<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>;
10636
+ <I, S>(service: ServiceMap.Key<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>;
10215
10637
  /**
10216
10638
  * The `provideService` function is used to provide an actual
10217
10639
  * implementation for a service in the context of an effect.
@@ -10257,7 +10679,7 @@ export declare const provideService: {
10257
10679
  * @since 2.0.0
10258
10680
  * @category ServiceMap
10259
10681
  */
10260
- <A, E, R, I, S>(self: Effect<A, E, R>, service: ServiceMap.Service<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>;
10682
+ <A, E, R, I, S>(self: Effect<A, E, R>, service: ServiceMap.Key<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>;
10261
10683
  };
10262
10684
  /**
10263
10685
  * Provides the effect with the single service it requires. If the effect
@@ -10364,7 +10786,7 @@ export declare const provideServiceEffect: {
10364
10786
  * @since 2.0.0
10365
10787
  * @category ServiceMap
10366
10788
  */
10367
- <I, S, E2, R2>(service: ServiceMap.Service<I, S>, acquire: Effect<S, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>;
10789
+ <I, S, E2, R2>(service: ServiceMap.Key<I, S>, acquire: Effect<S, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>;
10368
10790
  /**
10369
10791
  * Provides the effect with the single service it requires. If the effect
10370
10792
  * requires more than one service use `provide` instead.
@@ -10417,7 +10839,7 @@ export declare const provideServiceEffect: {
10417
10839
  * @since 2.0.0
10418
10840
  * @category ServiceMap
10419
10841
  */
10420
- <A, E, R, I, S, E2, R2>(self: Effect<A, E, R>, service: ServiceMap.Service<I, S>, acquire: Effect<S, E2, R2>): Effect<A, E | E2, Exclude<R, I> | R2>;
10842
+ <A, E, R, I, S, E2, R2>(self: Effect<A, E, R>, service: ServiceMap.Key<I, S>, acquire: Effect<S, E2, R2>): Effect<A, E | E2, Exclude<R, I> | R2>;
10421
10843
  };
10422
10844
  /**
10423
10845
  * Sets the concurrency level for parallel operations within an effect.
@@ -10672,7 +11094,9 @@ export declare const scopedWith: <A, E, R>(f: (scope: Scope) => Effect<A, E, R>)
10672
11094
  * @since 2.0.0
10673
11095
  * @category Resource Management & Finalization
10674
11096
  */
10675
- export declare const acquireRelease: <A, E, R>(acquire: Effect<A, E, R>, release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect<unknown>) => Effect<A, E, R | Scope>;
11097
+ export declare const acquireRelease: <A, E, R, R2>(acquire: Effect<A, E, R>, release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect<unknown, never, R2>, options?: {
11098
+ readonly interruptible?: boolean;
11099
+ }) => Effect<A, E, R | R2 | Scope>;
10676
11100
  /**
10677
11101
  * This function is used to ensure that an `Effect` value that represents the
10678
11102
  * acquisition of a resource (for example, opening a file, launching a thread,
@@ -10914,9 +11338,11 @@ export declare const ensuring: {
10914
11338
  *
10915
11339
  * @example
10916
11340
  * ```ts
10917
- * import { Cause, Console, Effect } from "effect"
11341
+ * import { Cause, Data, Console, Effect } from "effect"
11342
+ *
11343
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
10918
11344
  *
10919
- * const task = Effect.fail(new Error("Something went wrong"))
11345
+ * const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
10920
11346
  *
10921
11347
  * const program = Effect.onError(
10922
11348
  * task,
@@ -10925,8 +11351,8 @@ export declare const ensuring: {
10925
11351
  *
10926
11352
  * Effect.runPromise(program).catch(console.error)
10927
11353
  * // Output:
10928
- * // Cleanup on error: Error: Something went wrong
10929
- * // Error: Something went wrong
11354
+ * // Cleanup on error: TaskError: Something went wrong
11355
+ * // TaskError: Something went wrong
10930
11356
  * ```
10931
11357
  *
10932
11358
  * @since 2.0.0
@@ -10939,9 +11365,11 @@ export declare const onError: {
10939
11365
  *
10940
11366
  * @example
10941
11367
  * ```ts
10942
- * import { Cause, Console, Effect } from "effect"
11368
+ * import { Cause, Data, Console, Effect } from "effect"
11369
+ *
11370
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
10943
11371
  *
10944
- * const task = Effect.fail(new Error("Something went wrong"))
11372
+ * const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
10945
11373
  *
10946
11374
  * const program = Effect.onError(
10947
11375
  * task,
@@ -10950,8 +11378,8 @@ export declare const onError: {
10950
11378
  *
10951
11379
  * Effect.runPromise(program).catch(console.error)
10952
11380
  * // Output:
10953
- * // Cleanup on error: Error: Something went wrong
10954
- * // Error: Something went wrong
11381
+ * // Cleanup on error: TaskError: Something went wrong
11382
+ * // TaskError: Something went wrong
10955
11383
  * ```
10956
11384
  *
10957
11385
  * @since 2.0.0
@@ -10964,9 +11392,11 @@ export declare const onError: {
10964
11392
  *
10965
11393
  * @example
10966
11394
  * ```ts
10967
- * import { Cause, Console, Effect } from "effect"
11395
+ * import { Cause, Data, Console, Effect } from "effect"
11396
+ *
11397
+ * class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
10968
11398
  *
10969
- * const task = Effect.fail(new Error("Something went wrong"))
11399
+ * const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
10970
11400
  *
10971
11401
  * const program = Effect.onError(
10972
11402
  * task,
@@ -10975,8 +11405,8 @@ export declare const onError: {
10975
11405
  *
10976
11406
  * Effect.runPromise(program).catch(console.error)
10977
11407
  * // Output:
10978
- * // Cleanup on error: Error: Something went wrong
10979
- * // Error: Something went wrong
11408
+ * // Cleanup on error: TaskError: Something went wrong
11409
+ * // TaskError: Something went wrong
10980
11410
  * ```
10981
11411
  *
10982
11412
  * @since 2.0.0
@@ -10986,7 +11416,7 @@ export declare const onError: {
10986
11416
  };
10987
11417
  /**
10988
11418
  * Runs the finalizer only when this effect fails and the `Cause` matches the
10989
- * filter, passing the filtered failure and the original cause.
11419
+ * provided predicate.
10990
11420
  *
10991
11421
  * @example
10992
11422
  * ```ts
@@ -11010,7 +11440,7 @@ export declare const onError: {
11010
11440
  export declare const onErrorIf: {
11011
11441
  /**
11012
11442
  * Runs the finalizer only when this effect fails and the `Cause` matches the
11013
- * filter, passing the filtered failure and the original cause.
11443
+ * provided predicate.
11014
11444
  *
11015
11445
  * @example
11016
11446
  * ```ts
@@ -11031,10 +11461,10 @@ export declare const onErrorIf: {
11031
11461
  * @since 4.0.0
11032
11462
  * @category Resource Management & Finalization
11033
11463
  */
11034
- <E, Result extends Filter.ResultOrBool, XE, XR>(filter: Filter.OrPredicate<Cause.Cause<E>, Result>, f: (failure: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Effect<void, XE, XR>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
11464
+ <E, XE, XR>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
11035
11465
  /**
11036
11466
  * Runs the finalizer only when this effect fails and the `Cause` matches the
11037
- * filter, passing the filtered failure and the original cause.
11467
+ * provided predicate.
11038
11468
  *
11039
11469
  * @example
11040
11470
  * ```ts
@@ -11055,7 +11485,29 @@ export declare const onErrorIf: {
11055
11485
  * @since 4.0.0
11056
11486
  * @category Resource Management & Finalization
11057
11487
  */
11058
- <A, E, R, XE, XR, Result extends Filter.ResultOrBool>(self: Effect<A, E, R>, filter: Filter.OrPredicate<Cause.Cause<E>, Result>, f: (failure: Filter.Pass<Cause.Cause<E>, Result>, cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
11488
+ <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
11489
+ };
11490
+ /**
11491
+ * Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
11492
+ *
11493
+ * @since 4.0.0
11494
+ * @category Resource Management & Finalization
11495
+ */
11496
+ export declare const onErrorFilter: {
11497
+ /**
11498
+ * Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
11499
+ *
11500
+ * @since 4.0.0
11501
+ * @category Resource Management & Finalization
11502
+ */
11503
+ <A, E, EB, X, XE, XR>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
11504
+ /**
11505
+ * Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
11506
+ *
11507
+ * @since 4.0.0
11508
+ * @category Resource Management & Finalization
11509
+ */
11510
+ <A, E, R, EB, X, XE, XR>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
11059
11511
  };
11060
11512
  /**
11061
11513
  * The low level primitive that powers `onExit`.
@@ -11149,20 +11601,20 @@ export declare const onExit: {
11149
11601
  <A, E, R, XE = never, XR = never>(self: Effect<A, E, R>, f: (exit: Exit.Exit<A, E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
11150
11602
  };
11151
11603
  /**
11152
- * Runs the cleanup effect only when the `Exit` passes the provided filter.
11153
- *
11154
- * The cleanup is skipped when the filter returns `Filter.fail`.
11604
+ * Runs the cleanup effect only when the `Exit` satisfies the provided
11605
+ * predicate.
11155
11606
  *
11156
11607
  * @example
11157
11608
  * ```ts
11158
- * import { Console, Effect, Exit, Filter } from "effect"
11159
- *
11160
- * const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
11609
+ * import { Console, Effect, Exit } from "effect"
11161
11610
  *
11162
11611
  * const program = Effect.onExitIf(
11163
11612
  * Effect.succeed(42),
11164
- * exitFilter,
11165
- * (success) => Console.log(`Succeeded with: ${success.value}`)
11613
+ * Exit.isSuccess,
11614
+ * (exit) =>
11615
+ * Exit.isSuccess(exit)
11616
+ * ? Console.log(`Succeeded with: ${exit.value}`)
11617
+ * : Effect.void
11166
11618
  * )
11167
11619
  * ```
11168
11620
  *
@@ -11171,49 +11623,71 @@ export declare const onExit: {
11171
11623
  */
11172
11624
  export declare const onExitIf: {
11173
11625
  /**
11174
- * Runs the cleanup effect only when the `Exit` passes the provided filter.
11175
- *
11176
- * The cleanup is skipped when the filter returns `Filter.fail`.
11626
+ * Runs the cleanup effect only when the `Exit` satisfies the provided
11627
+ * predicate.
11177
11628
  *
11178
11629
  * @example
11179
11630
  * ```ts
11180
- * import { Console, Effect, Exit, Filter } from "effect"
11631
+ * import { Console, Effect, Exit } from "effect"
11632
+ *
11633
+ * const program = Effect.onExitIf(
11634
+ * Effect.succeed(42),
11635
+ * Exit.isSuccess,
11636
+ * (exit) =>
11637
+ * Exit.isSuccess(exit)
11638
+ * ? Console.log(`Succeeded with: ${exit.value}`)
11639
+ * : Effect.void
11640
+ * )
11641
+ * ```
11642
+ *
11643
+ * @since 4.0.0
11644
+ * @category Resource Management & Finalization
11645
+ */
11646
+ <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
11647
+ /**
11648
+ * Runs the cleanup effect only when the `Exit` satisfies the provided
11649
+ * predicate.
11181
11650
  *
11182
- * const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
11651
+ * @example
11652
+ * ```ts
11653
+ * import { Console, Effect, Exit } from "effect"
11183
11654
  *
11184
11655
  * const program = Effect.onExitIf(
11185
11656
  * Effect.succeed(42),
11186
- * exitFilter,
11187
- * (success) => Console.log(`Succeeded with: ${success.value}`)
11657
+ * Exit.isSuccess,
11658
+ * (exit) =>
11659
+ * Exit.isSuccess(exit)
11660
+ * ? Console.log(`Succeeded with: ${exit.value}`)
11661
+ * : Effect.void
11188
11662
  * )
11189
11663
  * ```
11190
11664
  *
11191
11665
  * @since 4.0.0
11192
11666
  * @category Resource Management & Finalization
11193
11667
  */
11194
- <A, E, XE, XR, Result extends Filter.ResultOrBool>(filter: Filter.OrPredicate<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>, f: (pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
11668
+ <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
11669
+ };
11670
+ /**
11671
+ * Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
11672
+ *
11673
+ * @since 4.0.0
11674
+ * @category Resource Management & Finalization
11675
+ */
11676
+ export declare const onExitFilter: {
11677
+ /**
11678
+ * Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
11679
+ *
11680
+ * @since 4.0.0
11681
+ * @category Resource Management & Finalization
11682
+ */
11683
+ <A, E, XE, XR, B, X>(filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>, f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
11195
11684
  /**
11196
- * Runs the cleanup effect only when the `Exit` passes the provided filter.
11197
- *
11198
- * The cleanup is skipped when the filter returns `Filter.fail`.
11199
- *
11200
- * @example
11201
- * ```ts
11202
- * import { Console, Effect, Exit, Filter } from "effect"
11203
- *
11204
- * const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
11205
- *
11206
- * const program = Effect.onExitIf(
11207
- * Effect.succeed(42),
11208
- * exitFilter,
11209
- * (success) => Console.log(`Succeeded with: ${success.value}`)
11210
- * )
11211
- * ```
11685
+ * Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
11212
11686
  *
11213
11687
  * @since 4.0.0
11214
11688
  * @category Resource Management & Finalization
11215
11689
  */
11216
- <A, E, R, XE, XR, Result extends Filter.ResultOrBool>(self: Effect<A, E, R>, filter: Filter.OrPredicate<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>, f: (pass: Filter.Pass<Exit.Exit<NoInfer<A>, NoInfer<E>>, Result>, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
11690
+ <A, E, R, XE, XR, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>, f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
11217
11691
  };
11218
11692
  /**
11219
11693
  * Returns an effect that lazily computes a result and caches it for subsequent
@@ -11412,7 +11886,7 @@ export declare const cachedWithTTL: {
11412
11886
  * @since 2.0.0
11413
11887
  * @category Caching
11414
11888
  */
11415
- (timeToLive: Duration.DurationInput): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>;
11889
+ (timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>;
11416
11890
  /**
11417
11891
  * Returns an effect that caches its result for a specified `Duration`,
11418
11892
  * known as "timeToLive" (TTL).
@@ -11479,7 +11953,7 @@ export declare const cachedWithTTL: {
11479
11953
  * @since 2.0.0
11480
11954
  * @category Caching
11481
11955
  */
11482
- <A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.DurationInput): Effect<Effect<A, E, R>>;
11956
+ <A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<Effect<A, E, R>>;
11483
11957
  };
11484
11958
  /**
11485
11959
  * Caches an effect's result for a specified duration and allows manual
@@ -11620,7 +12094,7 @@ export declare const cachedInvalidateWithTTL: {
11620
12094
  * @since 2.0.0
11621
12095
  * @category Caching
11622
12096
  */
11623
- (timeToLive: Duration.DurationInput): <A, E, R>(self: Effect<A, E, R>) => Effect<[Effect<A, E, R>, Effect<void>]>;
12097
+ (timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<[Effect<A, E, R>, Effect<void>]>;
11624
12098
  /**
11625
12099
  * Caches an effect's result for a specified duration and allows manual
11626
12100
  * invalidation before expiration.
@@ -11690,7 +12164,7 @@ export declare const cachedInvalidateWithTTL: {
11690
12164
  * @since 2.0.0
11691
12165
  * @category Caching
11692
12166
  */
11693
- <A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.DurationInput): Effect<[Effect<A, E, R>, Effect<void>]>;
12167
+ <A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<[Effect<A, E, R>, Effect<void>]>;
11694
12168
  };
11695
12169
  /**
11696
12170
  * Returns an effect that is immediately interrupted.
@@ -11700,8 +12174,8 @@ export declare const cachedInvalidateWithTTL: {
11700
12174
  * import { Effect } from "effect"
11701
12175
  *
11702
12176
  * const program = Effect.gen(function*() {
11703
- * yield* Effect.interrupt
11704
- * yield* Effect.succeed("This won't execute")
12177
+ * return yield* Effect.interrupt
12178
+ * yield* Effect.succeed("This won't execute and is unreachable")
11705
12179
  * })
11706
12180
  *
11707
12181
  * Effect.runPromise(program).catch(console.error)
@@ -11890,232 +12364,6 @@ export declare const uninterruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(ef
11890
12364
  * @category Interruption
11891
12365
  */
11892
12366
  export declare const interruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(effect: Effect<AX, EX, RX>) => Effect<AX, EX, RX>) => Effect<A, E, R>) => Effect<A, E, R>;
11893
- /**
11894
- * @category Semaphore
11895
- * @since 2.0.0
11896
- * @example
11897
- * ```ts
11898
- * import { Effect } from "effect"
11899
- *
11900
- * // Create and use a semaphore for controlling concurrent access
11901
- * const program = Effect.gen(function*() {
11902
- * const semaphore = yield* Effect.makeSemaphore(2)
11903
- *
11904
- * return yield* semaphore.withPermits(1)(
11905
- * Effect.succeed("Resource accessed")
11906
- * )
11907
- * })
11908
- * ```
11909
- */
11910
- export interface Semaphore {
11911
- /**
11912
- * Adjusts the number of permits available in the semaphore.
11913
- */
11914
- resize(permits: number): Effect<void>;
11915
- /**
11916
- * Runs an effect with the given number of permits and releases the permits
11917
- * when the effect completes.
11918
- *
11919
- * **Details**
11920
- *
11921
- * This function acquires the specified number of permits before executing
11922
- * the provided effect. Once the effect finishes, the permits are released.
11923
- * If insufficient permits are available, the function will wait until they
11924
- * are released by other tasks.
11925
- */
11926
- withPermits(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
11927
- /**
11928
- * Runs an effect with the given number of permits and releases the permits
11929
- * when the effect completes.
11930
- *
11931
- * **Details**
11932
- *
11933
- * This function acquires the specified number of permits before executing
11934
- * the provided effect. Once the effect finishes, the permits are released.
11935
- * If insufficient permits are available, the function will wait until they
11936
- * are released by other tasks.
11937
- */
11938
- withPermit<A, E, R>(self: Effect<A, E, R>): Effect<A, E, R>;
11939
- /**
11940
- * Runs an effect only if the specified number of permits are immediately
11941
- * available.
11942
- *
11943
- * **Details**
11944
- *
11945
- * This function attempts to acquire the specified number of permits. If they
11946
- * are available, it runs the effect and releases the permits after the effect
11947
- * completes. If permits are not available, the effect does not execute, and
11948
- * the result is `Option.none`.
11949
- */
11950
- withPermitsIfAvailable(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>;
11951
- /**
11952
- * Acquires the specified number of permits and returns the resulting
11953
- * available permits, suspending the task if they are not yet available.
11954
- * Concurrent pending `take` calls are processed in a first-in, first-out manner.
11955
- */
11956
- take(permits: number): Effect<number>;
11957
- /**
11958
- * Releases the specified number of permits and returns the resulting
11959
- * available permits.
11960
- */
11961
- release(permits: number): Effect<number>;
11962
- /**
11963
- * Releases all permits held by this semaphore and returns the resulting available permits.
11964
- */
11965
- releaseAll: Effect<number>;
11966
- }
11967
- /**
11968
- * Unsafely creates a new Semaphore.
11969
- *
11970
- * @example
11971
- * ```ts
11972
- * import { Effect } from "effect"
11973
- *
11974
- * const semaphore = Effect.makeSemaphoreUnsafe(3)
11975
- *
11976
- * const task = (id: number) =>
11977
- * semaphore.withPermits(1)(
11978
- * Effect.gen(function*() {
11979
- * yield* Effect.log(`Task ${id} started`)
11980
- * yield* Effect.sleep("1 second")
11981
- * yield* Effect.log(`Task ${id} completed`)
11982
- * })
11983
- * )
11984
- *
11985
- * // Only 3 tasks can run concurrently
11986
- * const program = Effect.all([
11987
- * task(1),
11988
- * task(2),
11989
- * task(3),
11990
- * task(4),
11991
- * task(5)
11992
- * ], { concurrency: "unbounded" })
11993
- * ```
11994
- *
11995
- * @since 2.0.0
11996
- * @category Semaphore
11997
- */
11998
- export declare const makeSemaphoreUnsafe: (permits: number) => Semaphore;
11999
- /**
12000
- * Creates a new Semaphore.
12001
- *
12002
- * @example
12003
- * ```ts
12004
- * import { Effect } from "effect"
12005
- *
12006
- * const program = Effect.gen(function*() {
12007
- * const semaphore = yield* Effect.makeSemaphore(2)
12008
- *
12009
- * const task = (id: number) =>
12010
- * semaphore.withPermits(1)(
12011
- * Effect.gen(function*() {
12012
- * yield* Effect.log(`Task ${id} acquired permit`)
12013
- * yield* Effect.sleep("1 second")
12014
- * yield* Effect.log(`Task ${id} releasing permit`)
12015
- * })
12016
- * )
12017
- *
12018
- * // Run 4 tasks, but only 2 can run concurrently
12019
- * yield* Effect.all([task(1), task(2), task(3), task(4)])
12020
- * })
12021
- * ```
12022
- *
12023
- * @since 2.0.0
12024
- * @category Semaphore
12025
- */
12026
- export declare const makeSemaphore: (permits: number) => Effect<Semaphore>;
12027
- /**
12028
- * @category Latch
12029
- * @since 3.8.0
12030
- * @example
12031
- * ```ts
12032
- * import { Effect } from "effect"
12033
- *
12034
- * // Create and use a latch for coordination between fibers
12035
- * const program = Effect.gen(function*() {
12036
- * const latch = yield* Effect.makeLatch()
12037
- *
12038
- * // Wait for the latch to be opened
12039
- * yield* latch.await
12040
- *
12041
- * return "Latch was opened!"
12042
- * })
12043
- * ```
12044
- */
12045
- export interface Latch {
12046
- /** open the latch, releasing all fibers waiting on it */
12047
- readonly open: Effect<boolean>;
12048
- /** open the latch, releasing all fibers waiting on it */
12049
- readonly openUnsafe: () => boolean;
12050
- /** release all fibers waiting on the latch, without opening it */
12051
- readonly release: Effect<boolean>;
12052
- /** wait for the latch to be opened */
12053
- readonly await: Effect<void>;
12054
- /** close the latch */
12055
- readonly close: Effect<boolean>;
12056
- /** close the latch */
12057
- readonly closeUnsafe: () => boolean;
12058
- /** only run the given effect when the latch is open */
12059
- readonly whenOpen: <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
12060
- }
12061
- /**
12062
- * Creates a new Latch.
12063
- *
12064
- * @example
12065
- * ```ts
12066
- * import { Effect } from "effect"
12067
- *
12068
- * const latch = Effect.makeLatchUnsafe(false)
12069
- *
12070
- * const waiter = Effect.gen(function*() {
12071
- * yield* Effect.log("Waiting for latch to open...")
12072
- * yield* latch.await
12073
- * yield* Effect.log("Latch opened! Continuing...")
12074
- * })
12075
- *
12076
- * const opener = Effect.gen(function*() {
12077
- * yield* Effect.sleep("2 seconds")
12078
- * yield* Effect.log("Opening latch...")
12079
- * yield* latch.open
12080
- * })
12081
- *
12082
- * const program = Effect.all([waiter, opener])
12083
- * ```
12084
- *
12085
- * @category Latch
12086
- * @since 3.8.0
12087
- */
12088
- export declare const makeLatchUnsafe: (open?: boolean | undefined) => Latch;
12089
- /**
12090
- * Creates a new Latch.
12091
- *
12092
- * @example
12093
- * ```ts
12094
- * import { Effect } from "effect"
12095
- *
12096
- * const program = Effect.gen(function*() {
12097
- * const latch = yield* Effect.makeLatch(false)
12098
- *
12099
- * const waiter = Effect.gen(function*() {
12100
- * yield* Effect.log("Waiting for latch to open...")
12101
- * yield* latch.await
12102
- * yield* Effect.log("Latch opened! Continuing...")
12103
- * })
12104
- *
12105
- * const opener = Effect.gen(function*() {
12106
- * yield* Effect.sleep("2 seconds")
12107
- * yield* Effect.log("Opening latch...")
12108
- * yield* latch.open
12109
- * })
12110
- *
12111
- * yield* Effect.all([waiter, opener])
12112
- * })
12113
- * ```
12114
- *
12115
- * @category Latch
12116
- * @since 3.8.0
12117
- */
12118
- export declare const makeLatch: (open?: boolean | undefined) => Effect<Latch>;
12119
12367
  /**
12120
12368
  * @since 2.0.0
12121
12369
  * @category Repetition / Recursion
@@ -12147,7 +12395,9 @@ export declare namespace Repeat {
12147
12395
  schedule: Schedule<infer Out, infer _I, infer _E, infer _R>;
12148
12396
  } ? Out : O extends {
12149
12397
  until: Predicate.Refinement<A, infer B>;
12150
- } ? B : A, E | (O extends {
12398
+ } ? B : O extends {
12399
+ while: Predicate.Refinement<A, infer B>;
12400
+ } ? Exclude<A, B> : A, E | (O extends {
12151
12401
  schedule: Schedule<infer _Out, infer _I, infer E, infer _R>;
12152
12402
  } ? E : never) | (O extends {
12153
12403
  while: (...args: Array<any>) => Effect<infer _A, infer E, infer _R>;
@@ -12696,7 +12946,7 @@ export declare const repeat: {
12696
12946
  * attempt++
12697
12947
  * if (attempt <= 2) {
12698
12948
  * yield* Console.log(`Attempt ${attempt} failed`)
12699
- * yield* Effect.fail(`Error ${attempt}`)
12949
+ * return yield* Effect.fail(`Error ${attempt}`)
12700
12950
  * }
12701
12951
  * yield* Console.log(`Attempt ${attempt} succeeded`)
12702
12952
  * return "success"
@@ -12746,7 +12996,7 @@ export declare const repeatOrElse: {
12746
12996
  * attempt++
12747
12997
  * if (attempt <= 2) {
12748
12998
  * yield* Console.log(`Attempt ${attempt} failed`)
12749
- * yield* Effect.fail(`Error ${attempt}`)
12999
+ * return yield* Effect.fail(`Error ${attempt}`)
12750
13000
  * }
12751
13001
  * yield* Console.log(`Attempt ${attempt} succeeded`)
12752
13002
  * return "success"
@@ -12796,7 +13046,7 @@ export declare const repeatOrElse: {
12796
13046
  * attempt++
12797
13047
  * if (attempt <= 2) {
12798
13048
  * yield* Console.log(`Attempt ${attempt} failed`)
12799
- * yield* Effect.fail(`Error ${attempt}`)
13049
+ * return yield* Effect.fail(`Error ${attempt}`)
12800
13050
  * }
12801
13051
  * yield* Console.log(`Attempt ${attempt} succeeded`)
12802
13052
  * return "success"
@@ -14195,7 +14445,7 @@ export declare const withParentSpan: {
14195
14445
  * )
14196
14446
  *
14197
14447
  * const program = Effect.gen(function*() {
14198
- * const name = yield* Effect.request(GetUser({ id: 1 }), Effect.succeed(resolver))
14448
+ * const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
14199
14449
  * yield* Console.log(name)
14200
14450
  * })
14201
14451
  * ```
@@ -14226,7 +14476,7 @@ export declare const request: {
14226
14476
  * )
14227
14477
  *
14228
14478
  * const program = Effect.gen(function*() {
14229
- * const name = yield* Effect.request(GetUser({ id: 1 }), Effect.succeed(resolver))
14479
+ * const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
14230
14480
  * yield* Console.log(name)
14231
14481
  * })
14232
14482
  * ```
@@ -14257,7 +14507,7 @@ export declare const request: {
14257
14507
  * )
14258
14508
  *
14259
14509
  * const program = Effect.gen(function*() {
14260
- * const name = yield* Effect.request(GetUser({ id: 1 }), Effect.succeed(resolver))
14510
+ * const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
14261
14511
  * yield* Console.log(name)
14262
14512
  * })
14263
14513
  * ```
@@ -14466,7 +14716,7 @@ export declare const forkScoped: <Arg extends Effect<any, any, any> | {
14466
14716
  }>(effectOrOptions?: Arg, options?: {
14467
14717
  readonly startImmediately?: boolean | undefined;
14468
14718
  readonly uninterruptible?: boolean | "inherit" | undefined;
14469
- } | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<Fiber<_A, _E>, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<Fiber<A, E>, never, R | Scope>;
14719
+ } | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<Fiber<_A, _E>, never, _R | Scope> : <A, E, R>(self: Effect<A, E, R>) => Effect<Fiber<A, E>, never, R | Scope>;
14470
14720
  /**
14471
14721
  * Forks the effect into a new fiber attached to the global scope. Because the
14472
14722
  * new fiber is attached to the global scope, when the fiber executing the
@@ -14586,6 +14836,7 @@ export interface RunOptions {
14586
14836
  readonly signal?: AbortSignal | undefined;
14587
14837
  readonly scheduler?: Scheduler | undefined;
14588
14838
  readonly uninterruptible?: boolean | undefined;
14839
+ readonly onFiberStart?: ((fiber: Fiber<unknown, unknown>) => void) | undefined;
14589
14840
  }
14590
14841
  /**
14591
14842
  * The foundational function for running effects, returning a "fiber" that can
@@ -15772,7 +16023,7 @@ export declare const clockWith: <A, E, R>(f: (clock: Clock) => Effect<A, E, R>)
15772
16023
  * @since 2.0.0
15773
16024
  * @category Logging
15774
16025
  */
15775
- export declare const logWithLevel: (level?: LogLevel) => (...message: ReadonlyArray<any>) => Effect<void>;
16026
+ export declare const logWithLevel: (level?: Severity) => (...message: ReadonlyArray<any>) => Effect<void>;
15776
16027
  /**
15777
16028
  * Logs one or more messages using the default log level.
15778
16029
  *
@@ -16039,6 +16290,85 @@ export declare const annotateLogs: {
16039
16290
  <A, E, R>(effect: Effect<A, E, R>, key: string, value: unknown): Effect<A, E, R>;
16040
16291
  <A, E, R>(effect: Effect<A, E, R>, values: Record<string, unknown>): Effect<A, E, R>;
16041
16292
  };
16293
+ /**
16294
+ * Adds log annotations to the current scope.
16295
+ *
16296
+ * This differs from `annotateLogs`, which only annotates a specific effect.
16297
+ * `annotateLogsScoped` updates annotations for the entire current `Scope` and
16298
+ * restores the previous annotations when the scope closes.
16299
+ *
16300
+ * @example
16301
+ * ```ts
16302
+ * import { Effect } from "effect"
16303
+ *
16304
+ * const program = Effect.scoped(
16305
+ * Effect.gen(function*() {
16306
+ * yield* Effect.log("before")
16307
+ * yield* Effect.annotateLogsScoped({ requestId: "req-123" })
16308
+ * yield* Effect.log("inside scope")
16309
+ * })
16310
+ * )
16311
+ *
16312
+ * Effect.runPromise(program)
16313
+ * ```
16314
+ *
16315
+ * @since 4.0.0
16316
+ * @category Logging
16317
+ */
16318
+ export declare const annotateLogsScoped: {
16319
+ /**
16320
+ * Adds log annotations to the current scope.
16321
+ *
16322
+ * This differs from `annotateLogs`, which only annotates a specific effect.
16323
+ * `annotateLogsScoped` updates annotations for the entire current `Scope` and
16324
+ * restores the previous annotations when the scope closes.
16325
+ *
16326
+ * @example
16327
+ * ```ts
16328
+ * import { Effect } from "effect"
16329
+ *
16330
+ * const program = Effect.scoped(
16331
+ * Effect.gen(function*() {
16332
+ * yield* Effect.log("before")
16333
+ * yield* Effect.annotateLogsScoped({ requestId: "req-123" })
16334
+ * yield* Effect.log("inside scope")
16335
+ * })
16336
+ * )
16337
+ *
16338
+ * Effect.runPromise(program)
16339
+ * ```
16340
+ *
16341
+ * @since 4.0.0
16342
+ * @category Logging
16343
+ */
16344
+ (key: string, value: unknown): Effect<void, never, Scope>;
16345
+ /**
16346
+ * Adds log annotations to the current scope.
16347
+ *
16348
+ * This differs from `annotateLogs`, which only annotates a specific effect.
16349
+ * `annotateLogsScoped` updates annotations for the entire current `Scope` and
16350
+ * restores the previous annotations when the scope closes.
16351
+ *
16352
+ * @example
16353
+ * ```ts
16354
+ * import { Effect } from "effect"
16355
+ *
16356
+ * const program = Effect.scoped(
16357
+ * Effect.gen(function*() {
16358
+ * yield* Effect.log("before")
16359
+ * yield* Effect.annotateLogsScoped({ requestId: "req-123" })
16360
+ * yield* Effect.log("inside scope")
16361
+ * })
16362
+ * )
16363
+ *
16364
+ * Effect.runPromise(program)
16365
+ * ```
16366
+ *
16367
+ * @since 4.0.0
16368
+ * @category Logging
16369
+ */
16370
+ (values: Record<string, unknown>): Effect<void, never, Scope>;
16371
+ };
16042
16372
  /**
16043
16373
  * Adds a span to each log line in this effect.
16044
16374
  *
@@ -16574,18 +16904,20 @@ export declare const trackSuccesses: {
16574
16904
  *
16575
16905
  * @example
16576
16906
  * ```ts
16577
- * import { Effect, Metric } from "effect"
16907
+ * import { Data, Effect, Metric } from "effect"
16908
+ *
16909
+ * class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
16578
16910
  *
16579
16911
  * // Track error types using frequency metric
16580
16912
  * const errorTypeFrequency = Metric.frequency("error_types")
16581
16913
  *
16582
- * const program = Effect.fail(new Error("Connection failed")).pipe(
16583
- * Effect.trackErrors(errorTypeFrequency, (error: Error) => error.name)
16914
+ * const program = Effect.fail(new ConnectionFailedError()).pipe(
16915
+ * Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
16584
16916
  * )
16585
16917
  *
16586
16918
  * Effect.runPromiseExit(program).then(() =>
16587
16919
  * Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
16588
- * // Output: { occurrences: Map(1) { "Error" => 1 } }
16920
+ * // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
16589
16921
  * )
16590
16922
  * ```
16591
16923
  *
@@ -16620,18 +16952,20 @@ export declare const trackErrors: {
16620
16952
  *
16621
16953
  * @example
16622
16954
  * ```ts
16623
- * import { Effect, Metric } from "effect"
16955
+ * import { Data, Effect, Metric } from "effect"
16956
+ *
16957
+ * class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
16624
16958
  *
16625
16959
  * // Track error types using frequency metric
16626
16960
  * const errorTypeFrequency = Metric.frequency("error_types")
16627
16961
  *
16628
- * const program = Effect.fail(new Error("Connection failed")).pipe(
16629
- * Effect.trackErrors(errorTypeFrequency, (error: Error) => error.name)
16962
+ * const program = Effect.fail(new ConnectionFailedError()).pipe(
16963
+ * Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
16630
16964
  * )
16631
16965
  *
16632
16966
  * Effect.runPromiseExit(program).then(() =>
16633
16967
  * Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
16634
- * // Output: { occurrences: Map(1) { "Error" => 1 } }
16968
+ * // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
16635
16969
  * )
16636
16970
  * ```
16637
16971
  *
@@ -16666,18 +17000,20 @@ export declare const trackErrors: {
16666
17000
  *
16667
17001
  * @example
16668
17002
  * ```ts
16669
- * import { Effect, Metric } from "effect"
17003
+ * import { Data, Effect, Metric } from "effect"
17004
+ *
17005
+ * class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
16670
17006
  *
16671
17007
  * // Track error types using frequency metric
16672
17008
  * const errorTypeFrequency = Metric.frequency("error_types")
16673
17009
  *
16674
- * const program = Effect.fail(new Error("Connection failed")).pipe(
16675
- * Effect.trackErrors(errorTypeFrequency, (error: Error) => error.name)
17010
+ * const program = Effect.fail(new ConnectionFailedError()).pipe(
17011
+ * Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
16676
17012
  * )
16677
17013
  *
16678
17014
  * Effect.runPromiseExit(program).then(() =>
16679
17015
  * Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
16680
- * // Output: { occurrences: Map(1) { "Error" => 1 } }
17016
+ * // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
16681
17017
  * )
16682
17018
  * ```
16683
17019
  *
@@ -16712,18 +17048,20 @@ export declare const trackErrors: {
16712
17048
  *
16713
17049
  * @example
16714
17050
  * ```ts
16715
- * import { Effect, Metric } from "effect"
17051
+ * import { Data, Effect, Metric } from "effect"
17052
+ *
17053
+ * class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
16716
17054
  *
16717
17055
  * // Track error types using frequency metric
16718
17056
  * const errorTypeFrequency = Metric.frequency("error_types")
16719
17057
  *
16720
- * const program = Effect.fail(new Error("Connection failed")).pipe(
16721
- * Effect.trackErrors(errorTypeFrequency, (error: Error) => error.name)
17058
+ * const program = Effect.fail(new ConnectionFailedError()).pipe(
17059
+ * Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
16722
17060
  * )
16723
17061
  *
16724
17062
  * Effect.runPromiseExit(program).then(() =>
16725
17063
  * Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
16726
- * // Output: { occurrences: Map(1) { "Error" => 1 } }
17064
+ * // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
16727
17065
  * )
16728
17066
  * ```
16729
17067
  *
@@ -16758,18 +17096,20 @@ export declare const trackErrors: {
16758
17096
  *
16759
17097
  * @example
16760
17098
  * ```ts
16761
- * import { Effect, Metric } from "effect"
17099
+ * import { Data, Effect, Metric } from "effect"
17100
+ *
17101
+ * class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
16762
17102
  *
16763
17103
  * // Track error types using frequency metric
16764
17104
  * const errorTypeFrequency = Metric.frequency("error_types")
16765
17105
  *
16766
- * const program = Effect.fail(new Error("Connection failed")).pipe(
16767
- * Effect.trackErrors(errorTypeFrequency, (error: Error) => error.name)
17106
+ * const program = Effect.fail(new ConnectionFailedError()).pipe(
17107
+ * Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
16768
17108
  * )
16769
17109
  *
16770
17110
  * Effect.runPromiseExit(program).then(() =>
16771
17111
  * Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
16772
- * // Output: { occurrences: Map(1) { "Error" => 1 } }
17112
+ * // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
16773
17113
  * )
16774
17114
  * ```
16775
17115
  *
@@ -17281,118 +17621,63 @@ declare const Transaction_base: ServiceMap.ServiceClass<Transaction, "effect/Eff
17281
17621
  export declare class Transaction extends Transaction_base {
17282
17622
  }
17283
17623
  /**
17284
- * Defines a transaction. Transactions are "all or nothing" with respect to changes made to
17285
- * transactional values (i.e. TxRef) that occur within the transaction body.
17286
- *
17287
- * In Effect transactions are optimistic with retry, that means transactions are retried when:
17288
- *
17289
- * - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
17290
- * accessed transactional values changes.
17291
- *
17292
- * - any of the accessed transactional values change during the execution of the transaction
17293
- * due to a different transaction committing before the current.
17624
+ * Accesses the current transaction state within an active transaction.
17294
17625
  *
17295
- * - parent transaction retry, if you have a transaction within another transaction and
17296
- * the parent retries the child will also retry together with the parent.
17626
+ * This function requires `Transaction` in the context and does NOT create or strip
17627
+ * transaction boundaries. Use it to interact with the transaction journal (e.g. in
17628
+ * `TxRef` internals). To define a transaction boundary, use {@link transaction}.
17297
17629
  *
17298
17630
  * @example
17299
17631
  * ```ts
17300
17632
  * import { Effect, TxRef } from "effect"
17301
17633
  *
17302
17634
  * const program = Effect.gen(function*() {
17303
- * const ref1 = yield* TxRef.make(0)
17304
- * const ref2 = yield* TxRef.make(0)
17305
- *
17306
- * // All operations within atomic block succeed or fail together
17307
- * yield* Effect.atomic(Effect.gen(function*() {
17308
- * yield* TxRef.set(ref1, 10)
17309
- * yield* TxRef.set(ref2, 20)
17310
- * const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
17311
- * console.log(`Transaction sum: ${sum}`)
17312
- * }))
17313
- *
17314
- * console.log(`Final ref1: ${yield* TxRef.get(ref1)}`) // 10
17315
- * console.log(`Final ref2: ${yield* TxRef.get(ref2)}`) // 20
17316
- * })
17317
- * ```
17318
- *
17319
- * @since 4.0.0
17320
- * @category Transactions
17321
- */
17322
- export declare const atomic: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
17323
- /**
17324
- * Executes a function within a transaction context, providing access to the transaction state.
17325
- *
17326
- * @example
17327
- * ```ts
17328
- * import { Effect, TxRef } from "effect"
17329
- *
17330
- * const program = Effect.atomicWith((txState) =>
17331
- * Effect.gen(function*() {
17332
- * const ref = yield* TxRef.make(0)
17333
- *
17334
- * // Access transaction state for debugging
17335
- * console.log(`Journal size: ${txState.journal.size}`)
17336
- * console.log(`Retry flag: ${txState.retry}`)
17635
+ * const ref = yield* Effect.transaction(TxRef.make(0))
17337
17636
  *
17637
+ * yield* Effect.transaction(Effect.gen(function*() {
17338
17638
  * yield* TxRef.set(ref, 42)
17339
17639
  * return yield* TxRef.get(ref)
17340
- * })
17341
- * )
17342
- *
17343
- * Effect.runPromise(program).then(console.log) // 42
17640
+ * }))
17641
+ * })
17344
17642
  * ```
17345
17643
  *
17346
17644
  * @since 4.0.0
17347
17645
  * @category Transactions
17348
17646
  */
17349
- export declare const atomicWith: <A, E, R>(f: (state: Transaction["Service"]) => Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
17647
+ export declare const withTxState: <A, E, R>(f: (state: Transaction["Service"]) => Effect<A, E, R>) => Effect<A, E, R | Transaction>;
17350
17648
  /**
17351
- * Creates an isolated transaction that never composes with parent transactions.
17649
+ * Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
17650
+ * made to transactional values (i.e. TxRef) that occur within the transaction body.
17352
17651
  *
17353
- * **Details**
17652
+ * In Effect transactions are optimistic with retry, that means transactions are retried when:
17354
17653
  *
17355
- * Unlike `Effect.atomic`, which composes with parent transactions when nested,
17356
- * `Effect.transaction` always creates a new isolated transaction boundary.
17357
- * This ensures complete isolation between different transaction scopes.
17654
+ * - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
17655
+ * accessed transactional values changes.
17358
17656
  *
17359
- * **Key Differences from Effect.atomic:**
17360
- * - Always creates a new transaction, even when called within another transaction
17361
- * - Parent transaction failures don't affect isolated transactions
17362
- * - Isolated transaction failures don't affect parent transactions
17363
- * - Each transaction has its own journal and retry logic
17657
+ * - any of the accessed transactional values change during the execution of the transaction
17658
+ * due to a different transaction committing before the current.
17364
17659
  *
17365
- * **When to Use:**
17366
- * - When you need guaranteed isolation between transaction scopes
17367
- * - For implementing independent operations that shouldn't be affected by outer transactions
17368
- * - When building transaction-based systems where isolation is critical
17660
+ * Each call to `transaction` always creates a new isolated transaction boundary with its own
17661
+ * journal and retry logic.
17369
17662
  *
17370
17663
  * @example
17371
17664
  * ```ts
17372
17665
  * import { Effect, TxRef } from "effect"
17373
17666
  *
17374
17667
  * const program = Effect.gen(function*() {
17375
- * const ref1 = yield* TxRef.make(0)
17376
- * const ref2 = yield* TxRef.make(100)
17377
- *
17378
- * // Nested atomic transaction - ref1 will be part of outer transaction
17379
- * yield* Effect.atomic(Effect.gen(function*() {
17380
- * yield* TxRef.set(ref1, 10)
17668
+ * const ref1 = yield* Effect.transaction(TxRef.make(0))
17669
+ * const ref2 = yield* Effect.transaction(TxRef.make(0))
17381
17670
  *
17382
- * // This atomic operation composes with the parent
17383
- * yield* Effect.atomic(Effect.gen(function*() {
17384
- * yield* TxRef.set(ref1, 20) // Part of same transaction
17385
- * }))
17386
- * }))
17387
- *
17388
- * // Isolated transaction - ref2 will be in its own transaction
17671
+ * // All operations within transaction block succeed or fail together
17389
17672
  * yield* Effect.transaction(Effect.gen(function*() {
17390
- * yield* TxRef.set(ref2, 200)
17673
+ * yield* TxRef.set(ref1, 10)
17674
+ * yield* TxRef.set(ref2, 20)
17675
+ * const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
17676
+ * console.log(`Transaction sum: ${sum}`)
17391
17677
  * }))
17392
17678
  *
17393
- * const val1 = yield* TxRef.get(ref1) // 20
17394
- * const val2 = yield* TxRef.get(ref2) // 200
17395
- * return { ref1: val1, ref2: val2 }
17679
+ * console.log(`Final ref1: ${yield* Effect.transaction(TxRef.get(ref1))}`) // 10
17680
+ * console.log(`Final ref2: ${yield* Effect.transaction(TxRef.get(ref2))}`) // 20
17396
17681
  * })
17397
17682
  * ```
17398
17683
  *
@@ -17401,34 +17686,21 @@ export declare const atomicWith: <A, E, R>(f: (state: Transaction["Service"]) =>
17401
17686
  */
17402
17687
  export declare const transaction: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
17403
17688
  /**
17404
- * Executes a function within an isolated transaction context, providing access to the transaction state.
17689
+ * Like {@link transaction} but provides access to the transaction state.
17405
17690
  *
17406
- * This function always creates a new transaction boundary, regardless of whether it's called
17407
- * within another transaction. This ensures complete isolation between transaction scopes.
17691
+ * Always creates a new isolated transaction boundary with its own journal and retry logic.
17408
17692
  *
17409
17693
  * @example
17410
17694
  * ```ts
17411
17695
  * import { Effect, TxRef } from "effect"
17412
17696
  *
17413
- * const program = Effect.transactionWith((txState) =>
17697
+ * const program = Effect.transactionWith((_txState) =>
17414
17698
  * Effect.gen(function*() {
17415
17699
  * const ref = yield* TxRef.make(0)
17416
- *
17417
- * // This transaction is isolated - it has its own journal
17418
- * // txState.journal is independent of any parent transaction
17419
- *
17420
17700
  * yield* TxRef.set(ref, 42)
17421
17701
  * return yield* TxRef.get(ref)
17422
17702
  * })
17423
17703
  * )
17424
- *
17425
- * // Even when nested in another atomic block, this transaction is isolated
17426
- * const nestedProgram = Effect.atomic(
17427
- * Effect.gen(function*() {
17428
- * const result = yield* program // Runs in its own isolated transaction
17429
- * return result
17430
- * })
17431
- * )
17432
17704
  * ```
17433
17705
  *
17434
17706
  * @since 4.0.0
@@ -17450,16 +17722,16 @@ export declare const transactionWith: <A, E, R>(f: (state: Transaction["Service"
17450
17722
  *
17451
17723
  * const program = Effect.gen(function*() {
17452
17724
  * // create a transactional reference
17453
- * const ref = yield* TxRef.make(0)
17725
+ * const ref = yield* Effect.transaction(TxRef.make(0))
17454
17726
  *
17455
17727
  * // forks a fiber that increases the value of `ref` every 100 millis
17456
17728
  * yield* Effect.forkChild(Effect.forever(
17457
17729
  * // update to transactional value
17458
- * TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
17730
+ * Effect.transaction(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
17459
17731
  * ))
17460
17732
  *
17461
17733
  * // the following will retry 10 times until the `ref` value is 10
17462
- * yield* Effect.atomic(Effect.gen(function*() {
17734
+ * yield* Effect.transaction(Effect.gen(function*() {
17463
17735
  * const value = yield* TxRef.get(ref)
17464
17736
  * if (value < 10) {
17465
17737
  * yield* Effect.log(`retry due to value: ${value}`)
@@ -17912,18 +18184,20 @@ export declare const satisfiesSuccessType: <A>() => <A2 extends A, E, R>(effect:
17912
18184
  *
17913
18185
  * @example
17914
18186
  * ```ts
17915
- * import { Effect } from "effect"
18187
+ * import { Data, Effect } from "effect"
18188
+ *
18189
+ * class ValidationError extends Data.TaggedError("ValidationError")<{}> {}
17916
18190
  *
17917
- * // Define a constraint that the error type must be an Error
17918
- * const satisfiesError = Effect.satisfiesErrorType<Error>()
18191
+ * // Define a constraint that the error type must be a ValidationError
18192
+ * const satisfiesError = Effect.satisfiesErrorType<ValidationError>()
17919
18193
  *
17920
- * // This works - Effect<number, TypeError, never> extends Effect<number, Error, never>
17921
- * const validEffect = satisfiesError(Effect.fail(new TypeError("Invalid type")))
18194
+ * // This works - Effect<number, ValidationError, never> extends the constrained type
18195
+ * const validEffect = satisfiesError(Effect.fail(new ValidationError()))
17922
18196
  *
17923
18197
  * // This would cause a TypeScript compilation error:
17924
18198
  * // const invalidEffect = satisfiesError(Effect.fail("string error"))
17925
18199
  * // ^^^^^^^^^^^^^^^^^^^^^^^^^^^
17926
- * // Type 'string' is not assignable to type 'Error'
18200
+ * // Type 'string' is not assignable to type 'ValidationError'
17927
18201
  * ```
17928
18202
  *
17929
18203
  * @since 4.0.0