effect 3.10.18 → 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (448) hide show
  1. package/dist/cjs/Array.js +206 -0
  2. package/dist/cjs/Array.js.map +1 -1
  3. package/dist/cjs/BigDecimal.js +181 -24
  4. package/dist/cjs/BigDecimal.js.map +1 -1
  5. package/dist/cjs/BigInt.js +54 -0
  6. package/dist/cjs/BigInt.js.map +1 -1
  7. package/dist/cjs/Boolean.js +24 -0
  8. package/dist/cjs/Boolean.js.map +1 -1
  9. package/dist/cjs/Brand.js +4 -0
  10. package/dist/cjs/Brand.js.map +1 -1
  11. package/dist/cjs/Channel.js +44 -4
  12. package/dist/cjs/Channel.js.map +1 -1
  13. package/dist/cjs/Chunk.js +8 -0
  14. package/dist/cjs/Chunk.js.map +1 -1
  15. package/dist/cjs/Config.js +10 -1
  16. package/dist/cjs/Config.js.map +1 -1
  17. package/dist/cjs/Context.js +50 -1
  18. package/dist/cjs/Context.js.map +1 -1
  19. package/dist/cjs/Cron.js +81 -67
  20. package/dist/cjs/Cron.js.map +1 -1
  21. package/dist/cjs/Data.js +14 -0
  22. package/dist/cjs/Data.js.map +1 -1
  23. package/dist/cjs/DateTime.js +178 -664
  24. package/dist/cjs/DateTime.js.map +1 -1
  25. package/dist/cjs/Duration.js +2 -0
  26. package/dist/cjs/Duration.js.map +1 -1
  27. package/dist/cjs/Effect.js +296 -4
  28. package/dist/cjs/Effect.js.map +1 -1
  29. package/dist/cjs/Either.js +38 -2
  30. package/dist/cjs/Either.js.map +1 -1
  31. package/dist/cjs/FiberHandle.js +6 -0
  32. package/dist/cjs/FiberHandle.js.map +1 -1
  33. package/dist/cjs/FiberMap.js +6 -0
  34. package/dist/cjs/FiberMap.js.map +1 -1
  35. package/dist/cjs/FiberSet.js +6 -0
  36. package/dist/cjs/FiberSet.js.map +1 -1
  37. package/dist/cjs/Function.js +34 -0
  38. package/dist/cjs/Function.js.map +1 -1
  39. package/dist/cjs/GlobalValue.js +2 -0
  40. package/dist/cjs/GlobalValue.js.map +1 -1
  41. package/dist/cjs/HashMap.js.map +1 -1
  42. package/dist/cjs/Inspectable.js +8 -4
  43. package/dist/cjs/Inspectable.js.map +1 -1
  44. package/dist/cjs/Iterable.js +18 -0
  45. package/dist/cjs/Iterable.js.map +1 -1
  46. package/dist/cjs/JSONSchema.js.map +1 -1
  47. package/dist/cjs/List.js +4 -0
  48. package/dist/cjs/List.js.map +1 -1
  49. package/dist/cjs/Logger.js +26 -0
  50. package/dist/cjs/Logger.js.map +1 -1
  51. package/dist/cjs/Mailbox.js +2 -0
  52. package/dist/cjs/Mailbox.js.map +1 -1
  53. package/dist/cjs/ManagedRuntime.js +2 -0
  54. package/dist/cjs/ManagedRuntime.js.map +1 -1
  55. package/dist/cjs/Metric.js +10 -0
  56. package/dist/cjs/Metric.js.map +1 -1
  57. package/dist/cjs/Micro.js +1104 -1069
  58. package/dist/cjs/Micro.js.map +1 -1
  59. package/dist/cjs/Number.js +44 -0
  60. package/dist/cjs/Number.js.map +1 -1
  61. package/dist/cjs/Option.js +70 -0
  62. package/dist/cjs/Option.js.map +1 -1
  63. package/dist/cjs/Order.js +2 -0
  64. package/dist/cjs/Order.js.map +1 -1
  65. package/dist/cjs/Ordering.js +4 -0
  66. package/dist/cjs/Ordering.js.map +1 -1
  67. package/dist/cjs/Predicate.js +68 -0
  68. package/dist/cjs/Predicate.js.map +1 -1
  69. package/dist/cjs/Random.js +4 -0
  70. package/dist/cjs/Random.js.map +1 -1
  71. package/dist/cjs/RateLimiter.js +4 -0
  72. package/dist/cjs/RateLimiter.js.map +1 -1
  73. package/dist/cjs/RcMap.js +2 -0
  74. package/dist/cjs/RcMap.js.map +1 -1
  75. package/dist/cjs/RcRef.js +2 -0
  76. package/dist/cjs/RcRef.js.map +1 -1
  77. package/dist/cjs/Record.js +56 -0
  78. package/dist/cjs/Record.js.map +1 -1
  79. package/dist/cjs/Redacted.js +8 -0
  80. package/dist/cjs/Redacted.js.map +1 -1
  81. package/dist/cjs/RegExp.js +4 -0
  82. package/dist/cjs/RegExp.js.map +1 -1
  83. package/dist/cjs/Request.js +4 -0
  84. package/dist/cjs/Request.js.map +1 -1
  85. package/dist/cjs/RequestResolver.js +2 -0
  86. package/dist/cjs/RequestResolver.js.map +1 -1
  87. package/dist/cjs/Runtime.js +6 -0
  88. package/dist/cjs/Runtime.js.map +1 -1
  89. package/dist/cjs/STM.js.map +1 -1
  90. package/dist/cjs/Schema.js +91 -8
  91. package/dist/cjs/Schema.js.map +1 -1
  92. package/dist/cjs/Sink.js +9 -1
  93. package/dist/cjs/Sink.js.map +1 -1
  94. package/dist/cjs/Stream.js +179 -7
  95. package/dist/cjs/Stream.js.map +1 -1
  96. package/dist/cjs/String.js +62 -0
  97. package/dist/cjs/String.js.map +1 -1
  98. package/dist/cjs/Struct.js +12 -0
  99. package/dist/cjs/Struct.js.map +1 -1
  100. package/dist/cjs/Symbol.js +2 -0
  101. package/dist/cjs/Symbol.js.map +1 -1
  102. package/dist/cjs/Trie.js +56 -0
  103. package/dist/cjs/Trie.js.map +1 -1
  104. package/dist/cjs/Tuple.js +18 -0
  105. package/dist/cjs/Tuple.js.map +1 -1
  106. package/dist/cjs/Utils.js +7 -1
  107. package/dist/cjs/Utils.js.map +1 -1
  108. package/dist/cjs/internal/channel/channelExecutor.js +5 -9
  109. package/dist/cjs/internal/channel/channelExecutor.js.map +1 -1
  110. package/dist/cjs/internal/channel.js +156 -130
  111. package/dist/cjs/internal/channel.js.map +1 -1
  112. package/dist/cjs/internal/config.js +13 -4
  113. package/dist/cjs/internal/config.js.map +1 -1
  114. package/dist/cjs/internal/context.js +46 -3
  115. package/dist/cjs/internal/context.js.map +1 -1
  116. package/dist/cjs/internal/dateTime.js +747 -0
  117. package/dist/cjs/internal/dateTime.js.map +1 -0
  118. package/dist/cjs/internal/fiberRuntime.js +34 -11
  119. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  120. package/dist/cjs/internal/groupBy.js +9 -3
  121. package/dist/cjs/internal/groupBy.js.map +1 -1
  122. package/dist/cjs/internal/layer.js +1 -1
  123. package/dist/cjs/internal/layer.js.map +1 -1
  124. package/dist/cjs/internal/mailbox.js +1 -1
  125. package/dist/cjs/internal/mailbox.js.map +1 -1
  126. package/dist/cjs/internal/sink.js +25 -21
  127. package/dist/cjs/internal/sink.js.map +1 -1
  128. package/dist/cjs/internal/stream.js +70 -71
  129. package/dist/cjs/internal/stream.js.map +1 -1
  130. package/dist/cjs/internal/version.js +1 -1
  131. package/dist/cjs/internal/version.js.map +1 -1
  132. package/dist/dts/Array.d.ts +534 -0
  133. package/dist/dts/Array.d.ts.map +1 -1
  134. package/dist/dts/BigDecimal.d.ts +172 -1
  135. package/dist/dts/BigDecimal.d.ts.map +1 -1
  136. package/dist/dts/BigInt.d.ts +114 -0
  137. package/dist/dts/BigInt.d.ts.map +1 -1
  138. package/dist/dts/Boolean.d.ts +56 -0
  139. package/dist/dts/Boolean.d.ts.map +1 -1
  140. package/dist/dts/Brand.d.ts +6 -0
  141. package/dist/dts/Brand.d.ts.map +1 -1
  142. package/dist/dts/Channel.d.ts +66 -5
  143. package/dist/dts/Channel.d.ts.map +1 -1
  144. package/dist/dts/Chunk.d.ts +30 -0
  145. package/dist/dts/Chunk.d.ts.map +1 -1
  146. package/dist/dts/Config.d.ts +25 -1
  147. package/dist/dts/Config.d.ts.map +1 -1
  148. package/dist/dts/Context.d.ts +155 -0
  149. package/dist/dts/Context.d.ts.map +1 -1
  150. package/dist/dts/Cron.d.ts +21 -6
  151. package/dist/dts/Cron.d.ts.map +1 -1
  152. package/dist/dts/Data.d.ts +26 -0
  153. package/dist/dts/Data.d.ts.map +1 -1
  154. package/dist/dts/DateTime.d.ts +192 -49
  155. package/dist/dts/DateTime.d.ts.map +1 -1
  156. package/dist/dts/Duration.d.ts +2 -0
  157. package/dist/dts/Duration.d.ts.map +1 -1
  158. package/dist/dts/Effect.d.ts +658 -1
  159. package/dist/dts/Effect.d.ts.map +1 -1
  160. package/dist/dts/Either.d.ts +84 -2
  161. package/dist/dts/Either.d.ts.map +1 -1
  162. package/dist/dts/FiberHandle.d.ts +6 -0
  163. package/dist/dts/FiberHandle.d.ts.map +1 -1
  164. package/dist/dts/FiberMap.d.ts +6 -0
  165. package/dist/dts/FiberMap.d.ts.map +1 -1
  166. package/dist/dts/FiberSet.d.ts +6 -0
  167. package/dist/dts/FiberSet.d.ts.map +1 -1
  168. package/dist/dts/Function.d.ts +50 -0
  169. package/dist/dts/Function.d.ts.map +1 -1
  170. package/dist/dts/GlobalValue.d.ts +2 -0
  171. package/dist/dts/GlobalValue.d.ts.map +1 -1
  172. package/dist/dts/HashMap.d.ts +6 -0
  173. package/dist/dts/HashMap.d.ts.map +1 -1
  174. package/dist/dts/Inspectable.d.ts.map +1 -1
  175. package/dist/dts/Iterable.d.ts +26 -0
  176. package/dist/dts/Iterable.d.ts.map +1 -1
  177. package/dist/dts/JSONSchema.d.ts +1 -0
  178. package/dist/dts/JSONSchema.d.ts.map +1 -1
  179. package/dist/dts/List.d.ts +20 -0
  180. package/dist/dts/List.d.ts.map +1 -1
  181. package/dist/dts/Logger.d.ts +34 -0
  182. package/dist/dts/Logger.d.ts.map +1 -1
  183. package/dist/dts/Mailbox.d.ts +2 -0
  184. package/dist/dts/Mailbox.d.ts.map +1 -1
  185. package/dist/dts/ManagedRuntime.d.ts +2 -0
  186. package/dist/dts/ManagedRuntime.d.ts.map +1 -1
  187. package/dist/dts/Metric.d.ts +18 -0
  188. package/dist/dts/Metric.d.ts.map +1 -1
  189. package/dist/dts/Micro.d.ts +880 -863
  190. package/dist/dts/Micro.d.ts.map +1 -1
  191. package/dist/dts/Number.d.ts +104 -0
  192. package/dist/dts/Number.d.ts.map +1 -1
  193. package/dist/dts/Option.d.ts +142 -0
  194. package/dist/dts/Option.d.ts.map +1 -1
  195. package/dist/dts/Order.d.ts +2 -0
  196. package/dist/dts/Order.d.ts.map +1 -1
  197. package/dist/dts/Ordering.d.ts +8 -0
  198. package/dist/dts/Ordering.d.ts.map +1 -1
  199. package/dist/dts/Predicate.d.ts +104 -0
  200. package/dist/dts/Predicate.d.ts.map +1 -1
  201. package/dist/dts/Random.d.ts +4 -0
  202. package/dist/dts/Random.d.ts.map +1 -1
  203. package/dist/dts/RateLimiter.d.ts +4 -0
  204. package/dist/dts/RateLimiter.d.ts.map +1 -1
  205. package/dist/dts/RcMap.d.ts +6 -0
  206. package/dist/dts/RcMap.d.ts.map +1 -1
  207. package/dist/dts/RcRef.d.ts +2 -0
  208. package/dist/dts/RcRef.d.ts.map +1 -1
  209. package/dist/dts/Record.d.ts +136 -0
  210. package/dist/dts/Record.d.ts.map +1 -1
  211. package/dist/dts/Redacted.d.ts +8 -0
  212. package/dist/dts/Redacted.d.ts.map +1 -1
  213. package/dist/dts/RegExp.d.ts +4 -0
  214. package/dist/dts/RegExp.d.ts.map +1 -1
  215. package/dist/dts/Request.d.ts +4 -0
  216. package/dist/dts/Request.d.ts.map +1 -1
  217. package/dist/dts/RequestResolver.d.ts +6 -0
  218. package/dist/dts/RequestResolver.d.ts.map +1 -1
  219. package/dist/dts/Runtime.d.ts +18 -0
  220. package/dist/dts/Runtime.d.ts.map +1 -1
  221. package/dist/dts/STM.d.ts +2 -0
  222. package/dist/dts/STM.d.ts.map +1 -1
  223. package/dist/dts/Schema.d.ts +90 -0
  224. package/dist/dts/Schema.d.ts.map +1 -1
  225. package/dist/dts/Sink.d.ts +8 -0
  226. package/dist/dts/Sink.d.ts.map +1 -1
  227. package/dist/dts/Stream.d.ts +394 -32
  228. package/dist/dts/Stream.d.ts.map +1 -1
  229. package/dist/dts/String.d.ts +94 -0
  230. package/dist/dts/String.d.ts.map +1 -1
  231. package/dist/dts/Struct.d.ts +24 -0
  232. package/dist/dts/Struct.d.ts.map +1 -1
  233. package/dist/dts/Symbol.d.ts +2 -0
  234. package/dist/dts/Symbol.d.ts.map +1 -1
  235. package/dist/dts/Trie.d.ts +132 -0
  236. package/dist/dts/Trie.d.ts.map +1 -1
  237. package/dist/dts/Tuple.d.ts +42 -0
  238. package/dist/dts/Tuple.d.ts.map +1 -1
  239. package/dist/dts/Types.d.ts +24 -0
  240. package/dist/dts/Types.d.ts.map +1 -1
  241. package/dist/dts/Utils.d.ts +4 -0
  242. package/dist/dts/Utils.d.ts.map +1 -1
  243. package/dist/dts/internal/context.d.ts +1 -1
  244. package/dist/dts/internal/context.d.ts.map +1 -1
  245. package/dist/dts/internal/dateTime.d.ts +2 -0
  246. package/dist/dts/internal/dateTime.d.ts.map +1 -0
  247. package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
  248. package/dist/dts/internal/stream.d.ts.map +1 -1
  249. package/dist/esm/Array.js +208 -0
  250. package/dist/esm/Array.js.map +1 -1
  251. package/dist/esm/BigDecimal.js +175 -20
  252. package/dist/esm/BigDecimal.js.map +1 -1
  253. package/dist/esm/BigInt.js +54 -0
  254. package/dist/esm/BigInt.js.map +1 -1
  255. package/dist/esm/Boolean.js +24 -0
  256. package/dist/esm/Boolean.js.map +1 -1
  257. package/dist/esm/Brand.js +4 -0
  258. package/dist/esm/Brand.js.map +1 -1
  259. package/dist/esm/Channel.js +42 -2
  260. package/dist/esm/Channel.js.map +1 -1
  261. package/dist/esm/Chunk.js +8 -0
  262. package/dist/esm/Chunk.js.map +1 -1
  263. package/dist/esm/Config.js +9 -0
  264. package/dist/esm/Config.js.map +1 -1
  265. package/dist/esm/Context.js +49 -0
  266. package/dist/esm/Context.js.map +1 -1
  267. package/dist/esm/Cron.js +81 -67
  268. package/dist/esm/Cron.js.map +1 -1
  269. package/dist/esm/Data.js +16 -0
  270. package/dist/esm/Data.js.map +1 -1
  271. package/dist/esm/DateTime.js +176 -627
  272. package/dist/esm/DateTime.js.map +1 -1
  273. package/dist/esm/Duration.js +2 -0
  274. package/dist/esm/Duration.js.map +1 -1
  275. package/dist/esm/Effect.js +297 -0
  276. package/dist/esm/Effect.js.map +1 -1
  277. package/dist/esm/Either.js +40 -2
  278. package/dist/esm/Either.js.map +1 -1
  279. package/dist/esm/FiberHandle.js +6 -0
  280. package/dist/esm/FiberHandle.js.map +1 -1
  281. package/dist/esm/FiberMap.js +6 -0
  282. package/dist/esm/FiberMap.js.map +1 -1
  283. package/dist/esm/FiberSet.js +6 -0
  284. package/dist/esm/FiberSet.js.map +1 -1
  285. package/dist/esm/Function.js +34 -0
  286. package/dist/esm/Function.js.map +1 -1
  287. package/dist/esm/GlobalValue.js +2 -0
  288. package/dist/esm/GlobalValue.js.map +1 -1
  289. package/dist/esm/HashMap.js.map +1 -1
  290. package/dist/esm/Inspectable.js +8 -4
  291. package/dist/esm/Inspectable.js.map +1 -1
  292. package/dist/esm/Iterable.js +18 -0
  293. package/dist/esm/Iterable.js.map +1 -1
  294. package/dist/esm/JSONSchema.js.map +1 -1
  295. package/dist/esm/List.js +4 -0
  296. package/dist/esm/List.js.map +1 -1
  297. package/dist/esm/Logger.js +26 -0
  298. package/dist/esm/Logger.js.map +1 -1
  299. package/dist/esm/Mailbox.js +2 -0
  300. package/dist/esm/Mailbox.js.map +1 -1
  301. package/dist/esm/ManagedRuntime.js +2 -0
  302. package/dist/esm/ManagedRuntime.js.map +1 -1
  303. package/dist/esm/Metric.js +10 -0
  304. package/dist/esm/Metric.js.map +1 -1
  305. package/dist/esm/Micro.js +1077 -1037
  306. package/dist/esm/Micro.js.map +1 -1
  307. package/dist/esm/Number.js +44 -0
  308. package/dist/esm/Number.js.map +1 -1
  309. package/dist/esm/Option.js +72 -0
  310. package/dist/esm/Option.js.map +1 -1
  311. package/dist/esm/Order.js +2 -0
  312. package/dist/esm/Order.js.map +1 -1
  313. package/dist/esm/Ordering.js +4 -0
  314. package/dist/esm/Ordering.js.map +1 -1
  315. package/dist/esm/Predicate.js +68 -0
  316. package/dist/esm/Predicate.js.map +1 -1
  317. package/dist/esm/Random.js +4 -0
  318. package/dist/esm/Random.js.map +1 -1
  319. package/dist/esm/RateLimiter.js +4 -0
  320. package/dist/esm/RateLimiter.js.map +1 -1
  321. package/dist/esm/RcMap.js +2 -0
  322. package/dist/esm/RcMap.js.map +1 -1
  323. package/dist/esm/RcRef.js +2 -0
  324. package/dist/esm/RcRef.js.map +1 -1
  325. package/dist/esm/Record.js +56 -0
  326. package/dist/esm/Record.js.map +1 -1
  327. package/dist/esm/Redacted.js +8 -0
  328. package/dist/esm/Redacted.js.map +1 -1
  329. package/dist/esm/RegExp.js +4 -0
  330. package/dist/esm/RegExp.js.map +1 -1
  331. package/dist/esm/Request.js +4 -0
  332. package/dist/esm/Request.js.map +1 -1
  333. package/dist/esm/RequestResolver.js +2 -0
  334. package/dist/esm/RequestResolver.js.map +1 -1
  335. package/dist/esm/Runtime.js +6 -0
  336. package/dist/esm/Runtime.js.map +1 -1
  337. package/dist/esm/STM.js.map +1 -1
  338. package/dist/esm/Schema.js +88 -0
  339. package/dist/esm/Schema.js.map +1 -1
  340. package/dist/esm/Sink.js +8 -0
  341. package/dist/esm/Sink.js.map +1 -1
  342. package/dist/esm/Stream.js +183 -5
  343. package/dist/esm/Stream.js.map +1 -1
  344. package/dist/esm/String.js +62 -0
  345. package/dist/esm/String.js.map +1 -1
  346. package/dist/esm/Struct.js +12 -0
  347. package/dist/esm/Struct.js.map +1 -1
  348. package/dist/esm/Symbol.js +2 -0
  349. package/dist/esm/Symbol.js.map +1 -1
  350. package/dist/esm/Trie.js +56 -0
  351. package/dist/esm/Trie.js.map +1 -1
  352. package/dist/esm/Tuple.js +22 -0
  353. package/dist/esm/Tuple.js.map +1 -1
  354. package/dist/esm/Utils.js +5 -0
  355. package/dist/esm/Utils.js.map +1 -1
  356. package/dist/esm/internal/channel/channelExecutor.js +5 -7
  357. package/dist/esm/internal/channel/channelExecutor.js.map +1 -1
  358. package/dist/esm/internal/channel.js +152 -129
  359. package/dist/esm/internal/channel.js.map +1 -1
  360. package/dist/esm/internal/config.js +11 -3
  361. package/dist/esm/internal/config.js.map +1 -1
  362. package/dist/esm/internal/context.js +42 -2
  363. package/dist/esm/internal/context.js.map +1 -1
  364. package/dist/esm/internal/dateTime.js +704 -0
  365. package/dist/esm/internal/dateTime.js.map +1 -0
  366. package/dist/esm/internal/fiberRuntime.js +31 -9
  367. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  368. package/dist/esm/internal/groupBy.js +9 -3
  369. package/dist/esm/internal/groupBy.js.map +1 -1
  370. package/dist/esm/internal/layer.js +1 -1
  371. package/dist/esm/internal/layer.js.map +1 -1
  372. package/dist/esm/internal/mailbox.js +1 -1
  373. package/dist/esm/internal/mailbox.js.map +1 -1
  374. package/dist/esm/internal/sink.js +23 -20
  375. package/dist/esm/internal/sink.js.map +1 -1
  376. package/dist/esm/internal/stream.js +66 -69
  377. package/dist/esm/internal/stream.js.map +1 -1
  378. package/dist/esm/internal/version.js +1 -1
  379. package/dist/esm/internal/version.js.map +1 -1
  380. package/package.json +1 -1
  381. package/src/Array.ts +534 -0
  382. package/src/BigDecimal.ts +247 -21
  383. package/src/BigInt.ts +114 -0
  384. package/src/Boolean.ts +56 -0
  385. package/src/Brand.ts +6 -0
  386. package/src/Channel.ts +81 -5
  387. package/src/Chunk.ts +32 -0
  388. package/src/Config.ts +26 -1
  389. package/src/Context.ts +163 -0
  390. package/src/Cron.ts +91 -68
  391. package/src/Data.ts +26 -0
  392. package/src/DateTime.ts +307 -757
  393. package/src/Duration.ts +2 -0
  394. package/src/Effect.ts +910 -1
  395. package/src/Either.ts +84 -2
  396. package/src/FiberHandle.ts +6 -0
  397. package/src/FiberMap.ts +6 -0
  398. package/src/FiberSet.ts +6 -0
  399. package/src/Function.ts +50 -0
  400. package/src/GlobalValue.ts +2 -0
  401. package/src/HashMap.ts +6 -0
  402. package/src/Inspectable.ts +11 -7
  403. package/src/Iterable.ts +26 -0
  404. package/src/JSONSchema.ts +1 -0
  405. package/src/List.ts +24 -0
  406. package/src/Logger.ts +34 -0
  407. package/src/Mailbox.ts +2 -0
  408. package/src/ManagedRuntime.ts +2 -0
  409. package/src/Metric.ts +18 -0
  410. package/src/Micro.ts +2007 -1745
  411. package/src/Number.ts +104 -0
  412. package/src/Option.ts +142 -0
  413. package/src/Order.ts +2 -0
  414. package/src/Ordering.ts +8 -0
  415. package/src/Predicate.ts +104 -0
  416. package/src/Random.ts +4 -0
  417. package/src/RateLimiter.ts +4 -0
  418. package/src/RcMap.ts +6 -0
  419. package/src/RcRef.ts +2 -0
  420. package/src/Record.ts +136 -0
  421. package/src/Redacted.ts +8 -0
  422. package/src/RegExp.ts +4 -0
  423. package/src/Request.ts +4 -0
  424. package/src/RequestResolver.ts +6 -0
  425. package/src/Runtime.ts +18 -0
  426. package/src/STM.ts +2 -0
  427. package/src/Schema.ts +124 -0
  428. package/src/Sink.ts +11 -0
  429. package/src/Stream.ts +399 -44
  430. package/src/String.ts +94 -0
  431. package/src/Struct.ts +24 -0
  432. package/src/Symbol.ts +2 -0
  433. package/src/Trie.ts +132 -0
  434. package/src/Tuple.ts +42 -0
  435. package/src/Types.ts +24 -0
  436. package/src/Utils.ts +8 -0
  437. package/src/internal/channel/channelExecutor.ts +37 -33
  438. package/src/internal/channel.ts +504 -467
  439. package/src/internal/config.ts +18 -6
  440. package/src/internal/context.ts +56 -4
  441. package/src/internal/dateTime.ts +1126 -0
  442. package/src/internal/fiberRuntime.ts +35 -16
  443. package/src/internal/groupBy.ts +13 -22
  444. package/src/internal/layer.ts +5 -8
  445. package/src/internal/mailbox.ts +6 -4
  446. package/src/internal/sink.ts +55 -35
  447. package/src/internal/stream.ts +299 -299
  448. package/src/internal/version.ts +1 -1
package/src/Effect.ts CHANGED
@@ -25,6 +25,7 @@ import { dual } from "./Function.js"
25
25
  import type * as HashMap from "./HashMap.js"
26
26
  import type * as HashSet from "./HashSet.js"
27
27
  import type { TypeLambda } from "./HKT.js"
28
+ import * as internalCause from "./internal/cause.js"
28
29
  import * as _console from "./internal/console.js"
29
30
  import { TagProto } from "./internal/context.js"
30
31
  import * as effect from "./internal/core-effect.js"
@@ -59,7 +60,7 @@ import type * as Supervisor from "./Supervisor.js"
59
60
  import type * as Tracer from "./Tracer.js"
60
61
  import type { Concurrency, Contravariant, Covariant, NoExcessProperties, NoInfer, NotFunction } from "./Types.js"
61
62
  import type * as Unify from "./Unify.js"
62
- import type { YieldWrap } from "./Utils.js"
63
+ import { internalCall, isGeneratorFunction, type YieldWrap } from "./Utils.js"
63
64
 
64
65
  /**
65
66
  * @since 2.0.0
@@ -151,6 +152,9 @@ declare module "./Context.js" {
151
152
  interface Tag<Id, Value> extends Effect<Value, never, Id> {
152
153
  [Symbol.iterator](): EffectGenerator<Tag<Id, Value>>
153
154
  }
155
+ interface Reference<Id, Value> extends Effect<Value> {
156
+ [Symbol.iterator](): EffectGenerator<Reference<Id, Value>>
157
+ }
154
158
  interface TagUnifyIgnore {
155
159
  Effect?: true
156
160
  Either?: true
@@ -256,6 +260,7 @@ export const isEffect: (u: unknown) => u is Effect<unknown, unknown, unknown> =
256
260
  * be recomputed upon next evaluation.
257
261
  *
258
262
  * @example
263
+ * ```ts
259
264
  * import { Effect, Console } from "effect"
260
265
  *
261
266
  * let i = 1
@@ -283,6 +288,7 @@ export const isEffect: (u: unknown) => u is Effect<unknown, unknown, unknown> =
283
288
  * // result 1
284
289
  * // expensive task...
285
290
  * // result 2
291
+ * ```
286
292
  *
287
293
  * @since 2.0.0
288
294
  * @category Caching
@@ -294,6 +300,7 @@ export const cachedWithTTL: {
294
300
  * be recomputed upon next evaluation.
295
301
  *
296
302
  * @example
303
+ * ```ts
297
304
  * import { Effect, Console } from "effect"
298
305
  *
299
306
  * let i = 1
@@ -321,6 +328,7 @@ export const cachedWithTTL: {
321
328
  * // result 1
322
329
  * // expensive task...
323
330
  * // result 2
331
+ * ```
324
332
  *
325
333
  * @since 2.0.0
326
334
  * @category Caching
@@ -332,6 +340,7 @@ export const cachedWithTTL: {
332
340
  * be recomputed upon next evaluation.
333
341
  *
334
342
  * @example
343
+ * ```ts
335
344
  * import { Effect, Console } from "effect"
336
345
  *
337
346
  * let i = 1
@@ -359,6 +368,7 @@ export const cachedWithTTL: {
359
368
  * // result 1
360
369
  * // expensive task...
361
370
  * // result 2
371
+ * ```
362
372
  *
363
373
  * @since 2.0.0
364
374
  * @category Caching
@@ -372,6 +382,7 @@ export const cachedWithTTL: {
372
382
  * invalidating the cached value before it naturally expires.
373
383
  *
374
384
  * @example
385
+ * ```ts
375
386
  * import { Effect, Console } from "effect"
376
387
  *
377
388
  * let i = 1
@@ -402,6 +413,7 @@ export const cachedWithTTL: {
402
413
  * // result 1
403
414
  * // expensive task...
404
415
  * // result 2
416
+ * ```
405
417
  *
406
418
  * @since 2.0.0
407
419
  * @category Caching
@@ -413,6 +425,7 @@ export const cachedInvalidateWithTTL: {
413
425
  * invalidating the cached value before it naturally expires.
414
426
  *
415
427
  * @example
428
+ * ```ts
416
429
  * import { Effect, Console } from "effect"
417
430
  *
418
431
  * let i = 1
@@ -443,6 +456,7 @@ export const cachedInvalidateWithTTL: {
443
456
  * // result 1
444
457
  * // expensive task...
445
458
  * // result 2
459
+ * ```
446
460
  *
447
461
  * @since 2.0.0
448
462
  * @category Caching
@@ -456,6 +470,7 @@ export const cachedInvalidateWithTTL: {
456
470
  * invalidating the cached value before it naturally expires.
457
471
  *
458
472
  * @example
473
+ * ```ts
459
474
  * import { Effect, Console } from "effect"
460
475
  *
461
476
  * let i = 1
@@ -486,6 +501,7 @@ export const cachedInvalidateWithTTL: {
486
501
  * // result 1
487
502
  * // expensive task...
488
503
  * // result 2
504
+ * ```
489
505
  *
490
506
  * @since 2.0.0
491
507
  * @category Caching
@@ -499,6 +515,7 @@ export const cachedInvalidateWithTTL: {
499
515
  * the logic.
500
516
  *
501
517
  * @example
518
+ * ```ts
502
519
  * import { Effect, Console } from "effect"
503
520
  *
504
521
  * let i = 1
@@ -532,6 +549,7 @@ export const cachedInvalidateWithTTL: {
532
549
  * // expensive task...
533
550
  * // result 3
534
551
  * // result 3
552
+ * ```
535
553
  *
536
554
  * @since 2.0.0
537
555
  * @category Caching
@@ -544,6 +562,7 @@ export const cached: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
544
562
  * recompute them.
545
563
  *
546
564
  * @example
565
+ * ```ts
547
566
  * import { Effect, Random } from "effect"
548
567
  *
549
568
  * const program = Effect.gen(function* () {
@@ -566,6 +585,7 @@ export const cached: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>
566
585
  * // memoized version:
567
586
  * // 5
568
587
  * // 5
588
+ * ```
569
589
  *
570
590
  * @since 2.0.0
571
591
  * @category Caching
@@ -580,6 +600,7 @@ export const cachedFunction: <A, B, E, R>(
580
600
  * called.
581
601
  *
582
602
  * @example
603
+ * ```ts
583
604
  * import { Effect, Console } from "effect"
584
605
  *
585
606
  * const program = Effect.gen(function* () {
@@ -595,6 +616,7 @@ export const cachedFunction: <A, B, E, R>(
595
616
  * // task1
596
617
  * // task1
597
618
  * // task2
619
+ * ```
598
620
  *
599
621
  * @since 2.0.0
600
622
  * @category Caching
@@ -651,6 +673,7 @@ export const once: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<void, E, R>
651
673
  * @see {@link forEach} for iterating over elements and applying an effect.
652
674
  *
653
675
  * @example
676
+ * ```ts
654
677
  * // Title: Combining Effects in Tuples
655
678
  * import { Effect, Console } from "effect"
656
679
  *
@@ -668,6 +691,7 @@ export const once: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<void, E, R>
668
691
  * // 42
669
692
  * // Hello
670
693
  * // [ 42, 'Hello' ]
694
+ * ```
671
695
  *
672
696
  * @example
673
697
  * // Title: Combining Effects in Iterables
@@ -826,6 +850,7 @@ export const all: <
826
850
  * your data and then apply operations to it.
827
851
  *
828
852
  * @example
853
+ * ```ts
829
854
  * import { Effect, pipe } from "effect"
830
855
  *
831
856
  * const task1 = Effect.succeed(1).pipe(
@@ -849,6 +874,7 @@ export const all: <
849
874
  * // timestamp=... level=INFO fiber=#3 message="task2 done"
850
875
  * // timestamp=... level=INFO fiber=#2 message="task1 done"
851
876
  * // [ 1, 'hello' ]
877
+ * ```
852
878
  *
853
879
  * @since 2.0.0
854
880
  * @category Collecting
@@ -1163,6 +1189,7 @@ export const filter: {
1163
1189
  * @see {@link filter} for concurrent filtering without mapping.
1164
1190
  *
1165
1191
  * @example
1192
+ * ```ts
1166
1193
  * import { Console, Effect, Option } from "effect"
1167
1194
  *
1168
1195
  * const task = (n: number) =>
@@ -1183,6 +1210,7 @@ export const filter: {
1183
1210
  * // task3 done
1184
1211
  * // task4 done
1185
1212
  * // [ 2, 4 ]
1213
+ * ```
1186
1214
  *
1187
1215
  * @since 2.0.0
1188
1216
  * @category Filtering
@@ -1199,6 +1227,7 @@ export const filterMap: {
1199
1227
  * @see {@link filter} for concurrent filtering without mapping.
1200
1228
  *
1201
1229
  * @example
1230
+ * ```ts
1202
1231
  * import { Console, Effect, Option } from "effect"
1203
1232
  *
1204
1233
  * const task = (n: number) =>
@@ -1219,6 +1248,7 @@ export const filterMap: {
1219
1248
  * // task3 done
1220
1249
  * // task4 done
1221
1250
  * // [ 2, 4 ]
1251
+ * ```
1222
1252
  *
1223
1253
  * @since 2.0.0
1224
1254
  * @category Filtering
@@ -1237,6 +1267,7 @@ export const filterMap: {
1237
1267
  * @see {@link filter} for concurrent filtering without mapping.
1238
1268
  *
1239
1269
  * @example
1270
+ * ```ts
1240
1271
  * import { Console, Effect, Option } from "effect"
1241
1272
  *
1242
1273
  * const task = (n: number) =>
@@ -1257,6 +1288,7 @@ export const filterMap: {
1257
1288
  * // task3 done
1258
1289
  * // task4 done
1259
1290
  * // [ 2, 4 ]
1291
+ * ```
1260
1292
  *
1261
1293
  * @since 2.0.0
1262
1294
  * @category Filtering
@@ -1319,6 +1351,7 @@ export const findFirst: {
1319
1351
  * @see {@link all} for combining multiple effects into one.
1320
1352
  *
1321
1353
  * @example
1354
+ * ```ts
1322
1355
  * // Title: Applying Effects to Iterable Elements
1323
1356
  * import { Effect, Console } from "effect"
1324
1357
  *
@@ -1334,6 +1367,7 @@ export const findFirst: {
1334
1367
  * // Currently at index 3
1335
1368
  * // Currently at index 4
1336
1369
  * // [ 2, 4, 6, 8, 10 ]
1370
+ * ```
1337
1371
  *
1338
1372
  * @example
1339
1373
  * // Title: Using discard to Ignore Results
@@ -1384,6 +1418,7 @@ export const forEach: {
1384
1418
  * @see {@link all} for combining multiple effects into one.
1385
1419
  *
1386
1420
  * @example
1421
+ * ```ts
1387
1422
  * // Title: Applying Effects to Iterable Elements
1388
1423
  * import { Effect, Console } from "effect"
1389
1424
  *
@@ -1399,6 +1434,7 @@ export const forEach: {
1399
1434
  * // Currently at index 3
1400
1435
  * // Currently at index 4
1401
1436
  * // [ 2, 4, 6, 8, 10 ]
1437
+ * ```
1402
1438
  *
1403
1439
  * @example
1404
1440
  * // Title: Using discard to Ignore Results
@@ -1459,6 +1495,7 @@ export const forEach: {
1459
1495
  * @see {@link all} for combining multiple effects into one.
1460
1496
  *
1461
1497
  * @example
1498
+ * ```ts
1462
1499
  * // Title: Applying Effects to Iterable Elements
1463
1500
  * import { Effect, Console } from "effect"
1464
1501
  *
@@ -1474,6 +1511,7 @@ export const forEach: {
1474
1511
  * // Currently at index 3
1475
1512
  * // Currently at index 4
1476
1513
  * // [ 2, 4, 6, 8, 10 ]
1514
+ * ```
1477
1515
  *
1478
1516
  * @example
1479
1517
  * // Title: Using discard to Ignore Results
@@ -1532,6 +1570,7 @@ export const forEach: {
1532
1570
  * @see {@link all} for combining multiple effects into one.
1533
1571
  *
1534
1572
  * @example
1573
+ * ```ts
1535
1574
  * // Title: Applying Effects to Iterable Elements
1536
1575
  * import { Effect, Console } from "effect"
1537
1576
  *
@@ -1547,6 +1586,7 @@ export const forEach: {
1547
1586
  * // Currently at index 3
1548
1587
  * // Currently at index 4
1549
1588
  * // [ 2, 4, 6, 8, 10 ]
1589
+ * ```
1550
1590
  *
1551
1591
  * @example
1552
1592
  * // Title: Using discard to Ignore Results
@@ -1606,6 +1646,7 @@ export const forEach: {
1606
1646
  * @see {@link all} for combining multiple effects into one.
1607
1647
  *
1608
1648
  * @example
1649
+ * ```ts
1609
1650
  * // Title: Applying Effects to Iterable Elements
1610
1651
  * import { Effect, Console } from "effect"
1611
1652
  *
@@ -1621,6 +1662,7 @@ export const forEach: {
1621
1662
  * // Currently at index 3
1622
1663
  * // Currently at index 4
1623
1664
  * // [ 2, 4, 6, 8, 10 ]
1665
+ * ```
1624
1666
  *
1625
1667
  * @example
1626
1668
  * // Title: Using discard to Ignore Results
@@ -1731,6 +1773,7 @@ export const mergeAll: {
1731
1773
  * @see {@link validateFirst} for a function that stops at the first success.
1732
1774
  *
1733
1775
  * @example
1776
+ * ```ts
1734
1777
  * import { Effect } from "effect"
1735
1778
  *
1736
1779
  * // ┌─── Effect<[string[], number[]], never, never>
@@ -1746,6 +1789,7 @@ export const mergeAll: {
1746
1789
  * Effect.runPromise(program).then(console.log, console.error)
1747
1790
  * // Output:
1748
1791
  * // [ [ '1 is not even', '3 is not even' ], [ 0, 2, 4 ] ]
1792
+ * ```
1749
1793
  *
1750
1794
  * @since 2.0.0
1751
1795
  * @category Error Accumulation
@@ -1767,6 +1811,7 @@ export const partition: {
1767
1811
  * @see {@link validateFirst} for a function that stops at the first success.
1768
1812
  *
1769
1813
  * @example
1814
+ * ```ts
1770
1815
  * import { Effect } from "effect"
1771
1816
  *
1772
1817
  * // ┌─── Effect<[string[], number[]], never, never>
@@ -1782,6 +1827,7 @@ export const partition: {
1782
1827
  * Effect.runPromise(program).then(console.log, console.error)
1783
1828
  * // Output:
1784
1829
  * // [ [ '1 is not even', '3 is not even' ], [ 0, 2, 4 ] ]
1830
+ * ```
1785
1831
  *
1786
1832
  * @since 2.0.0
1787
1833
  * @category Error Accumulation
@@ -1812,6 +1858,7 @@ export const partition: {
1812
1858
  * @see {@link validateFirst} for a function that stops at the first success.
1813
1859
  *
1814
1860
  * @example
1861
+ * ```ts
1815
1862
  * import { Effect } from "effect"
1816
1863
  *
1817
1864
  * // ┌─── Effect<[string[], number[]], never, never>
@@ -1827,6 +1874,7 @@ export const partition: {
1827
1874
  * Effect.runPromise(program).then(console.log, console.error)
1828
1875
  * // Output:
1829
1876
  * // [ [ '1 is not even', '3 is not even' ], [ 0, 2, 4 ] ]
1877
+ * ```
1830
1878
  *
1831
1879
  * @since 2.0.0
1832
1880
  * @category Error Accumulation
@@ -2147,6 +2195,7 @@ export const takeWhile: {
2147
2195
  * @see {@link partition} when you need to separate successes and failures instead of losing successes with errors.
2148
2196
  *
2149
2197
  * @example
2198
+ * ```ts
2150
2199
  * import { Effect, Console } from "effect"
2151
2200
  *
2152
2201
  * // ┌─── Effect<number[], string[], never>
@@ -2173,6 +2222,7 @@ export const takeWhile: {
2173
2222
  * // failure: [ '4 is not less that 4', '5 is not less that 4' ]
2174
2223
  * // }
2175
2224
  * // }
2225
+ * ```
2176
2226
  *
2177
2227
  * @since 2.0.0
2178
2228
  * @category Error Accumulation
@@ -2195,6 +2245,7 @@ export const validateAll: {
2195
2245
  * @see {@link partition} when you need to separate successes and failures instead of losing successes with errors.
2196
2246
  *
2197
2247
  * @example
2248
+ * ```ts
2198
2249
  * import { Effect, Console } from "effect"
2199
2250
  *
2200
2251
  * // ┌─── Effect<number[], string[], never>
@@ -2221,6 +2272,7 @@ export const validateAll: {
2221
2272
  * // failure: [ '4 is not less that 4', '5 is not less that 4' ]
2222
2273
  * // }
2223
2274
  * // }
2275
+ * ```
2224
2276
  *
2225
2277
  * @since 2.0.0
2226
2278
  * @category Error Accumulation
@@ -2251,6 +2303,7 @@ export const validateAll: {
2251
2303
  * @see {@link partition} when you need to separate successes and failures instead of losing successes with errors.
2252
2304
  *
2253
2305
  * @example
2306
+ * ```ts
2254
2307
  * import { Effect, Console } from "effect"
2255
2308
  *
2256
2309
  * // ┌─── Effect<number[], string[], never>
@@ -2277,6 +2330,7 @@ export const validateAll: {
2277
2330
  * // failure: [ '4 is not less that 4', '5 is not less that 4' ]
2278
2331
  * // }
2279
2332
  * // }
2333
+ * ```
2280
2334
  *
2281
2335
  * @since 2.0.0
2282
2336
  * @category Error Accumulation
@@ -2307,6 +2361,7 @@ export const validateAll: {
2307
2361
  * @see {@link partition} when you need to separate successes and failures instead of losing successes with errors.
2308
2362
  *
2309
2363
  * @example
2364
+ * ```ts
2310
2365
  * import { Effect, Console } from "effect"
2311
2366
  *
2312
2367
  * // ┌─── Effect<number[], string[], never>
@@ -2333,6 +2388,7 @@ export const validateAll: {
2333
2388
  * // failure: [ '4 is not less that 4', '5 is not less that 4' ]
2334
2389
  * // }
2335
2390
  * // }
2391
+ * ```
2336
2392
  *
2337
2393
  * @since 2.0.0
2338
2394
  * @category Error Accumulation
@@ -2364,6 +2420,7 @@ export const validateAll: {
2364
2420
  * @see {@link partition} when you need to separate successes and failures instead of losing successes with errors.
2365
2421
  *
2366
2422
  * @example
2423
+ * ```ts
2367
2424
  * import { Effect, Console } from "effect"
2368
2425
  *
2369
2426
  * // ┌─── Effect<number[], string[], never>
@@ -2390,6 +2447,7 @@ export const validateAll: {
2390
2447
  * // failure: [ '4 is not less that 4', '5 is not less that 4' ]
2391
2448
  * // }
2392
2449
  * // }
2450
+ * ```
2393
2451
  *
2394
2452
  * @since 2.0.0
2395
2453
  * @category Error Accumulation
@@ -2422,6 +2480,7 @@ export const validateAll: {
2422
2480
  * @see {@link firstSuccessOf} for a similar function that processes multiple effects and returns the first successful one or the last error.
2423
2481
  *
2424
2482
  * @example
2483
+ * ```ts
2425
2484
  * import { Effect, Console } from "effect"
2426
2485
  *
2427
2486
  * // ┌─── Effect<number, string[], never>
@@ -2438,6 +2497,7 @@ export const validateAll: {
2438
2497
  * // Output:
2439
2498
  * // item 4
2440
2499
  * // 4
2500
+ * ```
2441
2501
  *
2442
2502
  * @since 2.0.0
2443
2503
  * @category Error Accumulation
@@ -2459,6 +2519,7 @@ export const validateFirst: {
2459
2519
  * @see {@link firstSuccessOf} for a similar function that processes multiple effects and returns the first successful one or the last error.
2460
2520
  *
2461
2521
  * @example
2522
+ * ```ts
2462
2523
  * import { Effect, Console } from "effect"
2463
2524
  *
2464
2525
  * // ┌─── Effect<number, string[], never>
@@ -2475,6 +2536,7 @@ export const validateFirst: {
2475
2536
  * // Output:
2476
2537
  * // item 4
2477
2538
  * // 4
2539
+ * ```
2478
2540
  *
2479
2541
  * @since 2.0.0
2480
2542
  * @category Error Accumulation
@@ -2505,6 +2567,7 @@ export const validateFirst: {
2505
2567
  * @see {@link firstSuccessOf} for a similar function that processes multiple effects and returns the first successful one or the last error.
2506
2568
  *
2507
2569
  * @example
2570
+ * ```ts
2508
2571
  * import { Effect, Console } from "effect"
2509
2572
  *
2510
2573
  * // ┌─── Effect<number, string[], never>
@@ -2521,6 +2584,7 @@ export const validateFirst: {
2521
2584
  * // Output:
2522
2585
  * // item 4
2523
2586
  * // 4
2587
+ * ```
2524
2588
  *
2525
2589
  * @since 2.0.0
2526
2590
  * @category Error Accumulation
@@ -2563,6 +2627,7 @@ export const validateFirst: {
2563
2627
  * behavior of the returned effect.
2564
2628
  *
2565
2629
  * @example
2630
+ * ```ts
2566
2631
  * // Title: Wrapping a Callback API
2567
2632
  * import { Effect } from "effect"
2568
2633
  * import * as NodeFS from "node:fs"
@@ -2583,6 +2648,7 @@ export const validateFirst: {
2583
2648
  * // ┌─── Effect<Buffer, Error, never>
2584
2649
  * // ▼
2585
2650
  * const program = readFile("example.txt")
2651
+ * ```
2586
2652
  *
2587
2653
  * @example
2588
2654
  * // Title: Handling Interruption with Cleanup
@@ -2680,12 +2746,14 @@ export const asyncEffect: <A, E, R, R3, E2, R2>(
2680
2746
  * the "this" of the effect.
2681
2747
  *
2682
2748
  * @example
2749
+ * ```ts
2683
2750
  * import { Effect } from "effect"
2684
2751
  *
2685
2752
  * const throwingFunction = () => { throw new Error() }
2686
2753
  * const blowUp = Effect.custom(throwingFunction, function() {
2687
2754
  * return Effect.succeed(this.effect_instruction_i0())
2688
2755
  * })
2756
+ * ```
2689
2757
  *
2690
2758
  * @since 2.0.0
2691
2759
  * @category Creating Effects
@@ -2698,12 +2766,14 @@ export const custom: {
2698
2766
  * the "this" of the effect.
2699
2767
  *
2700
2768
  * @example
2769
+ * ```ts
2701
2770
  * import { Effect } from "effect"
2702
2771
  *
2703
2772
  * const throwingFunction = () => { throw new Error() }
2704
2773
  * const blowUp = Effect.custom(throwingFunction, function() {
2705
2774
  * return Effect.succeed(this.effect_instruction_i0())
2706
2775
  * })
2776
+ * ```
2707
2777
  *
2708
2778
  * @since 2.0.0
2709
2779
  * @category Creating Effects
@@ -2716,12 +2786,14 @@ export const custom: {
2716
2786
  * the "this" of the effect.
2717
2787
  *
2718
2788
  * @example
2789
+ * ```ts
2719
2790
  * import { Effect } from "effect"
2720
2791
  *
2721
2792
  * const throwingFunction = () => { throw new Error() }
2722
2793
  * const blowUp = Effect.custom(throwingFunction, function() {
2723
2794
  * return Effect.succeed(this.effect_instruction_i0())
2724
2795
  * })
2796
+ * ```
2725
2797
  *
2726
2798
  * @since 2.0.0
2727
2799
  * @category Creating Effects
@@ -2738,12 +2810,14 @@ export const custom: {
2738
2810
  * the "this" of the effect.
2739
2811
  *
2740
2812
  * @example
2813
+ * ```ts
2741
2814
  * import { Effect } from "effect"
2742
2815
  *
2743
2816
  * const throwingFunction = () => { throw new Error() }
2744
2817
  * const blowUp = Effect.custom(throwingFunction, function() {
2745
2818
  * return Effect.succeed(this.effect_instruction_i0())
2746
2819
  * })
2820
+ * ```
2747
2821
  *
2748
2822
  * @since 2.0.0
2749
2823
  * @category Creating Effects
@@ -2779,6 +2853,7 @@ export const withFiberRuntime: <A, E = never, R = never>(
2779
2853
  * @see {@link succeed} to create an effect that represents a successful value.
2780
2854
  *
2781
2855
  * @example
2856
+ * ```ts
2782
2857
  * // Title: Creating a Failed Effect
2783
2858
  * import { Effect } from "effect"
2784
2859
  *
@@ -2787,6 +2862,7 @@ export const withFiberRuntime: <A, E = never, R = never>(
2787
2862
  * const failure = Effect.fail(
2788
2863
  * new Error("Operation failed due to network error")
2789
2864
  * )
2865
+ * ```
2790
2866
  *
2791
2867
  * @since 2.0.0
2792
2868
  * @category Creating Effects
@@ -2832,6 +2908,7 @@ export const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Effect<nev
2832
2908
  * @see {@link dieMessage} for a variant that throws a `RuntimeException` with a message.
2833
2909
  *
2834
2910
  * @example
2911
+ * ```ts
2835
2912
  * // Title: Terminating on Division by Zero with a Specified Error
2836
2913
  * import { Effect } from "effect"
2837
2914
  *
@@ -2848,6 +2925,7 @@ export const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Effect<nev
2848
2925
  * // Output:
2849
2926
  * // (FiberFailure) Error: Cannot divide by zero
2850
2927
  * // ...stack trace...
2928
+ * ```
2851
2929
  *
2852
2930
  * @since 2.0.0
2853
2931
  * @category Creating Effects
@@ -2877,6 +2955,7 @@ export const die: (defect: unknown) => Effect<never> = core.die
2877
2955
  * lazily.
2878
2956
  *
2879
2957
  * @example
2958
+ * ```ts
2880
2959
  * // Title: Terminating on Division by Zero with a Specified Message
2881
2960
  * import { Effect } from "effect"
2882
2961
  *
@@ -2893,6 +2972,7 @@ export const die: (defect: unknown) => Effect<never> = core.die
2893
2972
  * // Output:
2894
2973
  * // (FiberFailure) RuntimeException: Cannot divide by zero
2895
2974
  * // ...stack trace...
2975
+ * ```
2896
2976
  *
2897
2977
  * @since 2.0.0
2898
2978
  * @category Creating Effects
@@ -2928,6 +3008,7 @@ export const dieSync: (evaluate: LazyArg<unknown>) => Effect<never> = core.dieSy
2928
3008
  * effects and return the final result at the end.
2929
3009
  *
2930
3010
  * @example
3011
+ * ```ts
2931
3012
  * import { Effect } from "effect"
2932
3013
  *
2933
3014
  * const addServiceCharge = (amount: number) => amount + 1
@@ -2954,6 +3035,7 @@ export const dieSync: (evaluate: LazyArg<unknown>) => Effect<never> = core.dieSy
2954
3035
  * const finalAmount = addServiceCharge(discountedAmount)
2955
3036
  * return `Final amount to charge: ${finalAmount}`
2956
3037
  * })
3038
+ * ```
2957
3039
  *
2958
3040
  * @since 2.0.0
2959
3041
  * @category Creating Effects
@@ -2975,6 +3057,7 @@ export const gen: {
2975
3057
  * effects and return the final result at the end.
2976
3058
  *
2977
3059
  * @example
3060
+ * ```ts
2978
3061
  * import { Effect } from "effect"
2979
3062
  *
2980
3063
  * const addServiceCharge = (amount: number) => amount + 1
@@ -3001,6 +3084,7 @@ export const gen: {
3001
3084
  * const finalAmount = addServiceCharge(discountedAmount)
3002
3085
  * return `Final amount to charge: ${finalAmount}`
3003
3086
  * })
3087
+ * ```
3004
3088
  *
3005
3089
  * @since 2.0.0
3006
3090
  * @category Creating Effects
@@ -3026,6 +3110,7 @@ export const gen: {
3026
3110
  * effects and return the final result at the end.
3027
3111
  *
3028
3112
  * @example
3113
+ * ```ts
3029
3114
  * import { Effect } from "effect"
3030
3115
  *
3031
3116
  * const addServiceCharge = (amount: number) => amount + 1
@@ -3052,6 +3137,7 @@ export const gen: {
3052
3137
  * const finalAmount = addServiceCharge(discountedAmount)
3053
3138
  * return `Final amount to charge: ${finalAmount}`
3054
3139
  * })
3140
+ * ```
3055
3141
  *
3056
3142
  * @since 2.0.0
3057
3143
  * @category Creating Effects
@@ -3377,6 +3463,7 @@ export const none: <A, E, R>(
3377
3463
  * @see {@link tryPromise} for a version that can handle failures.
3378
3464
  *
3379
3465
  * @example
3466
+ * ```ts
3380
3467
  * // Title: Delayed Message
3381
3468
  * import { Effect } from "effect"
3382
3469
  *
@@ -3393,6 +3480,7 @@ export const none: <A, E, R>(
3393
3480
  * // ┌─── Effect<string, never, never>
3394
3481
  * // ▼
3395
3482
  * const program = delay("Async operation completed successfully!")
3483
+ * ```
3396
3484
  *
3397
3485
  * @since 2.0.0
3398
3486
  * @category Creating Effects
@@ -3412,6 +3500,7 @@ export const promise: <A>(
3412
3500
  * @see {@link fail} to create an effect that represents a failure.
3413
3501
  *
3414
3502
  * @example
3503
+ * ```ts
3415
3504
  * // Title: Creating a Successful Effect
3416
3505
  * import { Effect } from "effect"
3417
3506
  *
@@ -3420,6 +3509,7 @@ export const promise: <A>(
3420
3509
  * // ┌─── Effect<number, never, never>
3421
3510
  * // ▼
3422
3511
  * const success = Effect.succeed(42)
3512
+ * ```
3423
3513
  *
3424
3514
  * @since 2.0.0
3425
3515
  * @category Creating Effects
@@ -3457,6 +3547,7 @@ export const succeedSome: <A>(value: A) => Effect<Option.Option<A>> = effect.suc
3457
3547
  * - **Unifying Return Types**: Can help TypeScript unify return types in situations where multiple branches of logic return different effects, simplifying type inference.
3458
3548
  *
3459
3549
  * @example
3550
+ * ```ts
3460
3551
  * // Title: Lazy Evaluation with Side Effects
3461
3552
  * import { Effect } from "effect"
3462
3553
  *
@@ -3471,6 +3562,7 @@ export const succeedSome: <A>(value: A) => Effect<Option.Option<A>> = effect.suc
3471
3562
  *
3472
3563
  * console.log(Effect.runSync(good)) // Output: 1
3473
3564
  * console.log(Effect.runSync(good)) // Output: 2
3565
+ * ```
3474
3566
  *
3475
3567
  * @example
3476
3568
  * // Title: Recursive Fibonacci
@@ -3544,6 +3636,7 @@ export const suspend: <A, E, R>(effect: LazyArg<Effect<A, E, R>>) => Effect<A, E
3544
3636
  * @see {@link try_ | try} for a version that can handle failures.
3545
3637
  *
3546
3638
  * @example
3639
+ * ```ts
3547
3640
  * // Title: Logging a Message
3548
3641
  * import { Effect } from "effect"
3549
3642
  *
@@ -3555,6 +3648,7 @@ export const suspend: <A, E, R>(effect: LazyArg<Effect<A, E, R>>) => Effect<A, E
3555
3648
  * // ┌─── Effect<void, never, never>
3556
3649
  * // ▼
3557
3650
  * const program = log("Hello, World!")
3651
+ * ```
3558
3652
  *
3559
3653
  * @since 2.0.0
3560
3654
  * @category Creating Effects
@@ -3616,6 +3710,7 @@ export {
3616
3710
  * @see {@link catchAllCause} for a version that can recover from both recoverable and unrecoverable errors.
3617
3711
  *
3618
3712
  * @example
3713
+ * ```ts
3619
3714
  * // Title: Providing Recovery Logic for Recoverable Errors
3620
3715
  * import { Effect, Random } from "effect"
3621
3716
  *
@@ -3648,6 +3743,7 @@ export {
3648
3743
  * Effect.succeed(`Recovering from ${error._tag}`)
3649
3744
  * )
3650
3745
  * )
3746
+ * ```
3651
3747
  *
3652
3748
  * @since 2.0.0
3653
3749
  * @category Error handling
@@ -3669,6 +3765,7 @@ export const catchAll: {
3669
3765
  * @see {@link catchAllCause} for a version that can recover from both recoverable and unrecoverable errors.
3670
3766
  *
3671
3767
  * @example
3768
+ * ```ts
3672
3769
  * // Title: Providing Recovery Logic for Recoverable Errors
3673
3770
  * import { Effect, Random } from "effect"
3674
3771
  *
@@ -3701,6 +3798,7 @@ export const catchAll: {
3701
3798
  * Effect.succeed(`Recovering from ${error._tag}`)
3702
3799
  * )
3703
3800
  * )
3801
+ * ```
3704
3802
  *
3705
3803
  * @since 2.0.0
3706
3804
  * @category Error handling
@@ -3722,6 +3820,7 @@ export const catchAll: {
3722
3820
  * @see {@link catchAllCause} for a version that can recover from both recoverable and unrecoverable errors.
3723
3821
  *
3724
3822
  * @example
3823
+ * ```ts
3725
3824
  * // Title: Providing Recovery Logic for Recoverable Errors
3726
3825
  * import { Effect, Random } from "effect"
3727
3826
  *
@@ -3754,6 +3853,7 @@ export const catchAll: {
3754
3853
  * Effect.succeed(`Recovering from ${error._tag}`)
3755
3854
  * )
3756
3855
  * )
3856
+ * ```
3757
3857
  *
3758
3858
  * @since 2.0.0
3759
3859
  * @category Error handling
@@ -3779,6 +3879,7 @@ export const catchAll: {
3779
3879
  * dynamically loaded plugins, controlled recovery might be needed.
3780
3880
  *
3781
3881
  * @example
3882
+ * ```ts
3782
3883
  * // Title: Recovering from All Errors
3783
3884
  * import { Cause, Effect } from "effect"
3784
3885
  *
@@ -3796,6 +3897,7 @@ export const catchAll: {
3796
3897
  *
3797
3898
  * Effect.runPromise(recovered).then(console.log)
3798
3899
  * // Output: "Recovered from a regular error"
3900
+ * ```
3799
3901
  *
3800
3902
  * @since 2.0.0
3801
3903
  * @category Error handling
@@ -3819,6 +3921,7 @@ export const catchAllCause: {
3819
3921
  * dynamically loaded plugins, controlled recovery might be needed.
3820
3922
  *
3821
3923
  * @example
3924
+ * ```ts
3822
3925
  * // Title: Recovering from All Errors
3823
3926
  * import { Cause, Effect } from "effect"
3824
3927
  *
@@ -3836,6 +3939,7 @@ export const catchAllCause: {
3836
3939
  *
3837
3940
  * Effect.runPromise(recovered).then(console.log)
3838
3941
  * // Output: "Recovered from a regular error"
3942
+ * ```
3839
3943
  *
3840
3944
  * @since 2.0.0
3841
3945
  * @category Error handling
@@ -3861,6 +3965,7 @@ export const catchAllCause: {
3861
3965
  * dynamically loaded plugins, controlled recovery might be needed.
3862
3966
  *
3863
3967
  * @example
3968
+ * ```ts
3864
3969
  * // Title: Recovering from All Errors
3865
3970
  * import { Cause, Effect } from "effect"
3866
3971
  *
@@ -3878,6 +3983,7 @@ export const catchAllCause: {
3878
3983
  *
3879
3984
  * Effect.runPromise(recovered).then(console.log)
3880
3985
  * // Output: "Recovered from a regular error"
3986
+ * ```
3881
3987
  *
3882
3988
  * @since 2.0.0
3883
3989
  * @category Error handling
@@ -3912,6 +4018,7 @@ export const catchAllCause: {
3912
4018
  * dynamically loaded plugins, controlled recovery might be needed.
3913
4019
  *
3914
4020
  * @example
4021
+ * ```ts
3915
4022
  * // Title: Handling All Defects
3916
4023
  * import { Effect, Cause, Console } from "effect"
3917
4024
  *
@@ -3936,6 +4043,7 @@ export const catchAllCause: {
3936
4043
  * // _tag: "Success",
3937
4044
  * // value: undefined
3938
4045
  * // }
4046
+ * ```
3939
4047
  *
3940
4048
  * @since 2.0.0
3941
4049
  * @category Error handling
@@ -3965,6 +4073,7 @@ export const catchAllDefect: {
3965
4073
  * dynamically loaded plugins, controlled recovery might be needed.
3966
4074
  *
3967
4075
  * @example
4076
+ * ```ts
3968
4077
  * // Title: Handling All Defects
3969
4078
  * import { Effect, Cause, Console } from "effect"
3970
4079
  *
@@ -3989,6 +4098,7 @@ export const catchAllDefect: {
3989
4098
  * // _tag: "Success",
3990
4099
  * // value: undefined
3991
4100
  * // }
4101
+ * ```
3992
4102
  *
3993
4103
  * @since 2.0.0
3994
4104
  * @category Error handling
@@ -4020,6 +4130,7 @@ export const catchAllDefect: {
4020
4130
  * dynamically loaded plugins, controlled recovery might be needed.
4021
4131
  *
4022
4132
  * @example
4133
+ * ```ts
4023
4134
  * // Title: Handling All Defects
4024
4135
  * import { Effect, Cause, Console } from "effect"
4025
4136
  *
@@ -4044,6 +4155,7 @@ export const catchAllDefect: {
4044
4155
  * // _tag: "Success",
4045
4156
  * // value: undefined
4046
4157
  * // }
4158
+ * ```
4047
4159
  *
4048
4160
  * @since 2.0.0
4049
4161
  * @category Error handling
@@ -4066,6 +4178,7 @@ export const catchAllDefect: {
4066
4178
  * error type unless a user-defined type guard is used to narrow the type.
4067
4179
  *
4068
4180
  * @example
4181
+ * ```ts
4069
4182
  * // Title: Catching Specific Errors with a Predicate
4070
4183
  * import { Effect, Random } from "effect"
4071
4184
  *
@@ -4100,6 +4213,7 @@ export const catchAllDefect: {
4100
4213
  * () => Effect.succeed("Recovering from HttpError")
4101
4214
  * )
4102
4215
  * )
4216
+ * ```
4103
4217
  *
4104
4218
  * @since 2.0.0
4105
4219
  * @category Error handling
@@ -4117,6 +4231,7 @@ export const catchIf: {
4117
4231
  * error type unless a user-defined type guard is used to narrow the type.
4118
4232
  *
4119
4233
  * @example
4234
+ * ```ts
4120
4235
  * // Title: Catching Specific Errors with a Predicate
4121
4236
  * import { Effect, Random } from "effect"
4122
4237
  *
@@ -4151,6 +4266,7 @@ export const catchIf: {
4151
4266
  * () => Effect.succeed("Recovering from HttpError")
4152
4267
  * )
4153
4268
  * )
4269
+ * ```
4154
4270
  *
4155
4271
  * @since 2.0.0
4156
4272
  * @category Error handling
@@ -4171,6 +4287,7 @@ export const catchIf: {
4171
4287
  * error type unless a user-defined type guard is used to narrow the type.
4172
4288
  *
4173
4289
  * @example
4290
+ * ```ts
4174
4291
  * // Title: Catching Specific Errors with a Predicate
4175
4292
  * import { Effect, Random } from "effect"
4176
4293
  *
@@ -4205,6 +4322,7 @@ export const catchIf: {
4205
4322
  * () => Effect.succeed("Recovering from HttpError")
4206
4323
  * )
4207
4324
  * )
4325
+ * ```
4208
4326
  *
4209
4327
  * @since 2.0.0
4210
4328
  * @category Error handling
@@ -4225,6 +4343,7 @@ export const catchIf: {
4225
4343
  * error type unless a user-defined type guard is used to narrow the type.
4226
4344
  *
4227
4345
  * @example
4346
+ * ```ts
4228
4347
  * // Title: Catching Specific Errors with a Predicate
4229
4348
  * import { Effect, Random } from "effect"
4230
4349
  *
@@ -4259,6 +4378,7 @@ export const catchIf: {
4259
4378
  * () => Effect.succeed("Recovering from HttpError")
4260
4379
  * )
4261
4380
  * )
4381
+ * ```
4262
4382
  *
4263
4383
  * @since 2.0.0
4264
4384
  * @category Error handling
@@ -4280,6 +4400,7 @@ export const catchIf: {
4280
4400
  * error type unless a user-defined type guard is used to narrow the type.
4281
4401
  *
4282
4402
  * @example
4403
+ * ```ts
4283
4404
  * // Title: Catching Specific Errors with a Predicate
4284
4405
  * import { Effect, Random } from "effect"
4285
4406
  *
@@ -4314,6 +4435,7 @@ export const catchIf: {
4314
4435
  * () => Effect.succeed("Recovering from HttpError")
4315
4436
  * )
4316
4437
  * )
4438
+ * ```
4317
4439
  *
4318
4440
  * @since 2.0.0
4319
4441
  * @category Error handling
@@ -4340,6 +4462,7 @@ export const catchIf: {
4340
4462
  * @see {@link catchIf} for a version that allows you to recover from errors based on a predicate.
4341
4463
  *
4342
4464
  * @example
4465
+ * ```ts
4343
4466
  * // Title: Handling Specific Errors with Effect.catchSome
4344
4467
  * import { Effect, Random, Option } from "effect"
4345
4468
  *
@@ -4377,6 +4500,7 @@ export const catchIf: {
4377
4500
  * }
4378
4501
  * })
4379
4502
  * )
4503
+ * ```
4380
4504
  *
4381
4505
  * @since 2.0.0
4382
4506
  * @category Error handling
@@ -4397,6 +4521,7 @@ export const catchSome: {
4397
4521
  * @see {@link catchIf} for a version that allows you to recover from errors based on a predicate.
4398
4522
  *
4399
4523
  * @example
4524
+ * ```ts
4400
4525
  * // Title: Handling Specific Errors with Effect.catchSome
4401
4526
  * import { Effect, Random, Option } from "effect"
4402
4527
  *
@@ -4434,6 +4559,7 @@ export const catchSome: {
4434
4559
  * }
4435
4560
  * })
4436
4561
  * )
4562
+ * ```
4437
4563
  *
4438
4564
  * @since 2.0.0
4439
4565
  * @category Error handling
@@ -4456,6 +4582,7 @@ export const catchSome: {
4456
4582
  * @see {@link catchIf} for a version that allows you to recover from errors based on a predicate.
4457
4583
  *
4458
4584
  * @example
4585
+ * ```ts
4459
4586
  * // Title: Handling Specific Errors with Effect.catchSome
4460
4587
  * import { Effect, Random, Option } from "effect"
4461
4588
  *
@@ -4493,6 +4620,7 @@ export const catchSome: {
4493
4620
  * }
4494
4621
  * })
4495
4622
  * )
4623
+ * ```
4496
4624
  *
4497
4625
  * @since 2.0.0
4498
4626
  * @category Error handling
@@ -4558,6 +4686,7 @@ export const catchSomeCause: {
4558
4686
  * - If the defect does not match, the function returns `Option.none`, allowing the defect to propagate.
4559
4687
  *
4560
4688
  * @example
4689
+ * ```ts
4561
4690
  * // Title: Handling Specific Defects
4562
4691
  * import { Effect, Cause, Option, Console } from "effect"
4563
4692
  *
@@ -4588,6 +4717,7 @@ export const catchSomeCause: {
4588
4717
  * // defect: { _tag: 'RuntimeException' }
4589
4718
  * // }
4590
4719
  * // }
4720
+ * ```
4591
4721
  *
4592
4722
  * @since 2.0.0
4593
4723
  * @category Error handling
@@ -4620,6 +4750,7 @@ export const catchSomeDefect: {
4620
4750
  * - If the defect does not match, the function returns `Option.none`, allowing the defect to propagate.
4621
4751
  *
4622
4752
  * @example
4753
+ * ```ts
4623
4754
  * // Title: Handling Specific Defects
4624
4755
  * import { Effect, Cause, Option, Console } from "effect"
4625
4756
  *
@@ -4650,6 +4781,7 @@ export const catchSomeDefect: {
4650
4781
  * // defect: { _tag: 'RuntimeException' }
4651
4782
  * // }
4652
4783
  * // }
4784
+ * ```
4653
4785
  *
4654
4786
  * @since 2.0.0
4655
4787
  * @category Error handling
@@ -4684,6 +4816,7 @@ export const catchSomeDefect: {
4684
4816
  * - If the defect does not match, the function returns `Option.none`, allowing the defect to propagate.
4685
4817
  *
4686
4818
  * @example
4819
+ * ```ts
4687
4820
  * // Title: Handling Specific Defects
4688
4821
  * import { Effect, Cause, Option, Console } from "effect"
4689
4822
  *
@@ -4714,6 +4847,7 @@ export const catchSomeDefect: {
4714
4847
  * // defect: { _tag: 'RuntimeException' }
4715
4848
  * // }
4716
4849
  * // }
4850
+ * ```
4717
4851
  *
4718
4852
  * @since 2.0.0
4719
4853
  * @category Error handling
@@ -4742,6 +4876,7 @@ export const catchSomeDefect: {
4742
4876
  * types at once.
4743
4877
  *
4744
4878
  * @example
4879
+ * ```ts
4745
4880
  * // Title: Handling Errors by Tag
4746
4881
  * import { Effect, Random } from "effect"
4747
4882
  *
@@ -4775,6 +4910,7 @@ export const catchSomeDefect: {
4775
4910
  * Effect.succeed("Recovering from HttpError")
4776
4911
  * )
4777
4912
  * )
4913
+ * ```
4778
4914
  *
4779
4915
  * @since 2.0.0
4780
4916
  * @category Error handling
@@ -4798,6 +4934,7 @@ export const catchTag: {
4798
4934
  * types at once.
4799
4935
  *
4800
4936
  * @example
4937
+ * ```ts
4801
4938
  * // Title: Handling Errors by Tag
4802
4939
  * import { Effect, Random } from "effect"
4803
4940
  *
@@ -4831,6 +4968,7 @@ export const catchTag: {
4831
4968
  * Effect.succeed("Recovering from HttpError")
4832
4969
  * )
4833
4970
  * )
4971
+ * ```
4834
4972
  *
4835
4973
  * @since 2.0.0
4836
4974
  * @category Error handling
@@ -4857,6 +4995,7 @@ export const catchTag: {
4857
4995
  * types at once.
4858
4996
  *
4859
4997
  * @example
4998
+ * ```ts
4860
4999
  * // Title: Handling Errors by Tag
4861
5000
  * import { Effect, Random } from "effect"
4862
5001
  *
@@ -4890,6 +5029,7 @@ export const catchTag: {
4890
5029
  * Effect.succeed("Recovering from HttpError")
4891
5030
  * )
4892
5031
  * )
5032
+ * ```
4893
5033
  *
4894
5034
  * @since 2.0.0
4895
5035
  * @category Error handling
@@ -4916,6 +5056,7 @@ export const catchTag: {
4916
5056
  * field is used to identify and match errors.
4917
5057
  *
4918
5058
  * @example
5059
+ * ```ts
4919
5060
  * // Title: Handling Multiple Tagged Error Types at Once
4920
5061
  * import { Effect, Random } from "effect"
4921
5062
  *
@@ -4951,6 +5092,7 @@ export const catchTag: {
4951
5092
  * Effect.succeed(`Recovering from ValidationError`)
4952
5093
  * })
4953
5094
  * )
5095
+ * ```
4954
5096
  *
4955
5097
  * @since 2.0.0
4956
5098
  * @category Error handling
@@ -4971,6 +5113,7 @@ export const catchTags: {
4971
5113
  * field is used to identify and match errors.
4972
5114
  *
4973
5115
  * @example
5116
+ * ```ts
4974
5117
  * // Title: Handling Multiple Tagged Error Types at Once
4975
5118
  * import { Effect, Random } from "effect"
4976
5119
  *
@@ -5006,6 +5149,7 @@ export const catchTags: {
5006
5149
  * Effect.succeed(`Recovering from ValidationError`)
5007
5150
  * })
5008
5151
  * )
5152
+ * ```
5009
5153
  *
5010
5154
  * @since 2.0.0
5011
5155
  * @category Error handling
@@ -5046,6 +5190,7 @@ export const catchTags: {
5046
5190
  * field is used to identify and match errors.
5047
5191
  *
5048
5192
  * @example
5193
+ * ```ts
5049
5194
  * // Title: Handling Multiple Tagged Error Types at Once
5050
5195
  * import { Effect, Random } from "effect"
5051
5196
  *
@@ -5081,6 +5226,7 @@ export const catchTags: {
5081
5226
  * Effect.succeed(`Recovering from ValidationError`)
5082
5227
  * })
5083
5228
  * )
5229
+ * ```
5084
5230
  *
5085
5231
  * @since 2.0.0
5086
5232
  * @category Error handling
@@ -5120,6 +5266,7 @@ export const catchTags: {
5120
5266
  * interruptions, etc.).
5121
5267
  *
5122
5268
  * @example
5269
+ * ```ts
5123
5270
  * import { Effect, Console } from "effect"
5124
5271
  *
5125
5272
  * // ┌─── Effect<number, string, never>
@@ -5132,6 +5279,7 @@ export const catchTags: {
5132
5279
  * const cause = yield* Effect.cause(program)
5133
5280
  * yield* Console.log(cause)
5134
5281
  * })
5282
+ * ```
5135
5283
  *
5136
5284
  * @since 2.0.0
5137
5285
  * @category Error handling
@@ -5155,6 +5303,7 @@ export const eventually: <A, E, R>(self: Effect<A, E, R>) => Effect<A, never, R>
5155
5303
  * side effects of the effect and do not need to handle or process its outcome.
5156
5304
  *
5157
5305
  * @example
5306
+ * ```ts
5158
5307
  * import { Effect } from "effect"
5159
5308
  *
5160
5309
  * // ┌─── Effect<number, string, never>
@@ -5164,6 +5313,7 @@ export const eventually: <A, E, R>(self: Effect<A, E, R>) => Effect<A, never, R>
5164
5313
  * // ┌─── Effect<void, never, never>
5165
5314
  * // ▼
5166
5315
  * const program = Effect.ignore(task)
5316
+ * ```
5167
5317
  *
5168
5318
  * @since 2.0.0
5169
5319
  * @category Error handling
@@ -5191,6 +5341,7 @@ export const ignoreLogged: <A, E, R>(self: Effect<A, E, R>) => Effect<void, neve
5191
5341
  * it easier to manage and respond to errors from multiple operations at once.
5192
5342
  *
5193
5343
  * @example
5344
+ * ```ts
5194
5345
  * import { Effect } from "effect"
5195
5346
  *
5196
5347
  * const fail1 = Effect.fail("Oh uh!")
@@ -5209,6 +5360,7 @@ export const ignoreLogged: <A, E, R>(self: Effect<A, E, R>) => Effect<void, neve
5209
5360
  * // _tag: 'Failure',
5210
5361
  * // cause: { _id: 'Cause', _tag: 'Fail', failure: [ 'Oh uh!', 'Oh no!' ] }
5211
5362
  * // }
5363
+ * ```
5212
5364
  *
5213
5365
  * @since 2.0.0
5214
5366
  * @category Error handling
@@ -5231,6 +5383,7 @@ export const parallelErrors: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Array
5231
5383
  * @see {@link unsandbox} to restore the original error handling.
5232
5384
  *
5233
5385
  * @example
5386
+ * ```ts
5234
5387
  * import { Effect, Console } from "effect"
5235
5388
  *
5236
5389
  * // ┌─── Effect<string, Error, never>
@@ -5265,6 +5418,7 @@ export const parallelErrors: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Array
5265
5418
  * // Output:
5266
5419
  * // Caught a defect: Oh uh!
5267
5420
  * // fallback result on failure
5421
+ * ```
5268
5422
  *
5269
5423
  * @since 2.0.0
5270
5424
  * @category Error handling
@@ -5322,6 +5476,7 @@ export declare namespace Retry {
5322
5476
  * @see {@link retryOrElse} for a version that allows you to run a fallback.
5323
5477
  *
5324
5478
  * @example
5479
+ * ```ts
5325
5480
  * import { Effect, Schedule } from "effect"
5326
5481
  *
5327
5482
  * let count = 0
@@ -5350,6 +5505,7 @@ export declare namespace Retry {
5350
5505
  * // failure
5351
5506
  * // success
5352
5507
  * // yay!
5508
+ * ```
5353
5509
  *
5354
5510
  * @since 2.0.0
5355
5511
  * @category Error handling
@@ -5372,6 +5528,7 @@ export const retry: {
5372
5528
  * @see {@link retryOrElse} for a version that allows you to run a fallback.
5373
5529
  *
5374
5530
  * @example
5531
+ * ```ts
5375
5532
  * import { Effect, Schedule } from "effect"
5376
5533
  *
5377
5534
  * let count = 0
@@ -5400,6 +5557,7 @@ export const retry: {
5400
5557
  * // failure
5401
5558
  * // success
5402
5559
  * // yay!
5560
+ * ```
5403
5561
  *
5404
5562
  * @since 2.0.0
5405
5563
  * @category Error handling
@@ -5424,6 +5582,7 @@ export const retry: {
5424
5582
  * @see {@link retryOrElse} for a version that allows you to run a fallback.
5425
5583
  *
5426
5584
  * @example
5585
+ * ```ts
5427
5586
  * import { Effect, Schedule } from "effect"
5428
5587
  *
5429
5588
  * let count = 0
@@ -5452,6 +5611,7 @@ export const retry: {
5452
5611
  * // failure
5453
5612
  * // success
5454
5613
  * // yay!
5614
+ * ```
5455
5615
  *
5456
5616
  * @since 2.0.0
5457
5617
  * @category Error handling
@@ -5474,6 +5634,7 @@ export const retry: {
5474
5634
  * @see {@link retryOrElse} for a version that allows you to run a fallback.
5475
5635
  *
5476
5636
  * @example
5637
+ * ```ts
5477
5638
  * import { Effect, Schedule } from "effect"
5478
5639
  *
5479
5640
  * let count = 0
@@ -5502,6 +5663,7 @@ export const retry: {
5502
5663
  * // failure
5503
5664
  * // success
5504
5665
  * // yay!
5666
+ * ```
5505
5667
  *
5506
5668
  * @since 2.0.0
5507
5669
  * @category Error handling
@@ -5524,6 +5686,7 @@ export const retry: {
5524
5686
  * @see {@link retryOrElse} for a version that allows you to run a fallback.
5525
5687
  *
5526
5688
  * @example
5689
+ * ```ts
5527
5690
  * import { Effect, Schedule } from "effect"
5528
5691
  *
5529
5692
  * let count = 0
@@ -5552,6 +5715,7 @@ export const retry: {
5552
5715
  * // failure
5553
5716
  * // success
5554
5717
  * // yay!
5718
+ * ```
5555
5719
  *
5556
5720
  * @since 2.0.0
5557
5721
  * @category Error handling
@@ -5571,6 +5735,7 @@ export const retry: {
5571
5735
  * @see {@link retry} for a version that does not run a fallback effect.
5572
5736
  *
5573
5737
  * @example
5738
+ * ```ts
5574
5739
  * import { Effect, Schedule, Console } from "effect"
5575
5740
  *
5576
5741
  * let count = 0
@@ -5602,6 +5767,7 @@ export const retry: {
5602
5767
  * // failure
5603
5768
  * // orElse
5604
5769
  * // default value
5770
+ * ```
5605
5771
  *
5606
5772
  * @since 2.0.0
5607
5773
  * @category Error handling
@@ -5619,6 +5785,7 @@ export const retryOrElse: {
5619
5785
  * @see {@link retry} for a version that does not run a fallback effect.
5620
5786
  *
5621
5787
  * @example
5788
+ * ```ts
5622
5789
  * import { Effect, Schedule, Console } from "effect"
5623
5790
  *
5624
5791
  * let count = 0
@@ -5650,6 +5817,7 @@ export const retryOrElse: {
5650
5817
  * // failure
5651
5818
  * // orElse
5652
5819
  * // default value
5820
+ * ```
5653
5821
  *
5654
5822
  * @since 2.0.0
5655
5823
  * @category Error handling
@@ -5670,6 +5838,7 @@ export const retryOrElse: {
5670
5838
  * @see {@link retry} for a version that does not run a fallback effect.
5671
5839
  *
5672
5840
  * @example
5841
+ * ```ts
5673
5842
  * import { Effect, Schedule, Console } from "effect"
5674
5843
  *
5675
5844
  * let count = 0
@@ -5701,6 +5870,7 @@ export const retryOrElse: {
5701
5870
  * // failure
5702
5871
  * // orElse
5703
5872
  * // default value
5873
+ * ```
5704
5874
  *
5705
5875
  * @since 2.0.0
5706
5876
  * @category Error handling
@@ -5742,6 +5912,7 @@ export {
5742
5912
  * throw errors.
5743
5913
  *
5744
5914
  * @example
5915
+ * ```ts
5745
5916
  * // Title: Safe JSON Parsing
5746
5917
  * import { Effect } from "effect"
5747
5918
  *
@@ -5753,6 +5924,7 @@ export {
5753
5924
  * // ▼
5754
5925
  * const program = parse("")
5755
5926
  *
5927
+ * ```
5756
5928
  * @example
5757
5929
  * // Title: Custom Error Handling
5758
5930
  * import { Effect } from "effect"
@@ -5884,6 +6056,7 @@ export const tryMapPromise: {
5884
6056
  * @see {@link promise} if the effectful computation is asynchronous and does not throw errors.
5885
6057
  *
5886
6058
  * @example
6059
+ * ```ts
5887
6060
  * // Title: Fetching a TODO Item
5888
6061
  * import { Effect } from "effect"
5889
6062
  *
@@ -5896,6 +6069,7 @@ export const tryMapPromise: {
5896
6069
  * // ┌─── Effect<Response, UnknownException, never>
5897
6070
  * // ▼
5898
6071
  * const program = getTodo(1)
6072
+ * ```
5899
6073
  *
5900
6074
  * @example
5901
6075
  * // Title: Custom Error Handling
@@ -5945,6 +6119,7 @@ export const tryPromise: {
5945
6119
  * @see {@link promise} if the effectful computation is asynchronous and does not throw errors.
5946
6120
  *
5947
6121
  * @example
6122
+ * ```ts
5948
6123
  * // Title: Fetching a TODO Item
5949
6124
  * import { Effect } from "effect"
5950
6125
  *
@@ -5957,6 +6132,7 @@ export const tryPromise: {
5957
6132
  * // ┌─── Effect<Response, UnknownException, never>
5958
6133
  * // ▼
5959
6134
  * const program = getTodo(1)
6135
+ * ```
5960
6136
  *
5961
6137
  * @example
5962
6138
  * // Title: Custom Error Handling
@@ -6011,6 +6187,7 @@ export const tryPromise: {
6011
6187
  * @see {@link promise} if the effectful computation is asynchronous and does not throw errors.
6012
6188
  *
6013
6189
  * @example
6190
+ * ```ts
6014
6191
  * // Title: Fetching a TODO Item
6015
6192
  * import { Effect } from "effect"
6016
6193
  *
@@ -6023,6 +6200,7 @@ export const tryPromise: {
6023
6200
  * // ┌─── Effect<Response, UnknownException, never>
6024
6201
  * // ▼
6025
6202
  * const program = getTodo(1)
6203
+ * ```
6026
6204
  *
6027
6205
  * @example
6028
6206
  * // Title: Custom Error Handling
@@ -6111,6 +6289,7 @@ export const checkInterruptible: <A, E, R>(f: (isInterruptible: boolean) => Effe
6111
6289
  * @see {@link Effect.uninterruptible} for creating an uninterruptible effect.
6112
6290
  *
6113
6291
  * @example
6292
+ * ```ts
6114
6293
  * import { Effect } from "effect"
6115
6294
  *
6116
6295
  * const longRunningTask = Effect.gen(function* () {
@@ -6140,6 +6319,7 @@ export const checkInterruptible: <A, E, R>(f: (isInterruptible: boolean) => Effe
6140
6319
  * // }
6141
6320
  * // }
6142
6321
  * // Heavy processing done.
6322
+ * ```
6143
6323
  *
6144
6324
  * @since 2.0.0
6145
6325
  * @category Interruption
@@ -6213,6 +6393,7 @@ export const uninterruptibleMask: <A, E, R>(
6213
6393
  * or failing with specified error if the predicate fails
6214
6394
  *
6215
6395
  * @example
6396
+ * ```ts
6216
6397
  * import { Effect } from "effect"
6217
6398
  *
6218
6399
  * const isPositive = (n: number): boolean => n > 0
@@ -6222,6 +6403,7 @@ export const uninterruptibleMask: <A, E, R>(
6222
6403
  *
6223
6404
  * // fails with `"0 is not positive"`
6224
6405
  * Effect.liftPredicate(0, isPositive, n => `${n} is not positive`)
6406
+ * ```
6225
6407
  *
6226
6408
  * @category Condition Checking
6227
6409
  * @since 3.4.0
@@ -6232,6 +6414,7 @@ export const liftPredicate: {
6232
6414
  * or failing with specified error if the predicate fails
6233
6415
  *
6234
6416
  * @example
6417
+ * ```ts
6235
6418
  * import { Effect } from "effect"
6236
6419
  *
6237
6420
  * const isPositive = (n: number): boolean => n > 0
@@ -6241,6 +6424,7 @@ export const liftPredicate: {
6241
6424
  *
6242
6425
  * // fails with `"0 is not positive"`
6243
6426
  * Effect.liftPredicate(0, isPositive, n => `${n} is not positive`)
6427
+ * ```
6244
6428
  *
6245
6429
  * @category Condition Checking
6246
6430
  * @since 3.4.0
@@ -6251,6 +6435,7 @@ export const liftPredicate: {
6251
6435
  * or failing with specified error if the predicate fails
6252
6436
  *
6253
6437
  * @example
6438
+ * ```ts
6254
6439
  * import { Effect } from "effect"
6255
6440
  *
6256
6441
  * const isPositive = (n: number): boolean => n > 0
@@ -6260,6 +6445,7 @@ export const liftPredicate: {
6260
6445
  *
6261
6446
  * // fails with `"0 is not positive"`
6262
6447
  * Effect.liftPredicate(0, isPositive, n => `${n} is not positive`)
6448
+ * ```
6263
6449
  *
6264
6450
  * @category Condition Checking
6265
6451
  * @since 3.4.0
@@ -6270,6 +6456,7 @@ export const liftPredicate: {
6270
6456
  * or failing with specified error if the predicate fails
6271
6457
  *
6272
6458
  * @example
6459
+ * ```ts
6273
6460
  * import { Effect } from "effect"
6274
6461
  *
6275
6462
  * const isPositive = (n: number): boolean => n > 0
@@ -6279,6 +6466,7 @@ export const liftPredicate: {
6279
6466
  *
6280
6467
  * // fails with `"0 is not positive"`
6281
6468
  * Effect.liftPredicate(0, isPositive, n => `${n} is not positive`)
6469
+ * ```
6282
6470
  *
6283
6471
  * @category Condition Checking
6284
6472
  * @since 3.4.0
@@ -6289,6 +6477,7 @@ export const liftPredicate: {
6289
6477
  * or failing with specified error if the predicate fails
6290
6478
  *
6291
6479
  * @example
6480
+ * ```ts
6292
6481
  * import { Effect } from "effect"
6293
6482
  *
6294
6483
  * const isPositive = (n: number): boolean => n > 0
@@ -6298,6 +6487,7 @@ export const liftPredicate: {
6298
6487
  *
6299
6488
  * // fails with `"0 is not positive"`
6300
6489
  * Effect.liftPredicate(0, isPositive, n => `${n} is not positive`)
6490
+ * ```
6301
6491
  *
6302
6492
  * @category Condition Checking
6303
6493
  * @since 3.4.0
@@ -6316,6 +6506,7 @@ export const liftPredicate: {
6316
6506
  * replace it with a new constant value.
6317
6507
  *
6318
6508
  * @example
6509
+ * ```ts
6319
6510
  * // Title: Replacing a Value
6320
6511
  * import { pipe, Effect } from "effect"
6321
6512
  *
@@ -6324,6 +6515,7 @@ export const liftPredicate: {
6324
6515
  *
6325
6516
  * Effect.runPromise(program).then(console.log)
6326
6517
  * // Output: "new value"
6518
+ * ```
6327
6519
  *
6328
6520
  * @since 2.0.0
6329
6521
  * @category Mapping
@@ -6336,6 +6528,7 @@ export const as: {
6336
6528
  * replace it with a new constant value.
6337
6529
  *
6338
6530
  * @example
6531
+ * ```ts
6339
6532
  * // Title: Replacing a Value
6340
6533
  * import { pipe, Effect } from "effect"
6341
6534
  *
@@ -6344,6 +6537,7 @@ export const as: {
6344
6537
  *
6345
6538
  * Effect.runPromise(program).then(console.log)
6346
6539
  * // Output: "new value"
6540
+ * ```
6347
6541
  *
6348
6542
  * @since 2.0.0
6349
6543
  * @category Mapping
@@ -6356,6 +6550,7 @@ export const as: {
6356
6550
  * replace it with a new constant value.
6357
6551
  *
6358
6552
  * @example
6553
+ * ```ts
6359
6554
  * // Title: Replacing a Value
6360
6555
  * import { pipe, Effect } from "effect"
6361
6556
  *
@@ -6364,6 +6559,7 @@ export const as: {
6364
6559
  *
6365
6560
  * Effect.runPromise(program).then(console.log)
6366
6561
  * // Output: "new value"
6562
+ * ```
6367
6563
  *
6368
6564
  * @since 2.0.0
6369
6565
  * @category Mapping
@@ -6412,6 +6608,7 @@ export const asVoid: <A, E, R>(self: Effect<A, E, R>) => Effect<void, E, R> = co
6412
6608
  * treat an error as a valid result.
6413
6609
  *
6414
6610
  * @example
6611
+ * ```ts
6415
6612
  * import { Effect } from "effect"
6416
6613
  *
6417
6614
  * // ┌─── Effect<number, string, never>
@@ -6421,6 +6618,7 @@ export const asVoid: <A, E, R>(self: Effect<A, E, R>) => Effect<void, E, R> = co
6421
6618
  * // ┌─── Effect<string, number, never>
6422
6619
  * // ▼
6423
6620
  * const flipped = Effect.flip(program)
6621
+ * ```
6424
6622
  *
6425
6623
  * @since 2.0.0
6426
6624
  * @category Mapping
@@ -6482,6 +6680,7 @@ export const flipWith: {
6482
6680
  * @see {@link flatMap} or {@link andThen} for a version that can return a new effect.
6483
6681
  *
6484
6682
  * @example
6683
+ * ```ts
6485
6684
  * // Title: Adding a Service Charge
6486
6685
  * import { pipe, Effect } from "effect"
6487
6686
  *
@@ -6496,6 +6695,7 @@ export const flipWith: {
6496
6695
  *
6497
6696
  * Effect.runPromise(finalAmount).then(console.log)
6498
6697
  * // Output: 101
6698
+ * ```
6499
6699
  * @since 2.0.0
6500
6700
  * @category Mapping
6501
6701
  */
@@ -6527,6 +6727,7 @@ export const map: {
6527
6727
  * @see {@link flatMap} or {@link andThen} for a version that can return a new effect.
6528
6728
  *
6529
6729
  * @example
6730
+ * ```ts
6530
6731
  * // Title: Adding a Service Charge
6531
6732
  * import { pipe, Effect } from "effect"
6532
6733
  *
@@ -6541,6 +6742,7 @@ export const map: {
6541
6742
  *
6542
6743
  * Effect.runPromise(finalAmount).then(console.log)
6543
6744
  * // Output: 101
6745
+ * ```
6544
6746
  * @since 2.0.0
6545
6747
  * @category Mapping
6546
6748
  */
@@ -6572,6 +6774,7 @@ export const map: {
6572
6774
  * @see {@link flatMap} or {@link andThen} for a version that can return a new effect.
6573
6775
  *
6574
6776
  * @example
6777
+ * ```ts
6575
6778
  * // Title: Adding a Service Charge
6576
6779
  * import { pipe, Effect } from "effect"
6577
6780
  *
@@ -6586,6 +6789,7 @@ export const map: {
6586
6789
  *
6587
6790
  * Effect.runPromise(finalAmount).then(console.log)
6588
6791
  * // Output: 101
6792
+ * ```
6589
6793
  * @since 2.0.0
6590
6794
  * @category Mapping
6591
6795
  */
@@ -6612,6 +6816,7 @@ export const map: {
6612
6816
  * input collection type.
6613
6817
  *
6614
6818
  * @example
6819
+ * ```ts
6615
6820
  * import { Effect } from "effect"
6616
6821
  *
6617
6822
  * // Define an initial state and a transformation function
@@ -6630,6 +6835,7 @@ export const map: {
6630
6835
  * // Output:
6631
6836
  * // 6
6632
6837
  * // [ 'A', 'BB', 'CCC' ]
6838
+ * ```
6633
6839
  *
6634
6840
  * @since 2.0.0
6635
6841
  * @category Mapping
@@ -6655,6 +6861,7 @@ export const mapAccum: {
6655
6861
  * input collection type.
6656
6862
  *
6657
6863
  * @example
6864
+ * ```ts
6658
6865
  * import { Effect } from "effect"
6659
6866
  *
6660
6867
  * // Define an initial state and a transformation function
@@ -6673,6 +6880,7 @@ export const mapAccum: {
6673
6880
  * // Output:
6674
6881
  * // 6
6675
6882
  * // [ 'A', 'BB', 'CCC' ]
6883
+ * ```
6676
6884
  *
6677
6885
  * @since 2.0.0
6678
6886
  * @category Mapping
@@ -6701,6 +6909,7 @@ export const mapAccum: {
6701
6909
  * input collection type.
6702
6910
  *
6703
6911
  * @example
6912
+ * ```ts
6704
6913
  * import { Effect } from "effect"
6705
6914
  *
6706
6915
  * // Define an initial state and a transformation function
@@ -6719,6 +6928,7 @@ export const mapAccum: {
6719
6928
  * // Output:
6720
6929
  * // 6
6721
6930
  * // [ 'A', 'BB', 'CCC' ]
6931
+ * ```
6722
6932
  *
6723
6933
  * @since 2.0.0
6724
6934
  * @category Mapping
@@ -6743,6 +6953,7 @@ export const mapAccum: {
6743
6953
  * @see {@link mapError} for a version that operates on the error channel.
6744
6954
  *
6745
6955
  * @example
6956
+ * ```ts
6746
6957
  * import { Effect } from "effect"
6747
6958
  *
6748
6959
  * // ┌─── Effect<number, string, never>
@@ -6755,6 +6966,7 @@ export const mapAccum: {
6755
6966
  * onFailure: (message) => new Error(message),
6756
6967
  * onSuccess: (n) => n > 0
6757
6968
  * })
6969
+ * ```
6758
6970
  *
6759
6971
  * @since 2.0.0
6760
6972
  * @category Mapping
@@ -6773,6 +6985,7 @@ export const mapBoth: {
6773
6985
  * @see {@link mapError} for a version that operates on the error channel.
6774
6986
  *
6775
6987
  * @example
6988
+ * ```ts
6776
6989
  * import { Effect } from "effect"
6777
6990
  *
6778
6991
  * // ┌─── Effect<number, string, never>
@@ -6785,6 +6998,7 @@ export const mapBoth: {
6785
6998
  * onFailure: (message) => new Error(message),
6786
6999
  * onSuccess: (n) => n > 0
6787
7000
  * })
7001
+ * ```
6788
7002
  *
6789
7003
  * @since 2.0.0
6790
7004
  * @category Mapping
@@ -6805,6 +7019,7 @@ export const mapBoth: {
6805
7019
  * @see {@link mapError} for a version that operates on the error channel.
6806
7020
  *
6807
7021
  * @example
7022
+ * ```ts
6808
7023
  * import { Effect } from "effect"
6809
7024
  *
6810
7025
  * // ┌─── Effect<number, string, never>
@@ -6817,6 +7032,7 @@ export const mapBoth: {
6817
7032
  * onFailure: (message) => new Error(message),
6818
7033
  * onSuccess: (n) => n > 0
6819
7034
  * })
7035
+ * ```
6820
7036
  *
6821
7037
  * @since 2.0.0
6822
7038
  * @category Mapping
@@ -6841,6 +7057,7 @@ export const mapBoth: {
6841
7057
  * @see {@link orElseFail} if you want to replace the error with a new one.
6842
7058
  *
6843
7059
  * @example
7060
+ * ```ts
6844
7061
  * import { Effect } from "effect"
6845
7062
  *
6846
7063
  * // ┌─── Effect<number, string, never>
@@ -6853,6 +7070,7 @@ export const mapBoth: {
6853
7070
  * simulatedTask,
6854
7071
  * (message) => new Error(message)
6855
7072
  * )
7073
+ * ```
6856
7074
  *
6857
7075
  * @since 2.0.0
6858
7076
  * @category Mapping
@@ -6872,6 +7090,7 @@ export const mapError: {
6872
7090
  * @see {@link orElseFail} if you want to replace the error with a new one.
6873
7091
  *
6874
7092
  * @example
7093
+ * ```ts
6875
7094
  * import { Effect } from "effect"
6876
7095
  *
6877
7096
  * // ┌─── Effect<number, string, never>
@@ -6884,6 +7103,7 @@ export const mapError: {
6884
7103
  * simulatedTask,
6885
7104
  * (message) => new Error(message)
6886
7105
  * )
7106
+ * ```
6887
7107
  *
6888
7108
  * @since 2.0.0
6889
7109
  * @category Mapping
@@ -6903,6 +7123,7 @@ export const mapError: {
6903
7123
  * @see {@link orElseFail} if you want to replace the error with a new one.
6904
7124
  *
6905
7125
  * @example
7126
+ * ```ts
6906
7127
  * import { Effect } from "effect"
6907
7128
  *
6908
7129
  * // ┌─── Effect<number, string, never>
@@ -6915,6 +7136,7 @@ export const mapError: {
6915
7136
  * simulatedTask,
6916
7137
  * (message) => new Error(message)
6917
7138
  * )
7139
+ * ```
6918
7140
  *
6919
7141
  * @since 2.0.0
6920
7142
  * @category Mapping
@@ -6968,6 +7190,7 @@ export const mapErrorCause: {
6968
7190
  * errors as part of the outcome.
6969
7191
  *
6970
7192
  * @example
7193
+ * ```ts
6971
7194
  * import { Effect } from "effect"
6972
7195
  *
6973
7196
  * // ┌─── Effect<number, string, never>
@@ -6977,6 +7200,7 @@ export const mapErrorCause: {
6977
7200
  * // ┌─── Effect<number | string, never, never>
6978
7201
  * // ▼
6979
7202
  * const recovered = Effect.merge(program)
7203
+ * ```
6980
7204
  *
6981
7205
  * @since 2.0.0
6982
7206
  * @category Mapping
@@ -7368,6 +7592,17 @@ export const scope: Effect<Scope.Scope, never, Scope.Scope> = fiberRuntime.scope
7368
7592
  export const scopeWith: <A, E, R>(f: (scope: Scope.Scope) => Effect<A, E, R>) => Effect<A, E, R | Scope.Scope> =
7369
7593
  fiberRuntime.scopeWith
7370
7594
 
7595
+ /**
7596
+ * Creates a `Scope`, passes it to the specified effectful function, and then
7597
+ * closes the scope as soon as the effect is complete (whether through success,
7598
+ * failure, or interruption).
7599
+ *
7600
+ * @since 3.11.0
7601
+ * @category scoping, resources & finalization
7602
+ */
7603
+ export const scopedWith: <A, E, R>(f: (scope: Scope.Scope) => Effect<A, E, R>) => Effect<A, E, R> =
7604
+ fiberRuntime.scopedWith
7605
+
7371
7606
  /**
7372
7607
  * Scopes all resources used in this workflow to the lifetime of the workflow,
7373
7608
  * ensuring that their finalizers are run as soon as this workflow completes
@@ -8030,6 +8265,7 @@ export const timedWith: {
8030
8265
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8031
8266
  *
8032
8267
  * @example
8268
+ * ```ts
8033
8269
  * import { Effect } from "effect"
8034
8270
  *
8035
8271
  * const task = Effect.gen(function* () {
@@ -8055,6 +8291,7 @@ export const timedWith: {
8055
8291
  * // failure: { _tag: 'TimeoutException' }
8056
8292
  * // }
8057
8293
  * // }
8294
+ * ```
8058
8295
  *
8059
8296
  * @since 2.0.0
8060
8297
  * @category delays & timeouts
@@ -8075,6 +8312,7 @@ export const timeout: {
8075
8312
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8076
8313
  *
8077
8314
  * @example
8315
+ * ```ts
8078
8316
  * import { Effect } from "effect"
8079
8317
  *
8080
8318
  * const task = Effect.gen(function* () {
@@ -8100,6 +8338,7 @@ export const timeout: {
8100
8338
  * // failure: { _tag: 'TimeoutException' }
8101
8339
  * // }
8102
8340
  * // }
8341
+ * ```
8103
8342
  *
8104
8343
  * @since 2.0.0
8105
8344
  * @category delays & timeouts
@@ -8120,6 +8359,7 @@ export const timeout: {
8120
8359
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8121
8360
  *
8122
8361
  * @example
8362
+ * ```ts
8123
8363
  * import { Effect } from "effect"
8124
8364
  *
8125
8365
  * const task = Effect.gen(function* () {
@@ -8145,6 +8385,7 @@ export const timeout: {
8145
8385
  * // failure: { _tag: 'TimeoutException' }
8146
8386
  * // }
8147
8387
  * // }
8388
+ * ```
8148
8389
  *
8149
8390
  * @since 2.0.0
8150
8391
  * @category delays & timeouts
@@ -8172,6 +8413,7 @@ export const timeout: {
8172
8413
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8173
8414
  *
8174
8415
  * @example
8416
+ * ```ts
8175
8417
  * import { Effect } from "effect"
8176
8418
  *
8177
8419
  * const task = Effect.gen(function* () {
@@ -8195,6 +8437,7 @@ export const timeout: {
8195
8437
  * // { _id: 'Option', _tag: 'Some', value: 'Result' },
8196
8438
  * // { _id: 'Option', _tag: 'None' }
8197
8439
  * // ]
8440
+ * ```
8198
8441
  *
8199
8442
  * @since 3.1.0
8200
8443
  * @category delays & timeouts
@@ -8220,6 +8463,7 @@ export const timeoutOption: {
8220
8463
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8221
8464
  *
8222
8465
  * @example
8466
+ * ```ts
8223
8467
  * import { Effect } from "effect"
8224
8468
  *
8225
8469
  * const task = Effect.gen(function* () {
@@ -8243,6 +8487,7 @@ export const timeoutOption: {
8243
8487
  * // { _id: 'Option', _tag: 'Some', value: 'Result' },
8244
8488
  * // { _id: 'Option', _tag: 'None' }
8245
8489
  * // ]
8490
+ * ```
8246
8491
  *
8247
8492
  * @since 3.1.0
8248
8493
  * @category delays & timeouts
@@ -8268,6 +8513,7 @@ export const timeoutOption: {
8268
8513
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8269
8514
  *
8270
8515
  * @example
8516
+ * ```ts
8271
8517
  * import { Effect } from "effect"
8272
8518
  *
8273
8519
  * const task = Effect.gen(function* () {
@@ -8291,6 +8537,7 @@ export const timeoutOption: {
8291
8537
  * // { _id: 'Option', _tag: 'Some', value: 'Result' },
8292
8538
  * // { _id: 'Option', _tag: 'None' }
8293
8539
  * // ]
8540
+ * ```
8294
8541
  *
8295
8542
  * @since 3.1.0
8296
8543
  * @category delays & timeouts
@@ -8317,6 +8564,7 @@ export const timeoutOption: {
8317
8564
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8318
8565
  *
8319
8566
  * @example
8567
+ * ```ts
8320
8568
  * import { Effect } from "effect"
8321
8569
  *
8322
8570
  * const task = Effect.gen(function* () {
@@ -8349,6 +8597,7 @@ export const timeoutOption: {
8349
8597
  * // failure: MyTimeoutError { _tag: 'MyTimeoutError' }
8350
8598
  * // }
8351
8599
  * // }
8600
+ * ```
8352
8601
  *
8353
8602
  * @since 2.0.0
8354
8603
  * @category delays & timeouts
@@ -8373,6 +8622,7 @@ export const timeoutFail: {
8373
8622
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8374
8623
  *
8375
8624
  * @example
8625
+ * ```ts
8376
8626
  * import { Effect } from "effect"
8377
8627
  *
8378
8628
  * const task = Effect.gen(function* () {
@@ -8405,6 +8655,7 @@ export const timeoutFail: {
8405
8655
  * // failure: MyTimeoutError { _tag: 'MyTimeoutError' }
8406
8656
  * // }
8407
8657
  * // }
8658
+ * ```
8408
8659
  *
8409
8660
  * @since 2.0.0
8410
8661
  * @category delays & timeouts
@@ -8431,6 +8682,7 @@ export const timeoutFail: {
8431
8682
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8432
8683
  *
8433
8684
  * @example
8685
+ * ```ts
8434
8686
  * import { Effect } from "effect"
8435
8687
  *
8436
8688
  * const task = Effect.gen(function* () {
@@ -8463,6 +8715,7 @@ export const timeoutFail: {
8463
8715
  * // failure: MyTimeoutError { _tag: 'MyTimeoutError' }
8464
8716
  * // }
8465
8717
  * // }
8718
+ * ```
8466
8719
  *
8467
8720
  * @since 2.0.0
8468
8721
  * @category delays & timeouts
@@ -8491,6 +8744,7 @@ export const timeoutFail: {
8491
8744
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8492
8745
  *
8493
8746
  * @example
8747
+ * ```ts
8494
8748
  * import { Effect, Cause } from "effect"
8495
8749
  *
8496
8750
  * const task = Effect.gen(function* () {
@@ -8515,6 +8769,7 @@ export const timeoutFail: {
8515
8769
  * // _tag: 'Failure',
8516
8770
  * // cause: { _id: 'Cause', _tag: 'Die', defect: 'Timed out!' }
8517
8771
  * // }
8772
+ * ```
8518
8773
  *
8519
8774
  * @since 2.0.0
8520
8775
  * @category delays & timeouts
@@ -8538,6 +8793,7 @@ export const timeoutFailCause: {
8538
8793
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8539
8794
  *
8540
8795
  * @example
8796
+ * ```ts
8541
8797
  * import { Effect, Cause } from "effect"
8542
8798
  *
8543
8799
  * const task = Effect.gen(function* () {
@@ -8562,6 +8818,7 @@ export const timeoutFailCause: {
8562
8818
  * // _tag: 'Failure',
8563
8819
  * // cause: { _id: 'Cause', _tag: 'Die', defect: 'Timed out!' }
8564
8820
  * // }
8821
+ * ```
8565
8822
  *
8566
8823
  * @since 2.0.0
8567
8824
  * @category delays & timeouts
@@ -8587,6 +8844,7 @@ export const timeoutFailCause: {
8587
8844
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
8588
8845
  *
8589
8846
  * @example
8847
+ * ```ts
8590
8848
  * import { Effect, Cause } from "effect"
8591
8849
  *
8592
8850
  * const task = Effect.gen(function* () {
@@ -8611,6 +8869,7 @@ export const timeoutFailCause: {
8611
8869
  * // _tag: 'Failure',
8612
8870
  * // cause: { _id: 'Cause', _tag: 'Die', defect: 'Timed out!' }
8613
8871
  * // }
8872
+ * ```
8614
8873
  *
8615
8874
  * @since 2.0.0
8616
8875
  * @category delays & timeouts
@@ -8643,6 +8902,7 @@ export const timeoutFailCause: {
8643
8902
  * @see {@link timeoutFailCause} for a version that raises a custom defect.
8644
8903
  *
8645
8904
  * @example
8905
+ * ```ts
8646
8906
  * import { Effect, Either } from "effect"
8647
8907
  *
8648
8908
  * const task = Effect.gen(function* () {
@@ -8670,6 +8930,7 @@ export const timeoutFailCause: {
8670
8930
  * // _tag: "Left",
8671
8931
  * // left: "Timed out!"
8672
8932
  * // }
8933
+ * ```
8673
8934
  *
8674
8935
  * @since 2.0.0
8675
8936
  * @category delays & timeouts
@@ -8697,6 +8958,7 @@ export const timeoutTo: {
8697
8958
  * @see {@link timeoutFailCause} for a version that raises a custom defect.
8698
8959
  *
8699
8960
  * @example
8961
+ * ```ts
8700
8962
  * import { Effect, Either } from "effect"
8701
8963
  *
8702
8964
  * const task = Effect.gen(function* () {
@@ -8724,6 +8986,7 @@ export const timeoutTo: {
8724
8986
  * // _tag: "Left",
8725
8987
  * // left: "Timed out!"
8726
8988
  * // }
8989
+ * ```
8727
8990
  *
8728
8991
  * @since 2.0.0
8729
8992
  * @category delays & timeouts
@@ -8757,6 +9020,7 @@ export const timeoutTo: {
8757
9020
  * @see {@link timeoutFailCause} for a version that raises a custom defect.
8758
9021
  *
8759
9022
  * @example
9023
+ * ```ts
8760
9024
  * import { Effect, Either } from "effect"
8761
9025
  *
8762
9026
  * const task = Effect.gen(function* () {
@@ -8784,6 +9048,7 @@ export const timeoutTo: {
8784
9048
  * // _tag: "Left",
8785
9049
  * // left: "Timed out!"
8786
9050
  * // }
9051
+ * ```
8787
9052
  *
8788
9053
  * @since 2.0.0
8789
9054
  * @category delays & timeouts
@@ -8905,6 +9170,7 @@ export const mapInputContext: {
8905
9170
  * @see {@link provideService} for providing a service to an effect.
8906
9171
  *
8907
9172
  * @example
9173
+ * ```ts
8908
9174
  * import { Context, Effect, Layer } from "effect"
8909
9175
  *
8910
9176
  * class Database extends Context.Tag("Database")<
@@ -8936,6 +9202,7 @@ export const mapInputContext: {
8936
9202
  * // Output:
8937
9203
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
8938
9204
  * // []
9205
+ * ```
8939
9206
  *
8940
9207
  * @since 2.0.0
8941
9208
  * @category Context
@@ -8951,6 +9218,7 @@ export const provide: {
8951
9218
  * @see {@link provideService} for providing a service to an effect.
8952
9219
  *
8953
9220
  * @example
9221
+ * ```ts
8954
9222
  * import { Context, Effect, Layer } from "effect"
8955
9223
  *
8956
9224
  * class Database extends Context.Tag("Database")<
@@ -8982,6 +9250,7 @@ export const provide: {
8982
9250
  * // Output:
8983
9251
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
8984
9252
  * // []
9253
+ * ```
8985
9254
  *
8986
9255
  * @since 2.0.0
8987
9256
  * @category Context
@@ -9004,6 +9273,7 @@ export const provide: {
9004
9273
  * @see {@link provideService} for providing a service to an effect.
9005
9274
  *
9006
9275
  * @example
9276
+ * ```ts
9007
9277
  * import { Context, Effect, Layer } from "effect"
9008
9278
  *
9009
9279
  * class Database extends Context.Tag("Database")<
@@ -9035,6 +9305,7 @@ export const provide: {
9035
9305
  * // Output:
9036
9306
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9037
9307
  * // []
9308
+ * ```
9038
9309
  *
9039
9310
  * @since 2.0.0
9040
9311
  * @category Context
@@ -9052,6 +9323,7 @@ export const provide: {
9052
9323
  * @see {@link provideService} for providing a service to an effect.
9053
9324
  *
9054
9325
  * @example
9326
+ * ```ts
9055
9327
  * import { Context, Effect, Layer } from "effect"
9056
9328
  *
9057
9329
  * class Database extends Context.Tag("Database")<
@@ -9083,6 +9355,7 @@ export const provide: {
9083
9355
  * // Output:
9084
9356
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9085
9357
  * // []
9358
+ * ```
9086
9359
  *
9087
9360
  * @since 2.0.0
9088
9361
  * @category Context
@@ -9098,6 +9371,7 @@ export const provide: {
9098
9371
  * @see {@link provideService} for providing a service to an effect.
9099
9372
  *
9100
9373
  * @example
9374
+ * ```ts
9101
9375
  * import { Context, Effect, Layer } from "effect"
9102
9376
  *
9103
9377
  * class Database extends Context.Tag("Database")<
@@ -9129,6 +9403,7 @@ export const provide: {
9129
9403
  * // Output:
9130
9404
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9131
9405
  * // []
9406
+ * ```
9132
9407
  *
9133
9408
  * @since 2.0.0
9134
9409
  * @category Context
@@ -9144,6 +9419,7 @@ export const provide: {
9144
9419
  * @see {@link provideService} for providing a service to an effect.
9145
9420
  *
9146
9421
  * @example
9422
+ * ```ts
9147
9423
  * import { Context, Effect, Layer } from "effect"
9148
9424
  *
9149
9425
  * class Database extends Context.Tag("Database")<
@@ -9175,6 +9451,7 @@ export const provide: {
9175
9451
  * // Output:
9176
9452
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9177
9453
  * // []
9454
+ * ```
9178
9455
  *
9179
9456
  * @since 2.0.0
9180
9457
  * @category Context
@@ -9192,6 +9469,7 @@ export const provide: {
9192
9469
  * @see {@link provideService} for providing a service to an effect.
9193
9470
  *
9194
9471
  * @example
9472
+ * ```ts
9195
9473
  * import { Context, Effect, Layer } from "effect"
9196
9474
  *
9197
9475
  * class Database extends Context.Tag("Database")<
@@ -9223,6 +9501,7 @@ export const provide: {
9223
9501
  * // Output:
9224
9502
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9225
9503
  * // []
9504
+ * ```
9226
9505
  *
9227
9506
  * @since 2.0.0
9228
9507
  * @category Context
@@ -9246,6 +9525,7 @@ export const provide: {
9246
9525
  * @see {@link provideService} for providing a service to an effect.
9247
9526
  *
9248
9527
  * @example
9528
+ * ```ts
9249
9529
  * import { Context, Effect, Layer } from "effect"
9250
9530
  *
9251
9531
  * class Database extends Context.Tag("Database")<
@@ -9277,6 +9557,7 @@ export const provide: {
9277
9557
  * // Output:
9278
9558
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9279
9559
  * // []
9560
+ * ```
9280
9561
  *
9281
9562
  * @since 2.0.0
9282
9563
  * @category Context
@@ -9295,6 +9576,7 @@ export const provide: {
9295
9576
  * @see {@link provideService} for providing a service to an effect.
9296
9577
  *
9297
9578
  * @example
9579
+ * ```ts
9298
9580
  * import { Context, Effect, Layer } from "effect"
9299
9581
  *
9300
9582
  * class Database extends Context.Tag("Database")<
@@ -9326,6 +9608,7 @@ export const provide: {
9326
9608
  * // Output:
9327
9609
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9328
9610
  * // []
9611
+ * ```
9329
9612
  *
9330
9613
  * @since 2.0.0
9331
9614
  * @category Context
@@ -9341,6 +9624,7 @@ export const provide: {
9341
9624
  * @see {@link provideService} for providing a service to an effect.
9342
9625
  *
9343
9626
  * @example
9627
+ * ```ts
9344
9628
  * import { Context, Effect, Layer } from "effect"
9345
9629
  *
9346
9630
  * class Database extends Context.Tag("Database")<
@@ -9372,6 +9656,7 @@ export const provide: {
9372
9656
  * // Output:
9373
9657
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9374
9658
  * // []
9659
+ * ```
9375
9660
  *
9376
9661
  * @since 2.0.0
9377
9662
  * @category Context
@@ -9387,6 +9672,7 @@ export const provide: {
9387
9672
  * @see {@link provideService} for providing a service to an effect.
9388
9673
  *
9389
9674
  * @example
9675
+ * ```ts
9390
9676
  * import { Context, Effect, Layer } from "effect"
9391
9677
  *
9392
9678
  * class Database extends Context.Tag("Database")<
@@ -9418,6 +9704,7 @@ export const provide: {
9418
9704
  * // Output:
9419
9705
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
9420
9706
  * // []
9707
+ * ```
9421
9708
  *
9422
9709
  * @since 2.0.0
9423
9710
  * @category Context
@@ -9441,6 +9728,7 @@ export const provide: {
9441
9728
  * @see {@link provide} for providing multiple layers to an effect.
9442
9729
  *
9443
9730
  * @example
9731
+ * ```ts
9444
9732
  * import { Effect, Context } from "effect"
9445
9733
  *
9446
9734
  * // Declaring a tag for a service that generates random numbers
@@ -9468,6 +9756,7 @@ export const provide: {
9468
9756
  * Effect.runPromise(runnable)
9469
9757
  * // Example Output:
9470
9758
  * // random number: 0.8241872233134417
9759
+ * ```
9471
9760
  *
9472
9761
  * @since 2.0.0
9473
9762
  * @category Context
@@ -9486,6 +9775,7 @@ export const provideService: {
9486
9775
  * @see {@link provide} for providing multiple layers to an effect.
9487
9776
  *
9488
9777
  * @example
9778
+ * ```ts
9489
9779
  * import { Effect, Context } from "effect"
9490
9780
  *
9491
9781
  * // Declaring a tag for a service that generates random numbers
@@ -9513,6 +9803,7 @@ export const provideService: {
9513
9803
  * Effect.runPromise(runnable)
9514
9804
  * // Example Output:
9515
9805
  * // random number: 0.8241872233134417
9806
+ * ```
9516
9807
  *
9517
9808
  * @since 2.0.0
9518
9809
  * @category Context
@@ -9534,6 +9825,7 @@ export const provideService: {
9534
9825
  * @see {@link provide} for providing multiple layers to an effect.
9535
9826
  *
9536
9827
  * @example
9828
+ * ```ts
9537
9829
  * import { Effect, Context } from "effect"
9538
9830
  *
9539
9831
  * // Declaring a tag for a service that generates random numbers
@@ -9561,6 +9853,7 @@ export const provideService: {
9561
9853
  * Effect.runPromise(runnable)
9562
9854
  * // Example Output:
9563
9855
  * // random number: 0.8241872233134417
9856
+ * ```
9564
9857
  *
9565
9858
  * @since 2.0.0
9566
9859
  * @category Context
@@ -9722,6 +10015,7 @@ export const updateService: {
9722
10015
  * @see {@link let_ let}
9723
10016
  *
9724
10017
  * @example
10018
+ * ```ts
9725
10019
  * import { Effect, pipe } from "effect"
9726
10020
  *
9727
10021
  * const result = pipe(
@@ -9731,6 +10025,7 @@ export const updateService: {
9731
10025
  * Effect.let("sum", ({ x, y }) => x + y)
9732
10026
  * )
9733
10027
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
10028
+ * ```
9734
10029
  *
9735
10030
  * @category Do notation
9736
10031
  * @since 2.0.0
@@ -9752,6 +10047,7 @@ export const Do: Effect<{}> = effect.Do
9752
10047
  * @see {@link let_ let}
9753
10048
  *
9754
10049
  * @example
10050
+ * ```ts
9755
10051
  * import { Effect, pipe } from "effect"
9756
10052
  *
9757
10053
  * const result = pipe(
@@ -9761,6 +10057,7 @@ export const Do: Effect<{}> = effect.Do
9761
10057
  * Effect.let("sum", ({ x, y }) => x + y)
9762
10058
  * )
9763
10059
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
10060
+ * ```
9764
10061
  *
9765
10062
  * @category Do notation
9766
10063
  * @since 2.0.0
@@ -9781,6 +10078,7 @@ export const bind: {
9781
10078
  * @see {@link let_ let}
9782
10079
  *
9783
10080
  * @example
10081
+ * ```ts
9784
10082
  * import { Effect, pipe } from "effect"
9785
10083
  *
9786
10084
  * const result = pipe(
@@ -9790,6 +10088,7 @@ export const bind: {
9790
10088
  * Effect.let("sum", ({ x, y }) => x + y)
9791
10089
  * )
9792
10090
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
10091
+ * ```
9793
10092
  *
9794
10093
  * @category Do notation
9795
10094
  * @since 2.0.0
@@ -9813,6 +10112,7 @@ export const bind: {
9813
10112
  * @see {@link let_ let}
9814
10113
  *
9815
10114
  * @example
10115
+ * ```ts
9816
10116
  * import { Effect, pipe } from "effect"
9817
10117
  *
9818
10118
  * const result = pipe(
@@ -9822,6 +10122,7 @@ export const bind: {
9822
10122
  * Effect.let("sum", ({ x, y }) => x + y)
9823
10123
  * )
9824
10124
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
10125
+ * ```
9825
10126
  *
9826
10127
  * @category Do notation
9827
10128
  * @since 2.0.0
@@ -9839,6 +10140,7 @@ export const bind: {
9839
10140
  * results in a Do notation pipeline.
9840
10141
  *
9841
10142
  * @example
10143
+ * ```ts
9842
10144
  * import { Effect, Either, pipe } from "effect"
9843
10145
  *
9844
10146
  * const result = pipe(
@@ -9850,6 +10152,7 @@ export const bind: {
9850
10152
  * }), { concurrency: 2, mode: "either" })
9851
10153
  * )
9852
10154
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, a: Either.right(2), b: Either.left("oops") })
10155
+ * ```
9853
10156
  *
9854
10157
  * @category Do notation
9855
10158
  * @since 3.7.0
@@ -9861,6 +10164,7 @@ export const bindAll: {
9861
10164
  * results in a Do notation pipeline.
9862
10165
  *
9863
10166
  * @example
10167
+ * ```ts
9864
10168
  * import { Effect, Either, pipe } from "effect"
9865
10169
  *
9866
10170
  * const result = pipe(
@@ -9872,6 +10176,7 @@ export const bindAll: {
9872
10176
  * }), { concurrency: 2, mode: "either" })
9873
10177
  * )
9874
10178
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, a: Either.right(2), b: Either.left("oops") })
10179
+ * ```
9875
10180
  *
9876
10181
  * @category Do notation
9877
10182
  * @since 3.7.0
@@ -9903,6 +10208,7 @@ export const bindAll: {
9903
10208
  * results in a Do notation pipeline.
9904
10209
  *
9905
10210
  * @example
10211
+ * ```ts
9906
10212
  * import { Effect, Either, pipe } from "effect"
9907
10213
  *
9908
10214
  * const result = pipe(
@@ -9914,6 +10220,7 @@ export const bindAll: {
9914
10220
  * }), { concurrency: 2, mode: "either" })
9915
10221
  * )
9916
10222
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, a: Either.right(2), b: Either.left("oops") })
10223
+ * ```
9917
10224
  *
9918
10225
  * @category Do notation
9919
10226
  * @since 3.7.0
@@ -9962,6 +10269,7 @@ export const bindAll: {
9962
10269
  * @see {@link let_ let}
9963
10270
  *
9964
10271
  * @example
10272
+ * ```ts
9965
10273
  * import { Effect, pipe } from "effect"
9966
10274
  *
9967
10275
  * const result = pipe(
@@ -9971,6 +10279,7 @@ export const bindAll: {
9971
10279
  * Effect.let("sum", ({ x, y }) => x + y)
9972
10280
  * )
9973
10281
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
10282
+ * ```
9974
10283
  *
9975
10284
  * @category Do notation
9976
10285
  * @since 2.0.0
@@ -9991,6 +10300,7 @@ export const bindTo: {
9991
10300
  * @see {@link let_ let}
9992
10301
  *
9993
10302
  * @example
10303
+ * ```ts
9994
10304
  * import { Effect, pipe } from "effect"
9995
10305
  *
9996
10306
  * const result = pipe(
@@ -10000,6 +10310,7 @@ export const bindTo: {
10000
10310
  * Effect.let("sum", ({ x, y }) => x + y)
10001
10311
  * )
10002
10312
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
10313
+ * ```
10003
10314
  *
10004
10315
  * @category Do notation
10005
10316
  * @since 2.0.0
@@ -10020,6 +10331,7 @@ export const bindTo: {
10020
10331
  * @see {@link let_ let}
10021
10332
  *
10022
10333
  * @example
10334
+ * ```ts
10023
10335
  * import { Effect, pipe } from "effect"
10024
10336
  *
10025
10337
  * const result = pipe(
@@ -10029,6 +10341,7 @@ export const bindTo: {
10029
10341
  * Effect.let("sum", ({ x, y }) => x + y)
10030
10342
  * )
10031
10343
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
10344
+ * ```
10032
10345
  *
10033
10346
  * @category Do notation
10034
10347
  * @since 2.0.0
@@ -10064,6 +10377,7 @@ export {
10064
10377
  * @see {@link bindTo}
10065
10378
  *
10066
10379
  * @example
10380
+ * ```ts
10067
10381
  * import { Effect, pipe } from "effect"
10068
10382
  *
10069
10383
  * const result = pipe(
@@ -10074,6 +10388,7 @@ export {
10074
10388
  * )
10075
10389
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
10076
10390
  *
10391
+ * ```
10077
10392
  * @category Do notation
10078
10393
  * @since 2.0.0
10079
10394
  */
@@ -10098,6 +10413,7 @@ export {
10098
10413
  * @see {@link exit} for a version that uses `Exit` instead.
10099
10414
  *
10100
10415
  * @example
10416
+ * ```ts
10101
10417
  * // Title: Using Effect.option to Handle Errors
10102
10418
  * import { Effect } from "effect"
10103
10419
  *
@@ -10130,6 +10446,7 @@ export {
10130
10446
  * // _tag: 'Failure',
10131
10447
  * // cause: { _id: 'Cause', _tag: 'Die', defect: 'Boom!' }
10132
10448
  * // }
10449
+ * ```
10133
10450
  *
10134
10451
  * @since 2.0.0
10135
10452
  * @category Outcome Encapsulation
@@ -10155,6 +10472,7 @@ export const option: <A, E, R>(self: Effect<A, E, R>) => Effect<Option.Option<A>
10155
10472
  * @see {@link exit} for a version that uses `Exit` instead.
10156
10473
  *
10157
10474
  * @example
10475
+ * ```ts
10158
10476
  * import { Effect, Either, Random } from "effect"
10159
10477
  *
10160
10478
  * class HttpError {
@@ -10190,6 +10508,7 @@ export const option: <A, E, R>(self: Effect<A, E, R>) => Effect<Option.Option<A>
10190
10508
  * onRight: (value) => value // Do nothing in case of success
10191
10509
  * })
10192
10510
  * })
10511
+ * ```
10193
10512
  *
10194
10513
  * @since 2.0.0
10195
10514
  * @category Outcome Encapsulation
@@ -10213,6 +10532,7 @@ export const either: <A, E, R>(self: Effect<A, E, R>) => Effect<Either.Either<A,
10213
10532
  * @see {@link either} for a version that uses `Either` instead.
10214
10533
  *
10215
10534
  * @example
10535
+ * ```ts
10216
10536
  * import { Effect, Cause, Console, Exit } from "effect"
10217
10537
  *
10218
10538
  * // Simulating a runtime error
@@ -10244,6 +10564,7 @@ export const either: <A, E, R>(self: Effect<A, E, R>) => Effect<Either.Either<A,
10244
10564
  * // _tag: "Success",
10245
10565
  * // value: undefined
10246
10566
  * // }
10567
+ * ```
10247
10568
  *
10248
10569
  * @since 2.0.0
10249
10570
  * @category Outcome Encapsulation
@@ -10261,6 +10582,7 @@ export const exit: <A, E, R>(self: Effect<A, E, R>) => Effect<Exit.Exit<A, E>, n
10261
10582
  * failure. Additionally, if the effect is interrupted, the `Deferred` will also be interrupted.
10262
10583
  *
10263
10584
  * @example
10585
+ * ```ts
10264
10586
  * import { Deferred, Effect } from "effect"
10265
10587
  *
10266
10588
  * // Define an effect that succeeds
@@ -10284,6 +10606,7 @@ export const exit: <A, E, R>(self: Effect<A, E, R>) => Effect<Exit.Exit<A, E>, n
10284
10606
  * // Output:
10285
10607
  * // 42
10286
10608
  * // true
10609
+ * ```
10287
10610
  *
10288
10611
  * @since 2.0.0
10289
10612
  * @category Synchronization Utilities
@@ -10300,6 +10623,7 @@ export const intoDeferred: {
10300
10623
  * failure. Additionally, if the effect is interrupted, the `Deferred` will also be interrupted.
10301
10624
  *
10302
10625
  * @example
10626
+ * ```ts
10303
10627
  * import { Deferred, Effect } from "effect"
10304
10628
  *
10305
10629
  * // Define an effect that succeeds
@@ -10323,6 +10647,7 @@ export const intoDeferred: {
10323
10647
  * // Output:
10324
10648
  * // 42
10325
10649
  * // true
10650
+ * ```
10326
10651
  *
10327
10652
  * @since 2.0.0
10328
10653
  * @category Synchronization Utilities
@@ -10339,6 +10664,7 @@ export const intoDeferred: {
10339
10664
  * failure. Additionally, if the effect is interrupted, the `Deferred` will also be interrupted.
10340
10665
  *
10341
10666
  * @example
10667
+ * ```ts
10342
10668
  * import { Deferred, Effect } from "effect"
10343
10669
  *
10344
10670
  * // Define an effect that succeeds
@@ -10362,6 +10688,7 @@ export const intoDeferred: {
10362
10688
  * // Output:
10363
10689
  * // 42
10364
10690
  * // true
10691
+ * ```
10365
10692
  *
10366
10693
  * @since 2.0.0
10367
10694
  * @category Synchronization Utilities
@@ -10388,6 +10715,7 @@ export {
10388
10715
  * is executed. If it is `false`, the `onFalse` effect is executed instead.
10389
10716
  *
10390
10717
  * @example
10718
+ * ```ts
10391
10719
  * // Title: Simulating a Coin Flip
10392
10720
  * import { Effect, Random, Console } from "effect"
10393
10721
  *
@@ -10398,6 +10726,7 @@ export {
10398
10726
  *
10399
10727
  * Effect.runFork(flipTheCoin)
10400
10728
  *
10729
+ * ```
10401
10730
  * @since 2.0.0
10402
10731
  * @category Conditional Operators
10403
10732
  */
@@ -10572,6 +10901,7 @@ export const filterOrElse: {
10572
10901
  * Let's explore this concept through an example:
10573
10902
  *
10574
10903
  * @example
10904
+ * ```ts
10575
10905
  * import { Effect, pipe } from "effect"
10576
10906
  *
10577
10907
  * // Define a user interface
@@ -10592,6 +10922,7 @@ export const filterOrElse: {
10592
10922
  * // 'user' now has the type `User` (not `User | null`)
10593
10923
  * Effect.andThen((user) => user.name)
10594
10924
  * )
10925
+ * ```
10595
10926
  *
10596
10927
  * @since 2.0.0
10597
10928
  * @category Filtering
@@ -10608,6 +10939,7 @@ export const filterOrFail: {
10608
10939
  * Let's explore this concept through an example:
10609
10940
  *
10610
10941
  * @example
10942
+ * ```ts
10611
10943
  * import { Effect, pipe } from "effect"
10612
10944
  *
10613
10945
  * // Define a user interface
@@ -10628,6 +10960,7 @@ export const filterOrFail: {
10628
10960
  * // 'user' now has the type `User` (not `User | null`)
10629
10961
  * Effect.andThen((user) => user.name)
10630
10962
  * )
10963
+ * ```
10631
10964
  *
10632
10965
  * @since 2.0.0
10633
10966
  * @category Filtering
@@ -10647,6 +10980,7 @@ export const filterOrFail: {
10647
10980
  * Let's explore this concept through an example:
10648
10981
  *
10649
10982
  * @example
10983
+ * ```ts
10650
10984
  * import { Effect, pipe } from "effect"
10651
10985
  *
10652
10986
  * // Define a user interface
@@ -10667,6 +11001,7 @@ export const filterOrFail: {
10667
11001
  * // 'user' now has the type `User` (not `User | null`)
10668
11002
  * Effect.andThen((user) => user.name)
10669
11003
  * )
11004
+ * ```
10670
11005
  *
10671
11006
  * @since 2.0.0
10672
11007
  * @category Filtering
@@ -10686,6 +11021,7 @@ export const filterOrFail: {
10686
11021
  * Let's explore this concept through an example:
10687
11022
  *
10688
11023
  * @example
11024
+ * ```ts
10689
11025
  * import { Effect, pipe } from "effect"
10690
11026
  *
10691
11027
  * // Define a user interface
@@ -10706,6 +11042,7 @@ export const filterOrFail: {
10706
11042
  * // 'user' now has the type `User` (not `User | null`)
10707
11043
  * Effect.andThen((user) => user.name)
10708
11044
  * )
11045
+ * ```
10709
11046
  *
10710
11047
  * @since 2.0.0
10711
11048
  * @category Filtering
@@ -10724,6 +11061,7 @@ export const filterOrFail: {
10724
11061
  * Let's explore this concept through an example:
10725
11062
  *
10726
11063
  * @example
11064
+ * ```ts
10727
11065
  * import { Effect, pipe } from "effect"
10728
11066
  *
10729
11067
  * // Define a user interface
@@ -10744,6 +11082,7 @@ export const filterOrFail: {
10744
11082
  * // 'user' now has the type `User` (not `User | null`)
10745
11083
  * Effect.andThen((user) => user.name)
10746
11084
  * )
11085
+ * ```
10747
11086
  *
10748
11087
  * @since 2.0.0
10749
11088
  * @category Filtering
@@ -10760,6 +11099,7 @@ export const filterOrFail: {
10760
11099
  * Let's explore this concept through an example:
10761
11100
  *
10762
11101
  * @example
11102
+ * ```ts
10763
11103
  * import { Effect, pipe } from "effect"
10764
11104
  *
10765
11105
  * // Define a user interface
@@ -10780,6 +11120,7 @@ export const filterOrFail: {
10780
11120
  * // 'user' now has the type `User` (not `User | null`)
10781
11121
  * Effect.andThen((user) => user.name)
10782
11122
  * )
11123
+ * ```
10783
11124
  *
10784
11125
  * @since 2.0.0
10785
11126
  * @category Filtering
@@ -10800,6 +11141,7 @@ export const filterOrFail: {
10800
11141
  * Let's explore this concept through an example:
10801
11142
  *
10802
11143
  * @example
11144
+ * ```ts
10803
11145
  * import { Effect, pipe } from "effect"
10804
11146
  *
10805
11147
  * // Define a user interface
@@ -10820,6 +11162,7 @@ export const filterOrFail: {
10820
11162
  * // 'user' now has the type `User` (not `User | null`)
10821
11163
  * Effect.andThen((user) => user.name)
10822
11164
  * )
11165
+ * ```
10823
11166
  *
10824
11167
  * @since 2.0.0
10825
11168
  * @category Filtering
@@ -10836,6 +11179,7 @@ export const filterOrFail: {
10836
11179
  * Let's explore this concept through an example:
10837
11180
  *
10838
11181
  * @example
11182
+ * ```ts
10839
11183
  * import { Effect, pipe } from "effect"
10840
11184
  *
10841
11185
  * // Define a user interface
@@ -10856,6 +11200,7 @@ export const filterOrFail: {
10856
11200
  * // 'user' now has the type `User` (not `User | null`)
10857
11201
  * Effect.andThen((user) => user.name)
10858
11202
  * )
11203
+ * ```
10859
11204
  *
10860
11205
  * @since 2.0.0
10861
11206
  * @category Filtering
@@ -10875,6 +11220,7 @@ export const filterOrFail: {
10875
11220
  * Let's explore this concept through an example:
10876
11221
  *
10877
11222
  * @example
11223
+ * ```ts
10878
11224
  * import { Effect, pipe } from "effect"
10879
11225
  *
10880
11226
  * // Define a user interface
@@ -10895,6 +11241,7 @@ export const filterOrFail: {
10895
11241
  * // 'user' now has the type `User` (not `User | null`)
10896
11242
  * Effect.andThen((user) => user.name)
10897
11243
  * )
11244
+ * ```
10898
11245
  *
10899
11246
  * @since 2.0.0
10900
11247
  * @category Filtering
@@ -10990,6 +11337,7 @@ export const unlessEffect: {
10990
11337
  * @see {@link unless} for a version that executes the effect when the condition is `false`.
10991
11338
  *
10992
11339
  * @example
11340
+ * ```ts
10993
11341
  * // Title: Conditional Effect Execution
10994
11342
  * import { Effect, Option } from "effect"
10995
11343
  *
@@ -11015,6 +11363,7 @@ export const unlessEffect: {
11015
11363
  * // _id: "Option",
11016
11364
  * // _tag: "None"
11017
11365
  * // }
11366
+ * ```
11018
11367
  *
11019
11368
  * @since 2.0.0
11020
11369
  * @category Conditional Operators
@@ -11036,6 +11385,7 @@ export const when: {
11036
11385
  * @see {@link unless} for a version that executes the effect when the condition is `false`.
11037
11386
  *
11038
11387
  * @example
11388
+ * ```ts
11039
11389
  * // Title: Conditional Effect Execution
11040
11390
  * import { Effect, Option } from "effect"
11041
11391
  *
@@ -11061,6 +11411,7 @@ export const when: {
11061
11411
  * // _id: "Option",
11062
11412
  * // _tag: "None"
11063
11413
  * // }
11414
+ * ```
11064
11415
  *
11065
11416
  * @since 2.0.0
11066
11417
  * @category Conditional Operators
@@ -11082,6 +11433,7 @@ export const when: {
11082
11433
  * @see {@link unless} for a version that executes the effect when the condition is `false`.
11083
11434
  *
11084
11435
  * @example
11436
+ * ```ts
11085
11437
  * // Title: Conditional Effect Execution
11086
11438
  * import { Effect, Option } from "effect"
11087
11439
  *
@@ -11107,6 +11459,7 @@ export const when: {
11107
11459
  * // _id: "Option",
11108
11460
  * // _tag: "None"
11109
11461
  * // }
11462
+ * ```
11110
11463
  *
11111
11464
  * @since 2.0.0
11112
11465
  * @category Conditional Operators
@@ -11132,6 +11485,7 @@ export const when: {
11132
11485
  * @see {@link unlessEffect} for a version that executes the effect when the condition is `false`.
11133
11486
  *
11134
11487
  * @example
11488
+ * ```ts
11135
11489
  * // Title: Using an Effect as a Condition
11136
11490
  * import { Effect, Random } from "effect"
11137
11491
  *
@@ -11142,6 +11496,7 @@ export const when: {
11142
11496
  * console.log(Effect.runSync(randomIntOption))
11143
11497
  * // Example Output:
11144
11498
  * // { _id: 'Option', _tag: 'Some', value: 8609104974198840 }
11499
+ * ```
11145
11500
  *
11146
11501
  * @since 2.0.0
11147
11502
  * @category Conditional Operators
@@ -11165,6 +11520,7 @@ export const whenEffect: {
11165
11520
  * @see {@link unlessEffect} for a version that executes the effect when the condition is `false`.
11166
11521
  *
11167
11522
  * @example
11523
+ * ```ts
11168
11524
  * // Title: Using an Effect as a Condition
11169
11525
  * import { Effect, Random } from "effect"
11170
11526
  *
@@ -11175,6 +11531,7 @@ export const whenEffect: {
11175
11531
  * console.log(Effect.runSync(randomIntOption))
11176
11532
  * // Example Output:
11177
11533
  * // { _id: 'Option', _tag: 'Some', value: 8609104974198840 }
11534
+ * ```
11178
11535
  *
11179
11536
  * @since 2.0.0
11180
11537
  * @category Conditional Operators
@@ -11200,6 +11557,7 @@ export const whenEffect: {
11200
11557
  * @see {@link unlessEffect} for a version that executes the effect when the condition is `false`.
11201
11558
  *
11202
11559
  * @example
11560
+ * ```ts
11203
11561
  * // Title: Using an Effect as a Condition
11204
11562
  * import { Effect, Random } from "effect"
11205
11563
  *
@@ -11210,6 +11568,7 @@ export const whenEffect: {
11210
11568
  * console.log(Effect.runSync(randomIntOption))
11211
11569
  * // Example Output:
11212
11570
  * // { _id: 'Option', _tag: 'Some', value: 8609104974198840 }
11571
+ * ```
11213
11572
  *
11214
11573
  * @since 2.0.0
11215
11574
  * @category Conditional Operators
@@ -11303,6 +11662,7 @@ export const whenRef: {
11303
11662
  * changing the original one.
11304
11663
  *
11305
11664
  * @example
11665
+ * ```ts
11306
11666
  * import { pipe, Effect } from "effect"
11307
11667
  *
11308
11668
  * // Function to apply a discount safely to a transaction amount
@@ -11325,6 +11685,7 @@ export const whenRef: {
11325
11685
  *
11326
11686
  * Effect.runPromise(finalAmount).then(console.log)
11327
11687
  * // Output: 95
11688
+ * ```
11328
11689
  *
11329
11690
  * @since 2.0.0
11330
11691
  * @category sequencing
@@ -11360,6 +11721,7 @@ export const flatMap: {
11360
11721
  * changing the original one.
11361
11722
  *
11362
11723
  * @example
11724
+ * ```ts
11363
11725
  * import { pipe, Effect } from "effect"
11364
11726
  *
11365
11727
  * // Function to apply a discount safely to a transaction amount
@@ -11382,6 +11744,7 @@ export const flatMap: {
11382
11744
  *
11383
11745
  * Effect.runPromise(finalAmount).then(console.log)
11384
11746
  * // Output: 95
11747
+ * ```
11385
11748
  *
11386
11749
  * @since 2.0.0
11387
11750
  * @category sequencing
@@ -11417,6 +11780,7 @@ export const flatMap: {
11417
11780
  * changing the original one.
11418
11781
  *
11419
11782
  * @example
11783
+ * ```ts
11420
11784
  * import { pipe, Effect } from "effect"
11421
11785
  *
11422
11786
  * // Function to apply a discount safely to a transaction amount
@@ -11439,6 +11803,7 @@ export const flatMap: {
11439
11803
  *
11440
11804
  * Effect.runPromise(finalAmount).then(console.log)
11441
11805
  * // Output: 95
11806
+ * ```
11442
11807
  *
11443
11808
  * @since 2.0.0
11444
11809
  * @category sequencing
@@ -11480,6 +11845,7 @@ export const flatMap: {
11480
11845
  * treating them as effects.
11481
11846
  *
11482
11847
  * @example
11848
+ * ```ts
11483
11849
  * // Title: Applying a Discount Based on Fetched Amount
11484
11850
  * import { pipe, Effect } from "effect"
11485
11851
  *
@@ -11514,6 +11880,7 @@ export const flatMap: {
11514
11880
  *
11515
11881
  * Effect.runPromise(result2).then(console.log)
11516
11882
  * // Output: 190
11883
+ * ```
11517
11884
  *
11518
11885
  * @since 2.0.0
11519
11886
  * @category sequencing
@@ -11553,6 +11920,7 @@ export const andThen: {
11553
11920
  * treating them as effects.
11554
11921
  *
11555
11922
  * @example
11923
+ * ```ts
11556
11924
  * // Title: Applying a Discount Based on Fetched Amount
11557
11925
  * import { pipe, Effect } from "effect"
11558
11926
  *
@@ -11587,6 +11955,7 @@ export const andThen: {
11587
11955
  *
11588
11956
  * Effect.runPromise(result2).then(console.log)
11589
11957
  * // Output: 190
11958
+ * ```
11590
11959
  *
11591
11960
  * @since 2.0.0
11592
11961
  * @category sequencing
@@ -11630,6 +11999,7 @@ export const andThen: {
11630
11999
  * treating them as effects.
11631
12000
  *
11632
12001
  * @example
12002
+ * ```ts
11633
12003
  * // Title: Applying a Discount Based on Fetched Amount
11634
12004
  * import { pipe, Effect } from "effect"
11635
12005
  *
@@ -11664,6 +12034,7 @@ export const andThen: {
11664
12034
  *
11665
12035
  * Effect.runPromise(result2).then(console.log)
11666
12036
  * // Output: 190
12037
+ * ```
11667
12038
  *
11668
12039
  * @since 2.0.0
11669
12040
  * @category sequencing
@@ -11707,6 +12078,7 @@ export const andThen: {
11707
12078
  * treating them as effects.
11708
12079
  *
11709
12080
  * @example
12081
+ * ```ts
11710
12082
  * // Title: Applying a Discount Based on Fetched Amount
11711
12083
  * import { pipe, Effect } from "effect"
11712
12084
  *
@@ -11741,6 +12113,7 @@ export const andThen: {
11741
12113
  *
11742
12114
  * Effect.runPromise(result2).then(console.log)
11743
12115
  * // Output: 190
12116
+ * ```
11744
12117
  *
11745
12118
  * @since 2.0.0
11746
12119
  * @category sequencing
@@ -11785,6 +12158,7 @@ export const andThen: {
11785
12158
  * treating them as effects.
11786
12159
  *
11787
12160
  * @example
12161
+ * ```ts
11788
12162
  * // Title: Applying a Discount Based on Fetched Amount
11789
12163
  * import { pipe, Effect } from "effect"
11790
12164
  *
@@ -11819,6 +12193,7 @@ export const andThen: {
11819
12193
  *
11820
12194
  * Effect.runPromise(result2).then(console.log)
11821
12195
  * // Output: 190
12196
+ * ```
11822
12197
  *
11823
12198
  * @since 2.0.0
11824
12199
  * @category sequencing
@@ -12025,6 +12400,7 @@ export const summarized: {
12025
12400
  * will fail too.
12026
12401
  *
12027
12402
  * @example
12403
+ * ```ts
12028
12404
  * // Title: Logging a step in a pipeline
12029
12405
  * import { Console, Effect, pipe } from "effect"
12030
12406
  *
@@ -12052,6 +12428,7 @@ export const summarized: {
12052
12428
  * // Output:
12053
12429
  * // Apply a discount to: 100
12054
12430
  * // 95
12431
+ * ```
12055
12432
  *
12056
12433
  * @since 2.0.0
12057
12434
  * @category sequencing
@@ -12075,6 +12452,7 @@ export const tap: {
12075
12452
  * will fail too.
12076
12453
  *
12077
12454
  * @example
12455
+ * ```ts
12078
12456
  * // Title: Logging a step in a pipeline
12079
12457
  * import { Console, Effect, pipe } from "effect"
12080
12458
  *
@@ -12102,6 +12480,7 @@ export const tap: {
12102
12480
  * // Output:
12103
12481
  * // Apply a discount to: 100
12104
12482
  * // 95
12483
+ * ```
12105
12484
  *
12106
12485
  * @since 2.0.0
12107
12486
  * @category sequencing
@@ -12129,6 +12508,7 @@ export const tap: {
12129
12508
  * will fail too.
12130
12509
  *
12131
12510
  * @example
12511
+ * ```ts
12132
12512
  * // Title: Logging a step in a pipeline
12133
12513
  * import { Console, Effect, pipe } from "effect"
12134
12514
  *
@@ -12156,6 +12536,7 @@ export const tap: {
12156
12536
  * // Output:
12157
12537
  * // Apply a discount to: 100
12158
12538
  * // 95
12539
+ * ```
12159
12540
  *
12160
12541
  * @since 2.0.0
12161
12542
  * @category sequencing
@@ -12181,6 +12562,7 @@ export const tap: {
12181
12562
  * will fail too.
12182
12563
  *
12183
12564
  * @example
12565
+ * ```ts
12184
12566
  * // Title: Logging a step in a pipeline
12185
12567
  * import { Console, Effect, pipe } from "effect"
12186
12568
  *
@@ -12208,6 +12590,7 @@ export const tap: {
12208
12590
  * // Output:
12209
12591
  * // Apply a discount to: 100
12210
12592
  * // 95
12593
+ * ```
12211
12594
  *
12212
12595
  * @since 2.0.0
12213
12596
  * @category sequencing
@@ -12235,6 +12618,7 @@ export const tap: {
12235
12618
  * will fail too.
12236
12619
  *
12237
12620
  * @example
12621
+ * ```ts
12238
12622
  * // Title: Logging a step in a pipeline
12239
12623
  * import { Console, Effect, pipe } from "effect"
12240
12624
  *
@@ -12262,6 +12646,7 @@ export const tap: {
12262
12646
  * // Output:
12263
12647
  * // Apply a discount to: 100
12264
12648
  * // 95
12649
+ * ```
12265
12650
  *
12266
12651
  * @since 2.0.0
12267
12652
  * @category sequencing
@@ -12287,6 +12672,7 @@ export const tap: {
12287
12672
  * will fail too.
12288
12673
  *
12289
12674
  * @example
12675
+ * ```ts
12290
12676
  * // Title: Logging a step in a pipeline
12291
12677
  * import { Console, Effect, pipe } from "effect"
12292
12678
  *
@@ -12314,6 +12700,7 @@ export const tap: {
12314
12700
  * // Output:
12315
12701
  * // Apply a discount to: 100
12316
12702
  * // 95
12703
+ * ```
12317
12704
  *
12318
12705
  * @since 2.0.0
12319
12706
  * @category sequencing
@@ -12342,6 +12729,7 @@ export const tap: {
12342
12729
  * will fail too.
12343
12730
  *
12344
12731
  * @example
12732
+ * ```ts
12345
12733
  * // Title: Logging a step in a pipeline
12346
12734
  * import { Console, Effect, pipe } from "effect"
12347
12735
  *
@@ -12369,6 +12757,7 @@ export const tap: {
12369
12757
  * // Output:
12370
12758
  * // Apply a discount to: 100
12371
12759
  * // 95
12760
+ * ```
12372
12761
  *
12373
12762
  * @since 2.0.0
12374
12763
  * @category sequencing
@@ -12396,6 +12785,7 @@ export const tap: {
12396
12785
  * will fail too.
12397
12786
  *
12398
12787
  * @example
12788
+ * ```ts
12399
12789
  * // Title: Logging a step in a pipeline
12400
12790
  * import { Console, Effect, pipe } from "effect"
12401
12791
  *
@@ -12423,6 +12813,7 @@ export const tap: {
12423
12813
  * // Output:
12424
12814
  * // Apply a discount to: 100
12425
12815
  * // 95
12816
+ * ```
12426
12817
  *
12427
12818
  * @since 2.0.0
12428
12819
  * @category sequencing
@@ -12451,6 +12842,7 @@ export const tap: {
12451
12842
  * will fail too.
12452
12843
  *
12453
12844
  * @example
12845
+ * ```ts
12454
12846
  * // Title: Logging a step in a pipeline
12455
12847
  * import { Console, Effect, pipe } from "effect"
12456
12848
  *
@@ -12478,6 +12870,7 @@ export const tap: {
12478
12870
  * // Output:
12479
12871
  * // Apply a discount to: 100
12480
12872
  * // 95
12873
+ * ```
12481
12874
  *
12482
12875
  * @since 2.0.0
12483
12876
  * @category sequencing
@@ -12501,6 +12894,7 @@ export const tap: {
12501
12894
  * altering the result.
12502
12895
  *
12503
12896
  * @example
12897
+ * ```ts
12504
12898
  * import { Effect, Random, Console } from "effect"
12505
12899
  *
12506
12900
  * // Simulate a task that might fail
@@ -12520,6 +12914,7 @@ export const tap: {
12520
12914
  * Effect.runFork(tapping)
12521
12915
  * // Example Output:
12522
12916
  * // failure: random number is negative
12917
+ * ```
12523
12918
  *
12524
12919
  * @since 2.0.0
12525
12920
  * @category sequencing
@@ -12537,6 +12932,7 @@ export const tapBoth: {
12537
12932
  * altering the result.
12538
12933
  *
12539
12934
  * @example
12935
+ * ```ts
12540
12936
  * import { Effect, Random, Console } from "effect"
12541
12937
  *
12542
12938
  * // Simulate a task that might fail
@@ -12556,6 +12952,7 @@ export const tapBoth: {
12556
12952
  * Effect.runFork(tapping)
12557
12953
  * // Example Output:
12558
12954
  * // failure: random number is negative
12955
+ * ```
12559
12956
  *
12560
12957
  * @since 2.0.0
12561
12958
  * @category sequencing
@@ -12578,6 +12975,7 @@ export const tapBoth: {
12578
12975
  * altering the result.
12579
12976
  *
12580
12977
  * @example
12978
+ * ```ts
12581
12979
  * import { Effect, Random, Console } from "effect"
12582
12980
  *
12583
12981
  * // Simulate a task that might fail
@@ -12597,6 +12995,7 @@ export const tapBoth: {
12597
12995
  * Effect.runFork(tapping)
12598
12996
  * // Example Output:
12599
12997
  * // failure: random number is negative
12998
+ * ```
12600
12999
  *
12601
13000
  * @since 2.0.0
12602
13001
  * @category sequencing
@@ -12621,6 +13020,7 @@ export const tapBoth: {
12621
13020
  * severe errors.
12622
13021
  *
12623
13022
  * @example
13023
+ * ```ts
12624
13024
  * import { Effect, Console } from "effect"
12625
13025
  *
12626
13026
  * // Simulate a task that fails with a recoverable error
@@ -12648,6 +13048,7 @@ export const tapBoth: {
12648
13048
  * // Output:
12649
13049
  * // defect: RuntimeException: Something went wrong
12650
13050
  * // ... stack trace ...
13051
+ * ```
12651
13052
  *
12652
13053
  * @since 2.0.0
12653
13054
  * @category sequencing
@@ -12664,6 +13065,7 @@ export const tapDefect: {
12664
13065
  * severe errors.
12665
13066
  *
12666
13067
  * @example
13068
+ * ```ts
12667
13069
  * import { Effect, Console } from "effect"
12668
13070
  *
12669
13071
  * // Simulate a task that fails with a recoverable error
@@ -12691,6 +13093,7 @@ export const tapDefect: {
12691
13093
  * // Output:
12692
13094
  * // defect: RuntimeException: Something went wrong
12693
13095
  * // ... stack trace ...
13096
+ * ```
12694
13097
  *
12695
13098
  * @since 2.0.0
12696
13099
  * @category sequencing
@@ -12709,6 +13112,7 @@ export const tapDefect: {
12709
13112
  * severe errors.
12710
13113
  *
12711
13114
  * @example
13115
+ * ```ts
12712
13116
  * import { Effect, Console } from "effect"
12713
13117
  *
12714
13118
  * // Simulate a task that fails with a recoverable error
@@ -12736,6 +13140,7 @@ export const tapDefect: {
12736
13140
  * // Output:
12737
13141
  * // defect: RuntimeException: Something went wrong
12738
13142
  * // ... stack trace ...
13143
+ * ```
12739
13144
  *
12740
13145
  * @since 2.0.0
12741
13146
  * @category sequencing
@@ -12756,6 +13161,7 @@ export const tapDefect: {
12756
13161
  * while the operation you provide can inspect or act on it.
12757
13162
  *
12758
13163
  * @example
13164
+ * ```ts
12759
13165
  * import { Effect, Console } from "effect"
12760
13166
  *
12761
13167
  * // Simulate a task that fails with an error
@@ -12769,6 +13175,7 @@ export const tapDefect: {
12769
13175
  * Effect.runFork(tapping)
12770
13176
  * // Output:
12771
13177
  * // expected error: NetworkError
13178
+ * ```
12772
13179
  *
12773
13180
  * @since 2.0.0
12774
13181
  * @category sequencing
@@ -12784,6 +13191,7 @@ export const tapError: {
12784
13191
  * while the operation you provide can inspect or act on it.
12785
13192
  *
12786
13193
  * @example
13194
+ * ```ts
12787
13195
  * import { Effect, Console } from "effect"
12788
13196
  *
12789
13197
  * // Simulate a task that fails with an error
@@ -12797,6 +13205,7 @@ export const tapError: {
12797
13205
  * Effect.runFork(tapping)
12798
13206
  * // Output:
12799
13207
  * // expected error: NetworkError
13208
+ * ```
12800
13209
  *
12801
13210
  * @since 2.0.0
12802
13211
  * @category sequencing
@@ -12812,6 +13221,7 @@ export const tapError: {
12812
13221
  * while the operation you provide can inspect or act on it.
12813
13222
  *
12814
13223
  * @example
13224
+ * ```ts
12815
13225
  * import { Effect, Console } from "effect"
12816
13226
  *
12817
13227
  * // Simulate a task that fails with an error
@@ -12825,6 +13235,7 @@ export const tapError: {
12825
13235
  * Effect.runFork(tapping)
12826
13236
  * // Output:
12827
13237
  * // expected error: NetworkError
13238
+ * ```
12828
13239
  *
12829
13240
  * @since 2.0.0
12830
13241
  * @category sequencing
@@ -12842,6 +13253,7 @@ export const tapError: {
12842
13253
  * without modifying the error or the overall result of the effect.
12843
13254
  *
12844
13255
  * @example
13256
+ * ```ts
12845
13257
  * import { Effect, Console } from "effect"
12846
13258
  *
12847
13259
  * class NetworkError {
@@ -12866,6 +13278,7 @@ export const tapError: {
12866
13278
  * Effect.runFork(tapping)
12867
13279
  * // Output:
12868
13280
  * // expected error: 504
13281
+ * ```
12869
13282
  *
12870
13283
  * @since 2.0.0
12871
13284
  * @category sequencing
@@ -12881,6 +13294,7 @@ export const tapErrorTag: {
12881
13294
  * without modifying the error or the overall result of the effect.
12882
13295
  *
12883
13296
  * @example
13297
+ * ```ts
12884
13298
  * import { Effect, Console } from "effect"
12885
13299
  *
12886
13300
  * class NetworkError {
@@ -12905,6 +13319,7 @@ export const tapErrorTag: {
12905
13319
  * Effect.runFork(tapping)
12906
13320
  * // Output:
12907
13321
  * // expected error: 504
13322
+ * ```
12908
13323
  *
12909
13324
  * @since 2.0.0
12910
13325
  * @category sequencing
@@ -12923,6 +13338,7 @@ export const tapErrorTag: {
12923
13338
  * without modifying the error or the overall result of the effect.
12924
13339
  *
12925
13340
  * @example
13341
+ * ```ts
12926
13342
  * import { Effect, Console } from "effect"
12927
13343
  *
12928
13344
  * class NetworkError {
@@ -12947,6 +13363,7 @@ export const tapErrorTag: {
12947
13363
  * Effect.runFork(tapping)
12948
13364
  * // Output:
12949
13365
  * // expected error: 504
13366
+ * ```
12950
13367
  *
12951
13368
  * @since 2.0.0
12952
13369
  * @category sequencing
@@ -12968,6 +13385,7 @@ export const tapErrorTag: {
12968
13385
  * altering the error or the overall result of the effect.
12969
13386
  *
12970
13387
  * @example
13388
+ * ```ts
12971
13389
  * import { Effect, Console } from "effect"
12972
13390
  *
12973
13391
  * // Create a task that fails with a NetworkError
@@ -12994,6 +13412,7 @@ export const tapErrorTag: {
12994
13412
  * // Output:
12995
13413
  * // error cause: RuntimeException: Something went wrong
12996
13414
  * // ... stack trace ...
13415
+ * ```
12997
13416
  *
12998
13417
  * @since 2.0.0
12999
13418
  * @category sequencing
@@ -13009,6 +13428,7 @@ export const tapErrorCause: {
13009
13428
  * altering the error or the overall result of the effect.
13010
13429
  *
13011
13430
  * @example
13431
+ * ```ts
13012
13432
  * import { Effect, Console } from "effect"
13013
13433
  *
13014
13434
  * // Create a task that fails with a NetworkError
@@ -13035,6 +13455,7 @@ export const tapErrorCause: {
13035
13455
  * // Output:
13036
13456
  * // error cause: RuntimeException: Something went wrong
13037
13457
  * // ... stack trace ...
13458
+ * ```
13038
13459
  *
13039
13460
  * @since 2.0.0
13040
13461
  * @category sequencing
@@ -13052,6 +13473,7 @@ export const tapErrorCause: {
13052
13473
  * altering the error or the overall result of the effect.
13053
13474
  *
13054
13475
  * @example
13476
+ * ```ts
13055
13477
  * import { Effect, Console } from "effect"
13056
13478
  *
13057
13479
  * // Create a task that fails with a NetworkError
@@ -13078,6 +13500,7 @@ export const tapErrorCause: {
13078
13500
  * // Output:
13079
13501
  * // error cause: RuntimeException: Something went wrong
13080
13502
  * // ... stack trace ...
13503
+ * ```
13081
13504
  *
13082
13505
  * @since 2.0.0
13083
13506
  * @category sequencing
@@ -13115,6 +13538,7 @@ export const forever: <A, E, R>(self: Effect<A, E, R>) => Effect<never, E, R> =
13115
13538
  * ```
13116
13539
  *
13117
13540
  * @example
13541
+ * ```ts
13118
13542
  * // Title: Effectful Iteration
13119
13543
  * import { Effect } from "effect"
13120
13544
  *
@@ -13131,6 +13555,7 @@ export const forever: <A, E, R>(self: Effect<A, E, R>) => Effect<never, E, R> =
13131
13555
  *
13132
13556
  * Effect.runPromise(result).then(console.log)
13133
13557
  * // Output: 6
13558
+ * ```
13134
13559
  *
13135
13560
  * @since 2.0.0
13136
13561
  * @category Looping
@@ -13155,6 +13580,7 @@ export const iterate: {
13155
13580
  * ```
13156
13581
  *
13157
13582
  * @example
13583
+ * ```ts
13158
13584
  * // Title: Effectful Iteration
13159
13585
  * import { Effect } from "effect"
13160
13586
  *
@@ -13171,6 +13597,7 @@ export const iterate: {
13171
13597
  *
13172
13598
  * Effect.runPromise(result).then(console.log)
13173
13599
  * // Output: 6
13600
+ * ```
13174
13601
  *
13175
13602
  * @since 2.0.0
13176
13603
  * @category Looping
@@ -13201,6 +13628,7 @@ export const iterate: {
13201
13628
  * ```
13202
13629
  *
13203
13630
  * @example
13631
+ * ```ts
13204
13632
  * // Title: Effectful Iteration
13205
13633
  * import { Effect } from "effect"
13206
13634
  *
@@ -13217,6 +13645,7 @@ export const iterate: {
13217
13645
  *
13218
13646
  * Effect.runPromise(result).then(console.log)
13219
13647
  * // Output: 6
13648
+ * ```
13220
13649
  *
13221
13650
  * @since 2.0.0
13222
13651
  * @category Looping
@@ -13257,6 +13686,7 @@ export const iterate: {
13257
13686
  * discarded, and the final result will be `void`.
13258
13687
  *
13259
13688
  * @example
13689
+ * ```ts
13260
13690
  * // Title: Looping with Collected Results
13261
13691
  * import { Effect } from "effect"
13262
13692
  *
@@ -13276,6 +13706,7 @@ export const iterate: {
13276
13706
  *
13277
13707
  * Effect.runPromise(result).then(console.log)
13278
13708
  * // Output: [1, 2, 3, 4, 5]
13709
+ * ```
13279
13710
  *
13280
13711
  * @example
13281
13712
  * // Title: Loop with Discarded Results
@@ -13336,6 +13767,7 @@ export const loop: {
13336
13767
  * discarded, and the final result will be `void`.
13337
13768
  *
13338
13769
  * @example
13770
+ * ```ts
13339
13771
  * // Title: Looping with Collected Results
13340
13772
  * import { Effect } from "effect"
13341
13773
  *
@@ -13355,6 +13787,7 @@ export const loop: {
13355
13787
  *
13356
13788
  * Effect.runPromise(result).then(console.log)
13357
13789
  * // Output: [1, 2, 3, 4, 5]
13790
+ * ```
13358
13791
  *
13359
13792
  * @example
13360
13793
  * // Title: Loop with Discarded Results
@@ -13423,6 +13856,7 @@ export const loop: {
13423
13856
  * discarded, and the final result will be `void`.
13424
13857
  *
13425
13858
  * @example
13859
+ * ```ts
13426
13860
  * // Title: Looping with Collected Results
13427
13861
  * import { Effect } from "effect"
13428
13862
  *
@@ -13442,6 +13876,7 @@ export const loop: {
13442
13876
  *
13443
13877
  * Effect.runPromise(result).then(console.log)
13444
13878
  * // Output: [1, 2, 3, 4, 5]
13879
+ * ```
13445
13880
  *
13446
13881
  * @example
13447
13882
  * // Title: Loop with Discarded Results
@@ -13510,6 +13945,7 @@ export const loop: {
13510
13945
  * discarded, and the final result will be `void`.
13511
13946
  *
13512
13947
  * @example
13948
+ * ```ts
13513
13949
  * // Title: Looping with Collected Results
13514
13950
  * import { Effect } from "effect"
13515
13951
  *
@@ -13529,6 +13965,7 @@ export const loop: {
13529
13965
  *
13530
13966
  * Effect.runPromise(result).then(console.log)
13531
13967
  * // Output: [1, 2, 3, 4, 5]
13968
+ * ```
13532
13969
  *
13533
13970
  * @example
13534
13971
  * // Title: Loop with Discarded Results
@@ -13597,6 +14034,7 @@ export const loop: {
13597
14034
  * discarded, and the final result will be `void`.
13598
14035
  *
13599
14036
  * @example
14037
+ * ```ts
13600
14038
  * // Title: Looping with Collected Results
13601
14039
  * import { Effect } from "effect"
13602
14040
  *
@@ -13616,6 +14054,7 @@ export const loop: {
13616
14054
  *
13617
14055
  * Effect.runPromise(result).then(console.log)
13618
14056
  * // Output: [1, 2, 3, 4, 5]
14057
+ * ```
13619
14058
  *
13620
14059
  * @example
13621
14060
  * // Title: Loop with Discarded Results
@@ -13701,6 +14140,7 @@ export declare namespace Repeat {
13701
14140
  * an additional time.
13702
14141
  *
13703
14142
  * @example
14143
+ * ```ts
13704
14144
  * // Success Example
13705
14145
  * import { Effect, Schedule, Console } from "effect"
13706
14146
  *
@@ -13709,6 +14149,7 @@ export declare namespace Repeat {
13709
14149
  * const program = Effect.repeat(action, policy)
13710
14150
  *
13711
14151
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
14152
+ * ```
13712
14153
  *
13713
14154
  * @example
13714
14155
  * // Failure Example
@@ -13745,6 +14186,7 @@ export const repeat: {
13745
14186
  * an additional time.
13746
14187
  *
13747
14188
  * @example
14189
+ * ```ts
13748
14190
  * // Success Example
13749
14191
  * import { Effect, Schedule, Console } from "effect"
13750
14192
  *
@@ -13753,6 +14195,7 @@ export const repeat: {
13753
14195
  * const program = Effect.repeat(action, policy)
13754
14196
  *
13755
14197
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
14198
+ * ```
13756
14199
  *
13757
14200
  * @example
13758
14201
  * // Failure Example
@@ -13791,6 +14234,7 @@ export const repeat: {
13791
14234
  * an additional time.
13792
14235
  *
13793
14236
  * @example
14237
+ * ```ts
13794
14238
  * // Success Example
13795
14239
  * import { Effect, Schedule, Console } from "effect"
13796
14240
  *
@@ -13799,6 +14243,7 @@ export const repeat: {
13799
14243
  * const program = Effect.repeat(action, policy)
13800
14244
  *
13801
14245
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
14246
+ * ```
13802
14247
  *
13803
14248
  * @example
13804
14249
  * // Failure Example
@@ -13835,6 +14280,7 @@ export const repeat: {
13835
14280
  * an additional time.
13836
14281
  *
13837
14282
  * @example
14283
+ * ```ts
13838
14284
  * // Success Example
13839
14285
  * import { Effect, Schedule, Console } from "effect"
13840
14286
  *
@@ -13843,6 +14289,7 @@ export const repeat: {
13843
14289
  * const program = Effect.repeat(action, policy)
13844
14290
  *
13845
14291
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
14292
+ * ```
13846
14293
  *
13847
14294
  * @example
13848
14295
  * // Failure Example
@@ -13879,6 +14326,7 @@ export const repeat: {
13879
14326
  * an additional time.
13880
14327
  *
13881
14328
  * @example
14329
+ * ```ts
13882
14330
  * // Success Example
13883
14331
  * import { Effect, Schedule, Console } from "effect"
13884
14332
  *
@@ -13887,6 +14335,7 @@ export const repeat: {
13887
14335
  * const program = Effect.repeat(action, policy)
13888
14336
  *
13889
14337
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
14338
+ * ```
13890
14339
  *
13891
14340
  * @example
13892
14341
  * // Failure Example
@@ -13924,12 +14373,14 @@ export const repeat: {
13924
14373
  * initially and then repeats it one additional time if it succeeds.
13925
14374
  *
13926
14375
  * @example
14376
+ * ```ts
13927
14377
  * import { Effect, Console } from "effect"
13928
14378
  *
13929
14379
  * const action = Console.log("success")
13930
14380
  * const program = Effect.repeatN(action, 2)
13931
14381
  *
13932
14382
  * Effect.runPromise(program)
14383
+ * ```
13933
14384
  *
13934
14385
  * @since 2.0.0
13935
14386
  * @category repetition / recursion
@@ -13942,12 +14393,14 @@ export const repeatN: {
13942
14393
  * initially and then repeats it one additional time if it succeeds.
13943
14394
  *
13944
14395
  * @example
14396
+ * ```ts
13945
14397
  * import { Effect, Console } from "effect"
13946
14398
  *
13947
14399
  * const action = Console.log("success")
13948
14400
  * const program = Effect.repeatN(action, 2)
13949
14401
  *
13950
14402
  * Effect.runPromise(program)
14403
+ * ```
13951
14404
  *
13952
14405
  * @since 2.0.0
13953
14406
  * @category repetition / recursion
@@ -13960,12 +14413,14 @@ export const repeatN: {
13960
14413
  * initially and then repeats it one additional time if it succeeds.
13961
14414
  *
13962
14415
  * @example
14416
+ * ```ts
13963
14417
  * import { Effect, Console } from "effect"
13964
14418
  *
13965
14419
  * const action = Console.log("success")
13966
14420
  * const program = Effect.repeatN(action, 2)
13967
14421
  *
13968
14422
  * Effect.runPromise(program)
14423
+ * ```
13969
14424
  *
13970
14425
  * @since 2.0.0
13971
14426
  * @category repetition / recursion
@@ -13982,6 +14437,7 @@ export const repeatN: {
13982
14437
  * initially and then repeats it an additional time if it succeeds.
13983
14438
  *
13984
14439
  * @example
14440
+ * ```ts
13985
14441
  * import { Effect, Schedule } from "effect"
13986
14442
  *
13987
14443
  * let count = 0
@@ -14011,6 +14467,7 @@ export const repeatN: {
14011
14467
  * )
14012
14468
  *
14013
14469
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
14470
+ * ```
14014
14471
  *
14015
14472
  * @since 2.0.0
14016
14473
  * @category repetition / recursion
@@ -14025,6 +14482,7 @@ export const repeatOrElse: {
14025
14482
  * initially and then repeats it an additional time if it succeeds.
14026
14483
  *
14027
14484
  * @example
14485
+ * ```ts
14028
14486
  * import { Effect, Schedule } from "effect"
14029
14487
  *
14030
14488
  * let count = 0
@@ -14054,6 +14512,7 @@ export const repeatOrElse: {
14054
14512
  * )
14055
14513
  *
14056
14514
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
14515
+ * ```
14057
14516
  *
14058
14517
  * @since 2.0.0
14059
14518
  * @category repetition / recursion
@@ -14071,6 +14530,7 @@ export const repeatOrElse: {
14071
14530
  * initially and then repeats it an additional time if it succeeds.
14072
14531
  *
14073
14532
  * @example
14533
+ * ```ts
14074
14534
  * import { Effect, Schedule } from "effect"
14075
14535
  *
14076
14536
  * let count = 0
@@ -14100,6 +14560,7 @@ export const repeatOrElse: {
14100
14560
  * )
14101
14561
  *
14102
14562
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
14563
+ * ```
14103
14564
  *
14104
14565
  * @since 2.0.0
14105
14566
  * @category repetition / recursion
@@ -14362,6 +14823,7 @@ export const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boolean, neve
14362
14823
  * @see {@link matchEffect} if you need to perform side effects in the handlers.
14363
14824
  *
14364
14825
  * @example
14826
+ * ```ts
14365
14827
  * import { Effect } from "effect"
14366
14828
  *
14367
14829
  * const success: Effect.Effect<number, Error> = Effect.succeed(42)
@@ -14387,6 +14849,7 @@ export const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boolean, neve
14387
14849
  * // Run and log the result of the failed effect
14388
14850
  * Effect.runPromise(program2).then(console.log)
14389
14851
  * // Output: "failure: Uh oh!"
14852
+ * ```
14390
14853
  *
14391
14854
  * @since 2.0.0
14392
14855
  * @category getters & folding
@@ -14405,6 +14868,7 @@ export const match: {
14405
14868
  * @see {@link matchEffect} if you need to perform side effects in the handlers.
14406
14869
  *
14407
14870
  * @example
14871
+ * ```ts
14408
14872
  * import { Effect } from "effect"
14409
14873
  *
14410
14874
  * const success: Effect.Effect<number, Error> = Effect.succeed(42)
@@ -14430,6 +14894,7 @@ export const match: {
14430
14894
  * // Run and log the result of the failed effect
14431
14895
  * Effect.runPromise(program2).then(console.log)
14432
14896
  * // Output: "failure: Uh oh!"
14897
+ * ```
14433
14898
  *
14434
14899
  * @since 2.0.0
14435
14900
  * @category getters & folding
@@ -14453,6 +14918,7 @@ export const match: {
14453
14918
  * @see {@link matchEffect} if you need to perform side effects in the handlers.
14454
14919
  *
14455
14920
  * @example
14921
+ * ```ts
14456
14922
  * import { Effect } from "effect"
14457
14923
  *
14458
14924
  * const success: Effect.Effect<number, Error> = Effect.succeed(42)
@@ -14478,6 +14944,7 @@ export const match: {
14478
14944
  * // Run and log the result of the failed effect
14479
14945
  * Effect.runPromise(program2).then(console.log)
14480
14946
  * // Output: "failure: Uh oh!"
14947
+ * ```
14481
14948
  *
14482
14949
  * @since 2.0.0
14483
14950
  * @category getters & folding
@@ -14566,6 +15033,7 @@ export const matchCause: {
14566
15033
  * @see {@link matchEffect} if you don't need to handle the cause of the failure.
14567
15034
  *
14568
15035
  * @example
15036
+ * ```ts
14569
15037
  * import { Effect, Console } from "effect"
14570
15038
  *
14571
15039
  * const task: Effect.Effect<number, Error> = Effect.die("Uh oh!")
@@ -14593,6 +15061,7 @@ export const matchCause: {
14593
15061
  *
14594
15062
  * Effect.runSync(program)
14595
15063
  * // Output: "Die: Uh oh!"
15064
+ * ```
14596
15065
  *
14597
15066
  * @since 2.0.0
14598
15067
  * @category getters & folding
@@ -14612,6 +15081,7 @@ export const matchCauseEffect: {
14612
15081
  * @see {@link matchEffect} if you don't need to handle the cause of the failure.
14613
15082
  *
14614
15083
  * @example
15084
+ * ```ts
14615
15085
  * import { Effect, Console } from "effect"
14616
15086
  *
14617
15087
  * const task: Effect.Effect<number, Error> = Effect.die("Uh oh!")
@@ -14639,6 +15109,7 @@ export const matchCauseEffect: {
14639
15109
  *
14640
15110
  * Effect.runSync(program)
14641
15111
  * // Output: "Die: Uh oh!"
15112
+ * ```
14642
15113
  *
14643
15114
  * @since 2.0.0
14644
15115
  * @category getters & folding
@@ -14663,6 +15134,7 @@ export const matchCauseEffect: {
14663
15134
  * @see {@link matchEffect} if you don't need to handle the cause of the failure.
14664
15135
  *
14665
15136
  * @example
15137
+ * ```ts
14666
15138
  * import { Effect, Console } from "effect"
14667
15139
  *
14668
15140
  * const task: Effect.Effect<number, Error> = Effect.die("Uh oh!")
@@ -14690,6 +15162,7 @@ export const matchCauseEffect: {
14690
15162
  *
14691
15163
  * Effect.runSync(program)
14692
15164
  * // Output: "Die: Uh oh!"
15165
+ * ```
14693
15166
  *
14694
15167
  * @since 2.0.0
14695
15168
  * @category getters & folding
@@ -14771,6 +15244,7 @@ export const matchEffect: {
14771
15244
  * To adjust the log level, use the `Logger.withMinimumLogLevel` function.
14772
15245
  *
14773
15246
  * @example
15247
+ * ```ts
14774
15248
  * import { Cause, Effect } from "effect"
14775
15249
  *
14776
15250
  * const program = Effect.log(
@@ -14784,6 +15258,7 @@ export const matchEffect: {
14784
15258
  * // Output:
14785
15259
  * // timestamp=... level=INFO fiber=#0 message=message1 message=message2 cause="Error: Oh no!
14786
15260
  * // Error: Oh uh!"
15261
+ * ```
14787
15262
  *
14788
15263
  * @since 2.0.0
14789
15264
  * @category Logging
@@ -14817,12 +15292,14 @@ export const logTrace: (...message: ReadonlyArray<any>) => Effect<void, never, n
14817
15292
  * `Logger.withMinimumLogLevel` and set the log level to `LogLevel.Debug`.
14818
15293
  *
14819
15294
  * @example
15295
+ * ```ts
14820
15296
  * import { Effect, Logger, LogLevel } from "effect"
14821
15297
  *
14822
15298
  * const program = Effect.logDebug("message1").pipe(Logger.withMinimumLogLevel(LogLevel.Debug))
14823
15299
  *
14824
15300
  * // Effect.runFork(program)
14825
15301
  * // timestamp=... level=DEBUG fiber=#0 message=message1
15302
+ * ```
14826
15303
  *
14827
15304
  * @since 2.0.0
14828
15305
  * @category Logging
@@ -14867,6 +15344,7 @@ export const logFatal: (...message: ReadonlyArray<any>) => Effect<void, never, n
14867
15344
  * time-sensitive processes.
14868
15345
  *
14869
15346
  * @example
15347
+ * ```ts
14870
15348
  * import { Effect } from "effect"
14871
15349
  *
14872
15350
  * const program = Effect.gen(function*() {
@@ -14876,6 +15354,7 @@ export const logFatal: (...message: ReadonlyArray<any>) => Effect<void, never, n
14876
15354
  *
14877
15355
  * // Effect.runFork(program)
14878
15356
  * // timestamp=... level=INFO fiber=#0 message="The job is finished!" myspan=1011ms
15357
+ * ```
14879
15358
  *
14880
15359
  * @since 2.0.0
14881
15360
  * @category Logging
@@ -14887,6 +15366,7 @@ export const withLogSpan: {
14887
15366
  * time-sensitive processes.
14888
15367
  *
14889
15368
  * @example
15369
+ * ```ts
14890
15370
  * import { Effect } from "effect"
14891
15371
  *
14892
15372
  * const program = Effect.gen(function*() {
@@ -14896,6 +15376,7 @@ export const withLogSpan: {
14896
15376
  *
14897
15377
  * // Effect.runFork(program)
14898
15378
  * // timestamp=... level=INFO fiber=#0 message="The job is finished!" myspan=1011ms
15379
+ * ```
14899
15380
  *
14900
15381
  * @since 2.0.0
14901
15382
  * @category Logging
@@ -14907,6 +15388,7 @@ export const withLogSpan: {
14907
15388
  * time-sensitive processes.
14908
15389
  *
14909
15390
  * @example
15391
+ * ```ts
14910
15392
  * import { Effect } from "effect"
14911
15393
  *
14912
15394
  * const program = Effect.gen(function*() {
@@ -14916,6 +15398,7 @@ export const withLogSpan: {
14916
15398
  *
14917
15399
  * // Effect.runFork(program)
14918
15400
  * // timestamp=... level=INFO fiber=#0 message="The job is finished!" myspan=1011ms
15401
+ * ```
14919
15402
  *
14920
15403
  * @since 2.0.0
14921
15404
  * @category Logging
@@ -14929,6 +15412,7 @@ export const withLogSpan: {
14929
15412
  * to log messages, making them more informative and easier to trace.
14930
15413
  *
14931
15414
  * @example
15415
+ * ```ts
14932
15416
  * import { Effect } from "effect"
14933
15417
  *
14934
15418
  * const program = Effect.gen(function*() {
@@ -14939,6 +15423,7 @@ export const withLogSpan: {
14939
15423
  * // Effect.runFork(program)
14940
15424
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
14941
15425
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
15426
+ * ```
14942
15427
  *
14943
15428
  * @since 2.0.0
14944
15429
  * @category Logging
@@ -14950,6 +15435,7 @@ export const annotateLogs: {
14950
15435
  * to log messages, making them more informative and easier to trace.
14951
15436
  *
14952
15437
  * @example
15438
+ * ```ts
14953
15439
  * import { Effect } from "effect"
14954
15440
  *
14955
15441
  * const program = Effect.gen(function*() {
@@ -14960,6 +15446,7 @@ export const annotateLogs: {
14960
15446
  * // Effect.runFork(program)
14961
15447
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
14962
15448
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
15449
+ * ```
14963
15450
  *
14964
15451
  * @since 2.0.0
14965
15452
  * @category Logging
@@ -14971,6 +15458,7 @@ export const annotateLogs: {
14971
15458
  * to log messages, making them more informative and easier to trace.
14972
15459
  *
14973
15460
  * @example
15461
+ * ```ts
14974
15462
  * import { Effect } from "effect"
14975
15463
  *
14976
15464
  * const program = Effect.gen(function*() {
@@ -14981,6 +15469,7 @@ export const annotateLogs: {
14981
15469
  * // Effect.runFork(program)
14982
15470
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
14983
15471
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
15472
+ * ```
14984
15473
  *
14985
15474
  * @since 2.0.0
14986
15475
  * @category Logging
@@ -14992,6 +15481,7 @@ export const annotateLogs: {
14992
15481
  * to log messages, making them more informative and easier to trace.
14993
15482
  *
14994
15483
  * @example
15484
+ * ```ts
14995
15485
  * import { Effect } from "effect"
14996
15486
  *
14997
15487
  * const program = Effect.gen(function*() {
@@ -15002,6 +15492,7 @@ export const annotateLogs: {
15002
15492
  * // Effect.runFork(program)
15003
15493
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
15004
15494
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
15495
+ * ```
15005
15496
  *
15006
15497
  * @since 2.0.0
15007
15498
  * @category Logging
@@ -15013,6 +15504,7 @@ export const annotateLogs: {
15013
15504
  * to log messages, making them more informative and easier to trace.
15014
15505
  *
15015
15506
  * @example
15507
+ * ```ts
15016
15508
  * import { Effect } from "effect"
15017
15509
  *
15018
15510
  * const program = Effect.gen(function*() {
@@ -15023,6 +15515,7 @@ export const annotateLogs: {
15023
15515
  * // Effect.runFork(program)
15024
15516
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
15025
15517
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
15518
+ * ```
15026
15519
  *
15027
15520
  * @since 2.0.0
15028
15521
  * @category Logging
@@ -15037,6 +15530,7 @@ export const annotateLogs: {
15037
15530
  * defined `Scope`, making it easier to manage context-specific logging.
15038
15531
  *
15039
15532
  * @example
15533
+ * ```ts
15040
15534
  * import { Effect } from "effect"
15041
15535
  *
15042
15536
  * const program = Effect.gen(function*() {
@@ -15051,6 +15545,7 @@ export const annotateLogs: {
15051
15545
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
15052
15546
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
15053
15547
  * // timestamp=... level=INFO fiber=#0 message="no annotations again"
15548
+ * ```
15054
15549
  *
15055
15550
  * @since 3.1.0
15056
15551
  * @category Logging
@@ -15063,6 +15558,7 @@ export const annotateLogsScoped: {
15063
15558
  * defined `Scope`, making it easier to manage context-specific logging.
15064
15559
  *
15065
15560
  * @example
15561
+ * ```ts
15066
15562
  * import { Effect } from "effect"
15067
15563
  *
15068
15564
  * const program = Effect.gen(function*() {
@@ -15077,6 +15573,7 @@ export const annotateLogsScoped: {
15077
15573
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
15078
15574
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
15079
15575
  * // timestamp=... level=INFO fiber=#0 message="no annotations again"
15576
+ * ```
15080
15577
  *
15081
15578
  * @since 3.1.0
15082
15579
  * @category Logging
@@ -15089,6 +15586,7 @@ export const annotateLogsScoped: {
15089
15586
  * defined `Scope`, making it easier to manage context-specific logging.
15090
15587
  *
15091
15588
  * @example
15589
+ * ```ts
15092
15590
  * import { Effect } from "effect"
15093
15591
  *
15094
15592
  * const program = Effect.gen(function*() {
@@ -15103,6 +15601,7 @@ export const annotateLogsScoped: {
15103
15601
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
15104
15602
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
15105
15603
  * // timestamp=... level=INFO fiber=#0 message="no annotations again"
15604
+ * ```
15106
15605
  *
15107
15606
  * @since 3.1.0
15108
15607
  * @category Logging
@@ -15157,6 +15656,7 @@ export const withUnhandledErrorLogLevel: {
15157
15656
  * @see {@link orDieWith} if you need to customize the error.
15158
15657
  *
15159
15658
  * @example
15659
+ * ```ts
15160
15660
  * // Title: Propagating an Error as a Defect
15161
15661
  * import { Effect } from "effect"
15162
15662
  *
@@ -15173,6 +15673,7 @@ export const withUnhandledErrorLogLevel: {
15173
15673
  * // Output:
15174
15674
  * // (FiberFailure) Error: Cannot divide by zero
15175
15675
  * // ...stack trace...
15676
+ * ```
15176
15677
  *
15177
15678
  * @since 2.0.0
15178
15679
  * @category Converting Failures to Defects
@@ -15197,6 +15698,7 @@ export const orDie: <A, E, R>(self: Effect<A, E, R>) => Effect<A, never, R> = co
15197
15698
  * @see {@link orDie} if you don't need to customize the error.
15198
15699
  *
15199
15700
  * @example
15701
+ * ```ts
15200
15702
  * // Title: Customizing Defect
15201
15703
  * import { Effect } from "effect"
15202
15704
  *
@@ -15216,6 +15718,7 @@ export const orDie: <A, E, R>(self: Effect<A, E, R>) => Effect<A, never, R> = co
15216
15718
  * // Output:
15217
15719
  * // (FiberFailure) Error: defect: Cannot divide by zero
15218
15720
  * // ...stack trace...
15721
+ * ```
15219
15722
  *
15220
15723
  * @since 2.0.0
15221
15724
  * @category Converting Failures to Defects
@@ -15239,6 +15742,7 @@ export const orDieWith: {
15239
15742
  * @see {@link orDie} if you don't need to customize the error.
15240
15743
  *
15241
15744
  * @example
15745
+ * ```ts
15242
15746
  * // Title: Customizing Defect
15243
15747
  * import { Effect } from "effect"
15244
15748
  *
@@ -15258,6 +15762,7 @@ export const orDieWith: {
15258
15762
  * // Output:
15259
15763
  * // (FiberFailure) Error: defect: Cannot divide by zero
15260
15764
  * // ...stack trace...
15765
+ * ```
15261
15766
  *
15262
15767
  * @since 2.0.0
15263
15768
  * @category Converting Failures to Defects
@@ -15281,6 +15786,7 @@ export const orDieWith: {
15281
15786
  * @see {@link orDie} if you don't need to customize the error.
15282
15787
  *
15283
15788
  * @example
15789
+ * ```ts
15284
15790
  * // Title: Customizing Defect
15285
15791
  * import { Effect } from "effect"
15286
15792
  *
@@ -15300,6 +15806,7 @@ export const orDieWith: {
15300
15806
  * // Output:
15301
15807
  * // (FiberFailure) Error: defect: Cannot divide by zero
15302
15808
  * // ...stack trace...
15809
+ * ```
15303
15810
  *
15304
15811
  * @since 2.0.0
15305
15812
  * @category Converting Failures to Defects
@@ -15318,6 +15825,7 @@ export const orDieWith: {
15318
15825
  * @see {@link catchAll} if you need to access the error in the fallback effect.
15319
15826
  *
15320
15827
  * @example
15828
+ * ```ts
15321
15829
  * import { Effect } from "effect"
15322
15830
  *
15323
15831
  * const success = Effect.succeed("success")
@@ -15333,6 +15841,7 @@ export const orDieWith: {
15333
15841
  * const program2 = Effect.orElse(failure, () => fallback)
15334
15842
  * console.log(Effect.runSync(program2))
15335
15843
  * // Output: "fallback"
15844
+ * ```
15336
15845
  *
15337
15846
  * @since 2.0.0
15338
15847
  * @category Fallback
@@ -15349,6 +15858,7 @@ export const orElse: {
15349
15858
  * @see {@link catchAll} if you need to access the error in the fallback effect.
15350
15859
  *
15351
15860
  * @example
15861
+ * ```ts
15352
15862
  * import { Effect } from "effect"
15353
15863
  *
15354
15864
  * const success = Effect.succeed("success")
@@ -15364,6 +15874,7 @@ export const orElse: {
15364
15874
  * const program2 = Effect.orElse(failure, () => fallback)
15365
15875
  * console.log(Effect.runSync(program2))
15366
15876
  * // Output: "fallback"
15877
+ * ```
15367
15878
  *
15368
15879
  * @since 2.0.0
15369
15880
  * @category Fallback
@@ -15380,6 +15891,7 @@ export const orElse: {
15380
15891
  * @see {@link catchAll} if you need to access the error in the fallback effect.
15381
15892
  *
15382
15893
  * @example
15894
+ * ```ts
15383
15895
  * import { Effect } from "effect"
15384
15896
  *
15385
15897
  * const success = Effect.succeed("success")
@@ -15395,6 +15907,7 @@ export const orElse: {
15395
15907
  * const program2 = Effect.orElse(failure, () => fallback)
15396
15908
  * console.log(Effect.runSync(program2))
15397
15909
  * // Output: "fallback"
15910
+ * ```
15398
15911
  *
15399
15912
  * @since 2.0.0
15400
15913
  * @category Fallback
@@ -15415,6 +15928,7 @@ export const orElse: {
15415
15928
  * @see {@link mapError} if you need to access the error to transform it.
15416
15929
  *
15417
15930
  * @example
15931
+ * ```ts
15418
15932
  * import { Effect } from "effect"
15419
15933
  *
15420
15934
  * const validate = (age: number): Effect.Effect<number, string> => {
@@ -15436,6 +15950,7 @@ export const orElse: {
15436
15950
  * // _tag: 'Failure',
15437
15951
  * // cause: { _id: 'Cause', _tag: 'Fail', failure: 'invalid age' }
15438
15952
  * // }
15953
+ * ```
15439
15954
  *
15440
15955
  * @since 2.0.0
15441
15956
  * @category Fallback
@@ -15454,6 +15969,7 @@ export const orElseFail: {
15454
15969
  * @see {@link mapError} if you need to access the error to transform it.
15455
15970
  *
15456
15971
  * @example
15972
+ * ```ts
15457
15973
  * import { Effect } from "effect"
15458
15974
  *
15459
15975
  * const validate = (age: number): Effect.Effect<number, string> => {
@@ -15475,6 +15991,7 @@ export const orElseFail: {
15475
15991
  * // _tag: 'Failure',
15476
15992
  * // cause: { _id: 'Cause', _tag: 'Fail', failure: 'invalid age' }
15477
15993
  * // }
15994
+ * ```
15478
15995
  *
15479
15996
  * @since 2.0.0
15480
15997
  * @category Fallback
@@ -15493,6 +16010,7 @@ export const orElseFail: {
15493
16010
  * @see {@link mapError} if you need to access the error to transform it.
15494
16011
  *
15495
16012
  * @example
16013
+ * ```ts
15496
16014
  * import { Effect } from "effect"
15497
16015
  *
15498
16016
  * const validate = (age: number): Effect.Effect<number, string> => {
@@ -15514,6 +16032,7 @@ export const orElseFail: {
15514
16032
  * // _tag: 'Failure',
15515
16033
  * // cause: { _id: 'Cause', _tag: 'Fail', failure: 'invalid age' }
15516
16034
  * // }
16035
+ * ```
15517
16036
  *
15518
16037
  * @since 2.0.0
15519
16038
  * @category Fallback
@@ -15539,6 +16058,7 @@ export const orElseFail: {
15539
16058
  * already succeeds, it will remain unchanged.
15540
16059
  *
15541
16060
  * @example
16061
+ * ```ts
15542
16062
  * import { Effect } from "effect"
15543
16063
  *
15544
16064
  * const validate = (age: number): Effect.Effect<number, string> => {
@@ -15556,6 +16076,7 @@ export const orElseFail: {
15556
16076
  * console.log(Effect.runSyncExit(program))
15557
16077
  * // Output:
15558
16078
  * // { _id: 'Exit', _tag: 'Success', value: 18 }
16079
+ * ```
15559
16080
  *
15560
16081
  * @since 2.0.0
15561
16082
  * @category Fallback
@@ -15579,6 +16100,7 @@ export const orElseSucceed: {
15579
16100
  * already succeeds, it will remain unchanged.
15580
16101
  *
15581
16102
  * @example
16103
+ * ```ts
15582
16104
  * import { Effect } from "effect"
15583
16105
  *
15584
16106
  * const validate = (age: number): Effect.Effect<number, string> => {
@@ -15596,6 +16118,7 @@ export const orElseSucceed: {
15596
16118
  * console.log(Effect.runSyncExit(program))
15597
16119
  * // Output:
15598
16120
  * // { _id: 'Exit', _tag: 'Success', value: 18 }
16121
+ * ```
15599
16122
  *
15600
16123
  * @since 2.0.0
15601
16124
  * @category Fallback
@@ -15619,6 +16142,7 @@ export const orElseSucceed: {
15619
16142
  * already succeeds, it will remain unchanged.
15620
16143
  *
15621
16144
  * @example
16145
+ * ```ts
15622
16146
  * import { Effect } from "effect"
15623
16147
  *
15624
16148
  * const validate = (age: number): Effect.Effect<number, string> => {
@@ -15636,6 +16160,7 @@ export const orElseSucceed: {
15636
16160
  * console.log(Effect.runSyncExit(program))
15637
16161
  * // Output:
15638
16162
  * // { _id: 'Exit', _tag: 'Success', value: 18 }
16163
+ * ```
15639
16164
  *
15640
16165
  * @since 2.0.0
15641
16166
  * @category Fallback
@@ -15661,6 +16186,7 @@ export const orElseSucceed: {
15661
16186
  * error.
15662
16187
  *
15663
16188
  * @example
16189
+ * ```ts
15664
16190
  * import { Effect, Console } from "effect"
15665
16191
  *
15666
16192
  * interface Config {
@@ -15707,6 +16233,7 @@ export const orElseSucceed: {
15707
16233
  * // Unavailable config for node2
15708
16234
  * // Config for node3 found
15709
16235
  * // { host: 'node3.example.com', port: 8080, apiKey: '12345-abcde' }
16236
+ * ```
15710
16237
  *
15711
16238
  * @since 2.0.0
15712
16239
  * @category Fallback
@@ -16013,6 +16540,7 @@ export const unsafeMakeLatch: (open?: boolean | undefined) => Latch = circular.u
16013
16540
  * @category latch
16014
16541
  * @since 3.8.0
16015
16542
  * @example
16543
+ * ```ts
16016
16544
  * import { Effect } from "effect"
16017
16545
  *
16018
16546
  * Effect.gen(function*() {
@@ -16029,6 +16557,7 @@ export const unsafeMakeLatch: (open?: boolean | undefined) => Latch = circular.u
16029
16557
  * yield* latch.open
16030
16558
  * yield* fiber.await
16031
16559
  * })
16560
+ * ```
16032
16561
  */
16033
16562
  export const makeLatch: (open?: boolean | undefined) => Effect<Latch, never, never> = circular.makeLatch
16034
16563
 
@@ -16046,6 +16575,7 @@ export const makeLatch: (open?: boolean | undefined) => Effect<Latch, never, nev
16046
16575
  * `runFork` is a good default choice.
16047
16576
  *
16048
16577
  * @example
16578
+ * ```ts
16049
16579
  * // Title: Running an Effect in the Background
16050
16580
  * import { Effect, Console, Schedule, Fiber } from "effect"
16051
16581
  *
@@ -16063,6 +16593,7 @@ export const makeLatch: (open?: boolean | undefined) => Effect<Latch, never, nev
16063
16593
  * setTimeout(() => {
16064
16594
  * Effect.runFork(Fiber.interrupt(fiber))
16065
16595
  * }, 500)
16596
+ * ```
16066
16597
  *
16067
16598
  * @since 2.0.0
16068
16599
  * @category Running Effects
@@ -16096,11 +16627,13 @@ export const runCallback: <A, E>(
16096
16627
  * @see {@link runPromiseExit} for a version that returns an `Exit` type instead of rejecting.
16097
16628
  *
16098
16629
  * @example
16630
+ * ```ts
16099
16631
  * // Title: Running a Successful Effect as a Promise
16100
16632
  * import { Effect } from "effect"
16101
16633
  *
16102
16634
  * Effect.runPromise(Effect.succeed(1)).then(console.log)
16103
16635
  * // Output: 1
16636
+ * ```
16104
16637
  *
16105
16638
  * @example
16106
16639
  * //Example: Handling a Failing Effect as a Rejected Promise
@@ -16135,6 +16668,7 @@ export const runPromise: <A, E>(
16135
16668
  * a `Cause` type.
16136
16669
  *
16137
16670
  * @example
16671
+ * ```ts
16138
16672
  * // Title: Handling Results as Exit
16139
16673
  * import { Effect } from "effect"
16140
16674
  *
@@ -16159,6 +16693,7 @@ export const runPromise: <A, E>(
16159
16693
  * // failure: "my error"
16160
16694
  * // }
16161
16695
  * // }
16696
+ * ```
16162
16697
  *
16163
16698
  * @since 2.0.0
16164
16699
  * @category Running Effects
@@ -16184,6 +16719,7 @@ export const runPromiseExit: <A, E>(
16184
16719
  * throwing an error.
16185
16720
  *
16186
16721
  * @example
16722
+ * ```ts
16187
16723
  * // Title: Synchronous Logging
16188
16724
  * import { Effect } from "effect"
16189
16725
  *
@@ -16197,6 +16733,7 @@ export const runPromiseExit: <A, E>(
16197
16733
  *
16198
16734
  * console.log(result)
16199
16735
  * // Output: 1
16736
+ * ```
16200
16737
  *
16201
16738
  * @example
16202
16739
  * // Title: Incorrect Usage with Failing or Async Effects
@@ -16246,6 +16783,7 @@ export const runSync: <A, E>(effect: Effect<A, E>) => A = _runtime.unsafeRunSync
16246
16783
  * resolved synchronously.
16247
16784
  *
16248
16785
  * @example
16786
+ * ```ts
16249
16787
  * // Title: Handling Results as Exit
16250
16788
  * import { Effect } from "effect"
16251
16789
  *
@@ -16268,6 +16806,7 @@ export const runSync: <A, E>(effect: Effect<A, E>) => A = _runtime.unsafeRunSync
16268
16806
  * // failure: "my error"
16269
16807
  * // }
16270
16808
  * // }
16809
+ * ```
16271
16810
  *
16272
16811
  * @example
16273
16812
  * // Title: Asynchronous Operation Resulting in Die
@@ -16309,6 +16848,7 @@ export const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E> = _run
16309
16848
  * @see {@link zip} for a version that stops at the first error.
16310
16849
  *
16311
16850
  * @example
16851
+ * ```ts
16312
16852
  * import { Effect, Console } from "effect"
16313
16853
  *
16314
16854
  * const task1 = Console.log("task1").pipe(Effect.as(1))
@@ -16336,6 +16876,7 @@ export const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E> = _run
16336
16876
  * // right: { _id: 'Cause', _tag: 'Fail', failure: 'Oh no!' }
16337
16877
  * // }
16338
16878
  * // }
16879
+ * ```
16339
16880
  *
16340
16881
  * @since 2.0.0
16341
16882
  * @category Error Accumulation
@@ -16356,6 +16897,7 @@ export const validate: {
16356
16897
  * @see {@link zip} for a version that stops at the first error.
16357
16898
  *
16358
16899
  * @example
16900
+ * ```ts
16359
16901
  * import { Effect, Console } from "effect"
16360
16902
  *
16361
16903
  * const task1 = Console.log("task1").pipe(Effect.as(1))
@@ -16383,6 +16925,7 @@ export const validate: {
16383
16925
  * // right: { _id: 'Cause', _tag: 'Fail', failure: 'Oh no!' }
16384
16926
  * // }
16385
16927
  * // }
16928
+ * ```
16386
16929
  *
16387
16930
  * @since 2.0.0
16388
16931
  * @category Error Accumulation
@@ -16410,6 +16953,7 @@ export const validate: {
16410
16953
  * @see {@link zip} for a version that stops at the first error.
16411
16954
  *
16412
16955
  * @example
16956
+ * ```ts
16413
16957
  * import { Effect, Console } from "effect"
16414
16958
  *
16415
16959
  * const task1 = Console.log("task1").pipe(Effect.as(1))
@@ -16437,6 +16981,7 @@ export const validate: {
16437
16981
  * // right: { _id: 'Cause', _tag: 'Fail', failure: 'Oh no!' }
16438
16982
  * // }
16439
16983
  * // }
16984
+ * ```
16440
16985
  *
16441
16986
  * @since 2.0.0
16442
16987
  * @category Error Accumulation
@@ -16516,6 +17061,7 @@ export const validateWith: {
16516
17061
  * @see {@link validate} for a version that accumulates errors.
16517
17062
  *
16518
17063
  * @example
17064
+ * ```ts
16519
17065
  * // Title: Combining Two Effects Sequentially
16520
17066
  * import { Effect } from "effect"
16521
17067
  *
@@ -16539,6 +17085,7 @@ export const validateWith: {
16539
17085
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16540
17086
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16541
17087
  * // [ 1, 'hello' ]
17088
+ * ```
16542
17089
  *
16543
17090
  * @example
16544
17091
  * // Title: Combining Two Effects Concurrently
@@ -16581,6 +17128,7 @@ export const zip: {
16581
17128
  * @see {@link validate} for a version that accumulates errors.
16582
17129
  *
16583
17130
  * @example
17131
+ * ```ts
16584
17132
  * // Title: Combining Two Effects Sequentially
16585
17133
  * import { Effect } from "effect"
16586
17134
  *
@@ -16604,6 +17152,7 @@ export const zip: {
16604
17152
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16605
17153
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16606
17154
  * // [ 1, 'hello' ]
17155
+ * ```
16607
17156
  *
16608
17157
  * @example
16609
17158
  * // Title: Combining Two Effects Concurrently
@@ -16655,6 +17204,7 @@ export const zip: {
16655
17204
  * @see {@link validate} for a version that accumulates errors.
16656
17205
  *
16657
17206
  * @example
17207
+ * ```ts
16658
17208
  * // Title: Combining Two Effects Sequentially
16659
17209
  * import { Effect } from "effect"
16660
17210
  *
@@ -16678,6 +17228,7 @@ export const zip: {
16678
17228
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16679
17229
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16680
17230
  * // [ 1, 'hello' ]
17231
+ * ```
16681
17232
  *
16682
17233
  * @example
16683
17234
  * // Title: Combining Two Effects Concurrently
@@ -16735,6 +17286,7 @@ export const zip: {
16735
17286
  * @see {@link zipRight} for a version that returns the result of the second effect.
16736
17287
  *
16737
17288
  * @example
17289
+ * ```ts
16738
17290
  * import { Effect } from "effect"
16739
17291
  *
16740
17292
  * const task1 = Effect.succeed(1).pipe(
@@ -16753,6 +17305,7 @@ export const zip: {
16753
17305
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16754
17306
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16755
17307
  * // 1
17308
+ * ```
16756
17309
  *
16757
17310
  * @since 2.0.0
16758
17311
  * @category Zipping
@@ -16776,6 +17329,7 @@ export const zipLeft: {
16776
17329
  * @see {@link zipRight} for a version that returns the result of the second effect.
16777
17330
  *
16778
17331
  * @example
17332
+ * ```ts
16779
17333
  * import { Effect } from "effect"
16780
17334
  *
16781
17335
  * const task1 = Effect.succeed(1).pipe(
@@ -16794,6 +17348,7 @@ export const zipLeft: {
16794
17348
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16795
17349
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16796
17350
  * // 1
17351
+ * ```
16797
17352
  *
16798
17353
  * @since 2.0.0
16799
17354
  * @category Zipping
@@ -16826,6 +17381,7 @@ export const zipLeft: {
16826
17381
  * @see {@link zipRight} for a version that returns the result of the second effect.
16827
17382
  *
16828
17383
  * @example
17384
+ * ```ts
16829
17385
  * import { Effect } from "effect"
16830
17386
  *
16831
17387
  * const task1 = Effect.succeed(1).pipe(
@@ -16844,6 +17400,7 @@ export const zipLeft: {
16844
17400
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16845
17401
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16846
17402
  * // 1
17403
+ * ```
16847
17404
  *
16848
17405
  * @since 2.0.0
16849
17406
  * @category Zipping
@@ -16879,6 +17436,7 @@ export const zipLeft: {
16879
17436
  * @see {@link zipLeft} for a version that returns the result of the first effect.
16880
17437
  *
16881
17438
  * @example
17439
+ * ```ts
16882
17440
  * import { Effect } from "effect"
16883
17441
  *
16884
17442
  * const task1 = Effect.succeed(1).pipe(
@@ -16897,6 +17455,7 @@ export const zipLeft: {
16897
17455
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16898
17456
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16899
17457
  * // hello
17458
+ * ```
16900
17459
  *
16901
17460
  * @since 2.0.0
16902
17461
  * @category Zipping
@@ -16920,6 +17479,7 @@ export const zipRight: {
16920
17479
  * @see {@link zipLeft} for a version that returns the result of the first effect.
16921
17480
  *
16922
17481
  * @example
17482
+ * ```ts
16923
17483
  * import { Effect } from "effect"
16924
17484
  *
16925
17485
  * const task1 = Effect.succeed(1).pipe(
@@ -16938,6 +17498,7 @@ export const zipRight: {
16938
17498
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16939
17499
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16940
17500
  * // hello
17501
+ * ```
16941
17502
  *
16942
17503
  * @since 2.0.0
16943
17504
  * @category Zipping
@@ -16968,6 +17529,7 @@ export const zipRight: {
16968
17529
  * @see {@link zipLeft} for a version that returns the result of the first effect.
16969
17530
  *
16970
17531
  * @example
17532
+ * ```ts
16971
17533
  * import { Effect } from "effect"
16972
17534
  *
16973
17535
  * const task1 = Effect.succeed(1).pipe(
@@ -16986,6 +17548,7 @@ export const zipRight: {
16986
17548
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
16987
17549
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
16988
17550
  * // hello
17551
+ * ```
16989
17552
  *
16990
17553
  * @since 2.0.0
16991
17554
  * @category Zipping
@@ -17017,6 +17580,7 @@ export const zipRight: {
17017
17580
  * use the `{ concurrent: true }` option.
17018
17581
  *
17019
17582
  * @example
17583
+ * ```ts
17020
17584
  * // Title: Combining Effects with a Custom Function
17021
17585
  * import { Effect } from "effect"
17022
17586
  *
@@ -17041,6 +17605,7 @@ export const zipRight: {
17041
17605
  * // timestamp=... level=INFO fiber=#3 message="task1 done"
17042
17606
  * // timestamp=... level=INFO fiber=#2 message="task2 done"
17043
17607
  * // 6
17608
+ * ```
17044
17609
  *
17045
17610
  * @since 2.0.0
17046
17611
  * @category Zipping
@@ -17062,6 +17627,7 @@ export const zipWith: {
17062
17627
  * use the `{ concurrent: true }` option.
17063
17628
  *
17064
17629
  * @example
17630
+ * ```ts
17065
17631
  * // Title: Combining Effects with a Custom Function
17066
17632
  * import { Effect } from "effect"
17067
17633
  *
@@ -17086,6 +17652,7 @@ export const zipWith: {
17086
17652
  * // timestamp=... level=INFO fiber=#3 message="task1 done"
17087
17653
  * // timestamp=... level=INFO fiber=#2 message="task2 done"
17088
17654
  * // 6
17655
+ * ```
17089
17656
  *
17090
17657
  * @since 2.0.0
17091
17658
  * @category Zipping
@@ -17115,6 +17682,7 @@ export const zipWith: {
17115
17682
  * use the `{ concurrent: true }` option.
17116
17683
  *
17117
17684
  * @example
17685
+ * ```ts
17118
17686
  * // Title: Combining Effects with a Custom Function
17119
17687
  * import { Effect } from "effect"
17120
17688
  *
@@ -17139,6 +17707,7 @@ export const zipWith: {
17139
17707
  * // timestamp=... level=INFO fiber=#3 message="task1 done"
17140
17708
  * // timestamp=... level=INFO fiber=#2 message="task2 done"
17141
17709
  * // 6
17710
+ * ```
17142
17711
  *
17143
17712
  * @since 2.0.0
17144
17713
  * @category Zipping
@@ -17329,6 +17898,7 @@ export const withTracerScoped: (value: Tracer.Tracer) => Effect<void, never, Sco
17329
17898
  * @since 2.0.0
17330
17899
  * @category Tracing
17331
17900
  * @example
17901
+ * ```ts
17332
17902
  * import { Effect } from "effect"
17333
17903
  *
17334
17904
  * Effect.succeed(42).pipe(
@@ -17336,6 +17906,7 @@ export const withTracerScoped: (value: Tracer.Tracer) => Effect<void, never, Sco
17336
17906
  * // the span will not be registered with the tracer
17337
17907
  * Effect.withTracerEnabled(false)
17338
17908
  * )
17909
+ * ```
17339
17910
  */
17340
17911
  export const withTracerEnabled: {
17341
17912
  /**
@@ -17344,6 +17915,7 @@ export const withTracerEnabled: {
17344
17915
  * @since 2.0.0
17345
17916
  * @category Tracing
17346
17917
  * @example
17918
+ * ```ts
17347
17919
  * import { Effect } from "effect"
17348
17920
  *
17349
17921
  * Effect.succeed(42).pipe(
@@ -17351,6 +17923,7 @@ export const withTracerEnabled: {
17351
17923
  * // the span will not be registered with the tracer
17352
17924
  * Effect.withTracerEnabled(false)
17353
17925
  * )
17926
+ * ```
17354
17927
  */
17355
17928
  (enabled: boolean): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>
17356
17929
  /**
@@ -17359,6 +17932,7 @@ export const withTracerEnabled: {
17359
17932
  * @since 2.0.0
17360
17933
  * @category Tracing
17361
17934
  * @example
17935
+ * ```ts
17362
17936
  * import { Effect } from "effect"
17363
17937
  *
17364
17938
  * Effect.succeed(42).pipe(
@@ -17366,6 +17940,7 @@ export const withTracerEnabled: {
17366
17940
  * // the span will not be registered with the tracer
17367
17941
  * Effect.withTracerEnabled(false)
17368
17942
  * )
17943
+ * ```
17369
17944
  */
17370
17945
  <A, E, R>(effect: Effect<A, E, R>, enabled: boolean): Effect<A, E, R>
17371
17946
  } = core.withTracerEnabled
@@ -17615,6 +18190,7 @@ export interface FunctionWithSpanOptions {
17615
18190
  * @since 3.2.0
17616
18191
  * @category Tracing
17617
18192
  * @example
18193
+ * ```ts
17618
18194
  * import { Effect } from "effect"
17619
18195
  *
17620
18196
  * const getTodo = Effect.functionWithSpan({
@@ -17624,6 +18200,7 @@ export interface FunctionWithSpanOptions {
17624
18200
  * attributes: { id }
17625
18201
  * })
17626
18202
  * })
18203
+ * ```
17627
18204
  */
17628
18205
  export const functionWithSpan: <Args extends Array<any>, Ret extends Effect<any, any, any>>(
17629
18206
  options: {
@@ -17704,6 +18281,7 @@ export const withParentSpan: {
17704
18281
  * value.
17705
18282
  *
17706
18283
  * @example
18284
+ * ```ts
17707
18285
  * import { Effect } from "effect"
17708
18286
  *
17709
18287
  * // ┌─── Effect<number, NoSuchElementException, never>
@@ -17729,6 +18307,7 @@ export const withParentSpan: {
17729
18307
  * // failure: { _tag: 'NoSuchElementException' }
17730
18308
  * // }
17731
18309
  * // }
18310
+ * ```
17732
18311
  *
17733
18312
  * @since 2.0.0
17734
18313
  * @category Optional Wrapping
@@ -17747,6 +18326,7 @@ export const fromNullable: <A>(value: A) => Effect<NonNullable<A>, Cause.NoSuchE
17747
18326
  * unchanged.
17748
18327
  *
17749
18328
  * @example
18329
+ * ```ts
17750
18330
  * import { Effect } from "effect"
17751
18331
  *
17752
18332
  * // ┌─── Effect<number, NoSuchElementException, never>
@@ -17770,6 +18350,7 @@ export const fromNullable: <A>(value: A) => Effect<NonNullable<A>, Cause.NoSuchE
17770
18350
  *
17771
18351
  * Effect.runPromise(option2).then(console.log)
17772
18352
  * // Output: { _tag: 'None' }
18353
+ * ```
17773
18354
  *
17774
18355
  * @since 2.0.0
17775
18356
  * @category Optional Wrapping
@@ -17856,6 +18437,7 @@ const makeTagProxy = (TagClass: Context.Tag<any, any> & Record<PropertyKey, any>
17856
18437
 
17857
18438
  /**
17858
18439
  * @example
18440
+ * ```ts
17859
18441
  * import { Effect, Layer } from "effect"
17860
18442
  *
17861
18443
  * class MapTag extends Effect.Tag("MapTag")<MapTag, Map<string, string>>() {
@@ -17864,6 +18446,7 @@ const makeTagProxy = (TagClass: Context.Tag<any, any> & Record<PropertyKey, any>
17864
18446
  * Effect.sync(() => new Map())
17865
18447
  * )
17866
18448
  * }
18449
+ * ```
17867
18450
  *
17868
18451
  * @since 2.0.0
17869
18452
  * @category Context
@@ -17903,6 +18486,7 @@ export const Tag: <const Id extends string>(id: Id) => <
17903
18486
 
17904
18487
  /**
17905
18488
  * @example
18489
+ * ```ts
17906
18490
  * import { Effect } from 'effect';
17907
18491
  *
17908
18492
  * class Prefix extends Effect.Service<Prefix>()("Prefix", {
@@ -17922,6 +18506,7 @@ export const Tag: <const Id extends string>(id: Id) => <
17922
18506
  * }),
17923
18507
  * dependencies: [Prefix.Default]
17924
18508
  * }) {}
18509
+ * ```
17925
18510
  *
17926
18511
  * @since 3.9.0
17927
18512
  * @category Context
@@ -18225,3 +18810,327 @@ export declare namespace Service {
18225
18810
  export type MakeAccessors<Make> = Make extends { readonly accessors: true } ? true
18226
18811
  : false
18227
18812
  }
18813
+
18814
+ /**
18815
+ * @since 3.11.0
18816
+ * @category models
18817
+ */
18818
+ export namespace fn {
18819
+ /**
18820
+ * @since 3.11.0
18821
+ * @category models
18822
+ */
18823
+ export type FnEffect<AEff, Eff extends YieldWrap<Effect<any, any, any>>> = Effect<
18824
+ AEff,
18825
+ [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Effect<infer _A, infer E, infer _R>>] ? E : never,
18826
+ [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Effect<infer _A, infer _E, infer R>>] ? R : never
18827
+ >
18828
+
18829
+ /**
18830
+ * @since 3.11.0
18831
+ * @category models
18832
+ */
18833
+ export type Gen = {
18834
+ <Eff extends YieldWrap<Effect<any, any, any>>, AEff, Args extends Array<any>>(
18835
+ body: (...args: Args) => Generator<Eff, AEff, never>
18836
+ ): (...args: Args) => fn.FnEffect<AEff, Eff>
18837
+ <Eff extends YieldWrap<Effect<any, any, any>>, AEff, Args extends Array<any>, A extends Effect<any, any, any>>(
18838
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18839
+ a: (_: fn.FnEffect<AEff, Eff>) => A
18840
+ ): (...args: Args) => A
18841
+ <Eff extends YieldWrap<Effect<any, any, any>>, AEff, Args extends Array<any>, A, B extends Effect<any, any, any>>(
18842
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18843
+ a: (_: fn.FnEffect<AEff, Eff>) => A,
18844
+ b: (_: A) => B
18845
+ ): (...args: Args) => B
18846
+ <
18847
+ Eff extends YieldWrap<Effect<any, any, any>>,
18848
+ AEff,
18849
+ Args extends Array<any>,
18850
+ A,
18851
+ B,
18852
+ C extends Effect<any, any, any>
18853
+ >(
18854
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18855
+ a: (_: fn.FnEffect<AEff, Eff>) => A,
18856
+ b: (_: A) => B,
18857
+ c: (_: B) => C
18858
+ ): (...args: Args) => C
18859
+ <
18860
+ Eff extends YieldWrap<Effect<any, any, any>>,
18861
+ AEff,
18862
+ Args extends Array<any>,
18863
+ A,
18864
+ B,
18865
+ C,
18866
+ D extends Effect<any, any, any>
18867
+ >(
18868
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18869
+ a: (_: fn.FnEffect<AEff, Eff>) => A,
18870
+ b: (_: A) => B,
18871
+ c: (_: B) => C,
18872
+ d: (_: C) => D
18873
+ ): (...args: Args) => D
18874
+ <
18875
+ Eff extends YieldWrap<Effect<any, any, any>>,
18876
+ AEff,
18877
+ Args extends Array<any>,
18878
+ A,
18879
+ B,
18880
+ C,
18881
+ D,
18882
+ E extends Effect<any, any, any>
18883
+ >(
18884
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18885
+ a: (_: fn.FnEffect<AEff, Eff>) => A,
18886
+ b: (_: A) => B,
18887
+ c: (_: B) => C,
18888
+ d: (_: C) => D,
18889
+ e: (_: D) => E
18890
+ ): (...args: Args) => E
18891
+ <
18892
+ Eff extends YieldWrap<Effect<any, any, any>>,
18893
+ AEff,
18894
+ Args extends Array<any>,
18895
+ A,
18896
+ B,
18897
+ C,
18898
+ D,
18899
+ E,
18900
+ F extends Effect<any, any, any>
18901
+ >(
18902
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18903
+ a: (_: fn.FnEffect<AEff, Eff>) => A,
18904
+ b: (_: A) => B,
18905
+ c: (_: B) => C,
18906
+ d: (_: C) => D,
18907
+ e: (_: D) => E,
18908
+ f: (_: E) => F
18909
+ ): (...args: Args) => F
18910
+ <
18911
+ Eff extends YieldWrap<Effect<any, any, any>>,
18912
+ AEff,
18913
+ Args extends Array<any>,
18914
+ A,
18915
+ B,
18916
+ C,
18917
+ D,
18918
+ E,
18919
+ F,
18920
+ G extends Effect<any, any, any>
18921
+ >(
18922
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18923
+ a: (_: fn.FnEffect<AEff, Eff>) => A,
18924
+ b: (_: A) => B,
18925
+ c: (_: B) => C,
18926
+ d: (_: C) => D,
18927
+ e: (_: D) => E,
18928
+ f: (_: E) => F,
18929
+ g: (_: F) => G
18930
+ ): (...args: Args) => G
18931
+ <
18932
+ Eff extends YieldWrap<Effect<any, any, any>>,
18933
+ AEff,
18934
+ Args extends Array<any>,
18935
+ A,
18936
+ B,
18937
+ C,
18938
+ D,
18939
+ E,
18940
+ F,
18941
+ G,
18942
+ H extends Effect<any, any, any>
18943
+ >(
18944
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18945
+ a: (_: fn.FnEffect<AEff, Eff>) => A,
18946
+ b: (_: A) => B,
18947
+ c: (_: B) => C,
18948
+ d: (_: C) => D,
18949
+ e: (_: D) => E,
18950
+ f: (_: E) => F,
18951
+ g: (_: F) => G,
18952
+ h: (_: G) => H
18953
+ ): (...args: Args) => H
18954
+ <
18955
+ Eff extends YieldWrap<Effect<any, any, any>>,
18956
+ AEff,
18957
+ Args extends Array<any>,
18958
+ A,
18959
+ B,
18960
+ C,
18961
+ D,
18962
+ E,
18963
+ F,
18964
+ G,
18965
+ H,
18966
+ I extends Effect<any, any, any>
18967
+ >(
18968
+ body: (...args: Args) => Generator<Eff, AEff, never>,
18969
+ a: (_: fn.FnEffect<AEff, Eff>) => A,
18970
+ b: (_: A) => B,
18971
+ c: (_: B) => C,
18972
+ d: (_: C) => D,
18973
+ e: (_: D) => E,
18974
+ f: (_: E) => F,
18975
+ g: (_: F) => G,
18976
+ h: (_: G) => H,
18977
+ i: (_: H) => I
18978
+ ): (...args: Args) => I
18979
+ }
18980
+
18981
+ /**
18982
+ * @since 3.11.0
18983
+ * @category models
18984
+ */
18985
+ export type NonGen = {
18986
+ <Eff extends Effect<any, any, any>, Args extends Array<any>>(
18987
+ body: (...args: Args) => Eff
18988
+ ): (...args: Args) => Eff
18989
+ <Eff extends Effect<any, any, any>, A, Args extends Array<any>>(
18990
+ body: (...args: Args) => A,
18991
+ a: (_: A) => Eff
18992
+ ): (...args: Args) => Eff
18993
+ <Eff extends Effect<any, any, any>, A, B, Args extends Array<any>>(
18994
+ body: (...args: Args) => A,
18995
+ a: (_: A) => B,
18996
+ b: (_: B) => Eff
18997
+ ): (...args: Args) => Eff
18998
+ <Eff extends Effect<any, any, any>, A, B, C, Args extends Array<any>>(
18999
+ body: (...args: Args) => A,
19000
+ a: (_: A) => B,
19001
+ b: (_: B) => C,
19002
+ c: (_: C) => Eff
19003
+ ): (...args: Args) => Eff
19004
+ <Eff extends Effect<any, any, any>, A, B, C, D, Args extends Array<any>>(
19005
+ body: (...args: Args) => A,
19006
+ a: (_: A) => B,
19007
+ b: (_: B) => C,
19008
+ c: (_: C) => D,
19009
+ d: (_: D) => Eff
19010
+ ): (...args: Args) => Eff
19011
+ <Eff extends Effect<any, any, any>, A, B, C, D, E, Args extends Array<any>>(
19012
+ body: (...args: Args) => A,
19013
+ a: (_: A) => B,
19014
+ b: (_: B) => C,
19015
+ c: (_: C) => D,
19016
+ d: (_: D) => E,
19017
+ e: (_: E) => Eff
19018
+ ): (...args: Args) => Eff
19019
+ <Eff extends Effect<any, any, any>, A, B, C, D, E, F, Args extends Array<any>>(
19020
+ body: (...args: Args) => A,
19021
+ a: (_: A) => B,
19022
+ b: (_: B) => C,
19023
+ c: (_: C) => D,
19024
+ d: (_: D) => E,
19025
+ e: (_: E) => F,
19026
+ f: (_: E) => Eff
19027
+ ): (...args: Args) => Eff
19028
+ <Eff extends Effect<any, any, any>, A, B, C, D, E, F, G, Args extends Array<any>>(
19029
+ body: (...args: Args) => A,
19030
+ a: (_: A) => B,
19031
+ b: (_: B) => C,
19032
+ c: (_: C) => D,
19033
+ d: (_: D) => E,
19034
+ e: (_: E) => F,
19035
+ f: (_: E) => G,
19036
+ g: (_: G) => Eff
19037
+ ): (...args: Args) => Eff
19038
+ <Eff extends Effect<any, any, any>, A, B, C, D, E, F, G, H, Args extends Array<any>>(
19039
+ body: (...args: Args) => A,
19040
+ a: (_: A) => B,
19041
+ b: (_: B) => C,
19042
+ c: (_: C) => D,
19043
+ d: (_: D) => E,
19044
+ e: (_: E) => F,
19045
+ f: (_: E) => G,
19046
+ g: (_: G) => H,
19047
+ h: (_: H) => Eff
19048
+ ): (...args: Args) => Eff
19049
+ <Eff extends Effect<any, any, any>, A, B, C, D, E, F, G, H, I, Args extends Array<any>>(
19050
+ body: (...args: Args) => A,
19051
+ a: (_: A) => B,
19052
+ b: (_: B) => C,
19053
+ c: (_: C) => D,
19054
+ d: (_: D) => E,
19055
+ e: (_: E) => F,
19056
+ f: (_: E) => G,
19057
+ g: (_: G) => H,
19058
+ h: (_: H) => I,
19059
+ i: (_: H) => Eff
19060
+ ): (...args: Args) => Eff
19061
+ }
19062
+ }
19063
+
19064
+ /**
19065
+ * Creates a function that returns an Effect which is automatically traced with a span pointing to the call site.
19066
+ *
19067
+ * The function can be created both using a generator function that can yield effects or using a normal function.
19068
+ *
19069
+ * @since 3.11.0
19070
+ * @category function
19071
+ *
19072
+ * @example
19073
+ * import { Effect } from "effect"
19074
+ *
19075
+ * const logExample = Effect.fn("logExample")(
19076
+ * function*<N extends number>(n: N) {
19077
+ * yield* Effect.annotateCurrentSpan("n", n)
19078
+ * yield* Effect.logInfo(`got: ${n}`)
19079
+ * yield* Effect.fail(new Error())
19080
+ * },
19081
+ * Effect.delay("1 second")
19082
+ * )
19083
+ *
19084
+ * Effect.runFork(
19085
+ * // this location is printed on the stack trace of the following `Effect.logError`
19086
+ * logExample(100).pipe(
19087
+ * Effect.catchAllCause(Effect.logError)
19088
+ * )
19089
+ * )
19090
+ */
19091
+ export const fn: (
19092
+ name: string,
19093
+ options?: Tracer.SpanOptions
19094
+ ) => fn.Gen & fn.NonGen = (name, options) => (body: Function, ...pipeables: Array<any>) => {
19095
+ return function(this: any, ...args: Array<any>) {
19096
+ const limit = Error.stackTraceLimit
19097
+ Error.stackTraceLimit = 2
19098
+ const error = new Error()
19099
+ Error.stackTraceLimit = limit
19100
+ let cache: false | string = false
19101
+ const captureStackTrace = () => {
19102
+ if (cache !== false) {
19103
+ return cache
19104
+ }
19105
+ if (error.stack) {
19106
+ const stack = error.stack.trim().split("\n")
19107
+ cache = stack.slice(2).join("\n").trim()
19108
+ return cache
19109
+ }
19110
+ }
19111
+ let effect: Effect<any, any, any>
19112
+ let fnError: any = undefined
19113
+ try {
19114
+ effect = isGeneratorFunction(body)
19115
+ ? gen(() => internalCall(() => body.apply(this, args)))
19116
+ : body.apply(this, args)
19117
+ } catch (error) {
19118
+ fnError = error
19119
+ effect = die(error)
19120
+ }
19121
+ try {
19122
+ for (const x of pipeables) {
19123
+ effect = x(effect)
19124
+ }
19125
+ } catch (error) {
19126
+ effect = fnError
19127
+ ? failCause(internalCause.sequential(
19128
+ internalCause.die(fnError),
19129
+ internalCause.die(error)
19130
+ ))
19131
+ : die(error)
19132
+ }
19133
+ const opts: any = (options && "captureStackTrace" in options) ? options : { captureStackTrace, ...options }
19134
+ return withSpan(effect, name, opts)
19135
+ }
19136
+ }