effect 3.10.17 → 3.10.19

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 (353) 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 +56 -0
  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/Chunk.js +8 -0
  12. package/dist/cjs/Chunk.js.map +1 -1
  13. package/dist/cjs/Config.js +2 -0
  14. package/dist/cjs/Config.js.map +1 -1
  15. package/dist/cjs/Context.js +24 -0
  16. package/dist/cjs/Context.js.map +1 -1
  17. package/dist/cjs/Cron.js +6 -0
  18. package/dist/cjs/Cron.js.map +1 -1
  19. package/dist/cjs/Data.js +14 -0
  20. package/dist/cjs/Data.js.map +1 -1
  21. package/dist/cjs/DateTime.js +64 -0
  22. package/dist/cjs/DateTime.js.map +1 -1
  23. package/dist/cjs/Duration.js +2 -0
  24. package/dist/cjs/Duration.js.map +1 -1
  25. package/dist/cjs/Effect.js +214 -0
  26. package/dist/cjs/Effect.js.map +1 -1
  27. package/dist/cjs/Either.js +38 -2
  28. package/dist/cjs/Either.js.map +1 -1
  29. package/dist/cjs/FiberHandle.js +6 -0
  30. package/dist/cjs/FiberHandle.js.map +1 -1
  31. package/dist/cjs/FiberMap.js +6 -0
  32. package/dist/cjs/FiberMap.js.map +1 -1
  33. package/dist/cjs/FiberSet.js +6 -0
  34. package/dist/cjs/FiberSet.js.map +1 -1
  35. package/dist/cjs/Function.js +34 -0
  36. package/dist/cjs/Function.js.map +1 -1
  37. package/dist/cjs/GlobalValue.js +2 -0
  38. package/dist/cjs/GlobalValue.js.map +1 -1
  39. package/dist/cjs/HashMap.js.map +1 -1
  40. package/dist/cjs/Iterable.js +18 -0
  41. package/dist/cjs/Iterable.js.map +1 -1
  42. package/dist/cjs/List.js +4 -0
  43. package/dist/cjs/List.js.map +1 -1
  44. package/dist/cjs/Logger.js +26 -0
  45. package/dist/cjs/Logger.js.map +1 -1
  46. package/dist/cjs/Mailbox.js +2 -0
  47. package/dist/cjs/Mailbox.js.map +1 -1
  48. package/dist/cjs/ManagedRuntime.js +2 -0
  49. package/dist/cjs/ManagedRuntime.js.map +1 -1
  50. package/dist/cjs/Metric.js +10 -0
  51. package/dist/cjs/Metric.js.map +1 -1
  52. package/dist/cjs/Micro.js +8 -0
  53. package/dist/cjs/Micro.js.map +1 -1
  54. package/dist/cjs/Number.js +44 -0
  55. package/dist/cjs/Number.js.map +1 -1
  56. package/dist/cjs/Option.js +70 -0
  57. package/dist/cjs/Option.js.map +1 -1
  58. package/dist/cjs/Order.js +2 -0
  59. package/dist/cjs/Order.js.map +1 -1
  60. package/dist/cjs/Ordering.js +4 -0
  61. package/dist/cjs/Ordering.js.map +1 -1
  62. package/dist/cjs/Predicate.js +68 -0
  63. package/dist/cjs/Predicate.js.map +1 -1
  64. package/dist/cjs/Random.js +4 -0
  65. package/dist/cjs/Random.js.map +1 -1
  66. package/dist/cjs/RateLimiter.js +4 -0
  67. package/dist/cjs/RateLimiter.js.map +1 -1
  68. package/dist/cjs/RcMap.js +2 -0
  69. package/dist/cjs/RcMap.js.map +1 -1
  70. package/dist/cjs/RcRef.js +2 -0
  71. package/dist/cjs/RcRef.js.map +1 -1
  72. package/dist/cjs/Record.js +56 -0
  73. package/dist/cjs/Record.js.map +1 -1
  74. package/dist/cjs/Redacted.js +8 -0
  75. package/dist/cjs/Redacted.js.map +1 -1
  76. package/dist/cjs/RegExp.js +4 -0
  77. package/dist/cjs/RegExp.js.map +1 -1
  78. package/dist/cjs/Request.js +4 -0
  79. package/dist/cjs/Request.js.map +1 -1
  80. package/dist/cjs/RequestResolver.js +2 -0
  81. package/dist/cjs/RequestResolver.js.map +1 -1
  82. package/dist/cjs/Runtime.js +6 -0
  83. package/dist/cjs/Runtime.js.map +1 -1
  84. package/dist/cjs/Schema.js +34 -0
  85. package/dist/cjs/Schema.js.map +1 -1
  86. package/dist/cjs/Stream.js +154 -0
  87. package/dist/cjs/Stream.js.map +1 -1
  88. package/dist/cjs/String.js +62 -0
  89. package/dist/cjs/String.js.map +1 -1
  90. package/dist/cjs/Struct.js +12 -0
  91. package/dist/cjs/Struct.js.map +1 -1
  92. package/dist/cjs/Symbol.js +2 -0
  93. package/dist/cjs/Symbol.js.map +1 -1
  94. package/dist/cjs/Trie.js +56 -0
  95. package/dist/cjs/Trie.js.map +1 -1
  96. package/dist/cjs/Tuple.js +18 -0
  97. package/dist/cjs/Tuple.js.map +1 -1
  98. package/dist/cjs/internal/stream.js +1 -1
  99. package/dist/cjs/internal/stream.js.map +1 -1
  100. package/dist/cjs/internal/version.js +1 -1
  101. package/dist/dts/Array.d.ts +534 -0
  102. package/dist/dts/Array.d.ts.map +1 -1
  103. package/dist/dts/BigDecimal.d.ts +116 -0
  104. package/dist/dts/BigDecimal.d.ts.map +1 -1
  105. package/dist/dts/BigInt.d.ts +114 -0
  106. package/dist/dts/BigInt.d.ts.map +1 -1
  107. package/dist/dts/Boolean.d.ts +56 -0
  108. package/dist/dts/Boolean.d.ts.map +1 -1
  109. package/dist/dts/Brand.d.ts +6 -0
  110. package/dist/dts/Brand.d.ts.map +1 -1
  111. package/dist/dts/Chunk.d.ts +30 -0
  112. package/dist/dts/Chunk.d.ts.map +1 -1
  113. package/dist/dts/Config.d.ts +2 -0
  114. package/dist/dts/Config.d.ts.map +1 -1
  115. package/dist/dts/Context.d.ts +44 -0
  116. package/dist/dts/Context.d.ts.map +1 -1
  117. package/dist/dts/Cron.d.ts +6 -0
  118. package/dist/dts/Cron.d.ts.map +1 -1
  119. package/dist/dts/Data.d.ts +26 -0
  120. package/dist/dts/Data.d.ts.map +1 -1
  121. package/dist/dts/DateTime.d.ts +152 -0
  122. package/dist/dts/DateTime.d.ts.map +1 -1
  123. package/dist/dts/Duration.d.ts +2 -0
  124. package/dist/dts/Duration.d.ts.map +1 -1
  125. package/dist/dts/Effect.d.ts +570 -0
  126. package/dist/dts/Effect.d.ts.map +1 -1
  127. package/dist/dts/Either.d.ts +84 -2
  128. package/dist/dts/Either.d.ts.map +1 -1
  129. package/dist/dts/FiberHandle.d.ts +6 -0
  130. package/dist/dts/FiberHandle.d.ts.map +1 -1
  131. package/dist/dts/FiberMap.d.ts +6 -0
  132. package/dist/dts/FiberMap.d.ts.map +1 -1
  133. package/dist/dts/FiberSet.d.ts +6 -0
  134. package/dist/dts/FiberSet.d.ts.map +1 -1
  135. package/dist/dts/Function.d.ts +50 -0
  136. package/dist/dts/Function.d.ts.map +1 -1
  137. package/dist/dts/GlobalValue.d.ts +2 -0
  138. package/dist/dts/GlobalValue.d.ts.map +1 -1
  139. package/dist/dts/HashMap.d.ts +6 -0
  140. package/dist/dts/HashMap.d.ts.map +1 -1
  141. package/dist/dts/Iterable.d.ts +26 -0
  142. package/dist/dts/Iterable.d.ts.map +1 -1
  143. package/dist/dts/List.d.ts +20 -0
  144. package/dist/dts/List.d.ts.map +1 -1
  145. package/dist/dts/Logger.d.ts +34 -0
  146. package/dist/dts/Logger.d.ts.map +1 -1
  147. package/dist/dts/Mailbox.d.ts +2 -0
  148. package/dist/dts/Mailbox.d.ts.map +1 -1
  149. package/dist/dts/ManagedRuntime.d.ts +2 -0
  150. package/dist/dts/ManagedRuntime.d.ts.map +1 -1
  151. package/dist/dts/Metric.d.ts +18 -0
  152. package/dist/dts/Metric.d.ts.map +1 -1
  153. package/dist/dts/Micro.d.ts +14 -0
  154. package/dist/dts/Micro.d.ts.map +1 -1
  155. package/dist/dts/Number.d.ts +104 -0
  156. package/dist/dts/Number.d.ts.map +1 -1
  157. package/dist/dts/Option.d.ts +142 -0
  158. package/dist/dts/Option.d.ts.map +1 -1
  159. package/dist/dts/Order.d.ts +2 -0
  160. package/dist/dts/Order.d.ts.map +1 -1
  161. package/dist/dts/Ordering.d.ts +8 -0
  162. package/dist/dts/Ordering.d.ts.map +1 -1
  163. package/dist/dts/Predicate.d.ts +104 -0
  164. package/dist/dts/Predicate.d.ts.map +1 -1
  165. package/dist/dts/Random.d.ts +4 -0
  166. package/dist/dts/Random.d.ts.map +1 -1
  167. package/dist/dts/RateLimiter.d.ts +4 -0
  168. package/dist/dts/RateLimiter.d.ts.map +1 -1
  169. package/dist/dts/RcMap.d.ts +6 -0
  170. package/dist/dts/RcMap.d.ts.map +1 -1
  171. package/dist/dts/RcRef.d.ts +2 -0
  172. package/dist/dts/RcRef.d.ts.map +1 -1
  173. package/dist/dts/Record.d.ts +136 -0
  174. package/dist/dts/Record.d.ts.map +1 -1
  175. package/dist/dts/Redacted.d.ts +8 -0
  176. package/dist/dts/Redacted.d.ts.map +1 -1
  177. package/dist/dts/RegExp.d.ts +4 -0
  178. package/dist/dts/RegExp.d.ts.map +1 -1
  179. package/dist/dts/Request.d.ts +4 -0
  180. package/dist/dts/Request.d.ts.map +1 -1
  181. package/dist/dts/RequestResolver.d.ts +6 -0
  182. package/dist/dts/RequestResolver.d.ts.map +1 -1
  183. package/dist/dts/Runtime.d.ts +18 -0
  184. package/dist/dts/Runtime.d.ts.map +1 -1
  185. package/dist/dts/Schema.d.ts +58 -0
  186. package/dist/dts/Schema.d.ts.map +1 -1
  187. package/dist/dts/Stream.d.ts +344 -0
  188. package/dist/dts/Stream.d.ts.map +1 -1
  189. package/dist/dts/String.d.ts +94 -0
  190. package/dist/dts/String.d.ts.map +1 -1
  191. package/dist/dts/Struct.d.ts +24 -0
  192. package/dist/dts/Struct.d.ts.map +1 -1
  193. package/dist/dts/Symbol.d.ts +2 -0
  194. package/dist/dts/Symbol.d.ts.map +1 -1
  195. package/dist/dts/Trie.d.ts +132 -0
  196. package/dist/dts/Trie.d.ts.map +1 -1
  197. package/dist/dts/Tuple.d.ts +42 -0
  198. package/dist/dts/Tuple.d.ts.map +1 -1
  199. package/dist/dts/Types.d.ts +24 -0
  200. package/dist/dts/Types.d.ts.map +1 -1
  201. package/dist/esm/Array.js +208 -0
  202. package/dist/esm/Array.js.map +1 -1
  203. package/dist/esm/BigDecimal.js +56 -0
  204. package/dist/esm/BigDecimal.js.map +1 -1
  205. package/dist/esm/BigInt.js +54 -0
  206. package/dist/esm/BigInt.js.map +1 -1
  207. package/dist/esm/Boolean.js +24 -0
  208. package/dist/esm/Boolean.js.map +1 -1
  209. package/dist/esm/Brand.js +4 -0
  210. package/dist/esm/Brand.js.map +1 -1
  211. package/dist/esm/Chunk.js +8 -0
  212. package/dist/esm/Chunk.js.map +1 -1
  213. package/dist/esm/Config.js +2 -0
  214. package/dist/esm/Config.js.map +1 -1
  215. package/dist/esm/Context.js +24 -0
  216. package/dist/esm/Context.js.map +1 -1
  217. package/dist/esm/Cron.js +6 -0
  218. package/dist/esm/Cron.js.map +1 -1
  219. package/dist/esm/Data.js +16 -0
  220. package/dist/esm/Data.js.map +1 -1
  221. package/dist/esm/DateTime.js +64 -0
  222. package/dist/esm/DateTime.js.map +1 -1
  223. package/dist/esm/Duration.js +2 -0
  224. package/dist/esm/Duration.js.map +1 -1
  225. package/dist/esm/Effect.js +220 -0
  226. package/dist/esm/Effect.js.map +1 -1
  227. package/dist/esm/Either.js +40 -2
  228. package/dist/esm/Either.js.map +1 -1
  229. package/dist/esm/FiberHandle.js +6 -0
  230. package/dist/esm/FiberHandle.js.map +1 -1
  231. package/dist/esm/FiberMap.js +6 -0
  232. package/dist/esm/FiberMap.js.map +1 -1
  233. package/dist/esm/FiberSet.js +6 -0
  234. package/dist/esm/FiberSet.js.map +1 -1
  235. package/dist/esm/Function.js +34 -0
  236. package/dist/esm/Function.js.map +1 -1
  237. package/dist/esm/GlobalValue.js +2 -0
  238. package/dist/esm/GlobalValue.js.map +1 -1
  239. package/dist/esm/HashMap.js.map +1 -1
  240. package/dist/esm/Iterable.js +18 -0
  241. package/dist/esm/Iterable.js.map +1 -1
  242. package/dist/esm/List.js +4 -0
  243. package/dist/esm/List.js.map +1 -1
  244. package/dist/esm/Logger.js +26 -0
  245. package/dist/esm/Logger.js.map +1 -1
  246. package/dist/esm/Mailbox.js +2 -0
  247. package/dist/esm/Mailbox.js.map +1 -1
  248. package/dist/esm/ManagedRuntime.js +2 -0
  249. package/dist/esm/ManagedRuntime.js.map +1 -1
  250. package/dist/esm/Metric.js +10 -0
  251. package/dist/esm/Metric.js.map +1 -1
  252. package/dist/esm/Micro.js +10 -0
  253. package/dist/esm/Micro.js.map +1 -1
  254. package/dist/esm/Number.js +44 -0
  255. package/dist/esm/Number.js.map +1 -1
  256. package/dist/esm/Option.js +72 -0
  257. package/dist/esm/Option.js.map +1 -1
  258. package/dist/esm/Order.js +2 -0
  259. package/dist/esm/Order.js.map +1 -1
  260. package/dist/esm/Ordering.js +4 -0
  261. package/dist/esm/Ordering.js.map +1 -1
  262. package/dist/esm/Predicate.js +68 -0
  263. package/dist/esm/Predicate.js.map +1 -1
  264. package/dist/esm/Random.js +4 -0
  265. package/dist/esm/Random.js.map +1 -1
  266. package/dist/esm/RateLimiter.js +4 -0
  267. package/dist/esm/RateLimiter.js.map +1 -1
  268. package/dist/esm/RcMap.js +2 -0
  269. package/dist/esm/RcMap.js.map +1 -1
  270. package/dist/esm/RcRef.js +2 -0
  271. package/dist/esm/RcRef.js.map +1 -1
  272. package/dist/esm/Record.js +56 -0
  273. package/dist/esm/Record.js.map +1 -1
  274. package/dist/esm/Redacted.js +8 -0
  275. package/dist/esm/Redacted.js.map +1 -1
  276. package/dist/esm/RegExp.js +4 -0
  277. package/dist/esm/RegExp.js.map +1 -1
  278. package/dist/esm/Request.js +4 -0
  279. package/dist/esm/Request.js.map +1 -1
  280. package/dist/esm/RequestResolver.js +2 -0
  281. package/dist/esm/RequestResolver.js.map +1 -1
  282. package/dist/esm/Runtime.js +6 -0
  283. package/dist/esm/Runtime.js.map +1 -1
  284. package/dist/esm/Schema.js +34 -0
  285. package/dist/esm/Schema.js.map +1 -1
  286. package/dist/esm/Stream.js +160 -0
  287. package/dist/esm/Stream.js.map +1 -1
  288. package/dist/esm/String.js +62 -0
  289. package/dist/esm/String.js.map +1 -1
  290. package/dist/esm/Struct.js +12 -0
  291. package/dist/esm/Struct.js.map +1 -1
  292. package/dist/esm/Symbol.js +2 -0
  293. package/dist/esm/Symbol.js.map +1 -1
  294. package/dist/esm/Trie.js +56 -0
  295. package/dist/esm/Trie.js.map +1 -1
  296. package/dist/esm/Tuple.js +22 -0
  297. package/dist/esm/Tuple.js.map +1 -1
  298. package/dist/esm/internal/stream.js +1 -1
  299. package/dist/esm/internal/stream.js.map +1 -1
  300. package/dist/esm/internal/version.js +1 -1
  301. package/package.json +1 -1
  302. package/src/Array.ts +534 -0
  303. package/src/BigDecimal.ts +116 -0
  304. package/src/BigInt.ts +114 -0
  305. package/src/Boolean.ts +56 -0
  306. package/src/Brand.ts +6 -0
  307. package/src/Chunk.ts +32 -0
  308. package/src/Config.ts +2 -0
  309. package/src/Context.ts +44 -0
  310. package/src/Cron.ts +6 -0
  311. package/src/Data.ts +26 -0
  312. package/src/DateTime.ts +152 -0
  313. package/src/Duration.ts +2 -0
  314. package/src/Effect.ts +570 -0
  315. package/src/Either.ts +84 -2
  316. package/src/FiberHandle.ts +6 -0
  317. package/src/FiberMap.ts +6 -0
  318. package/src/FiberSet.ts +6 -0
  319. package/src/Function.ts +50 -0
  320. package/src/GlobalValue.ts +2 -0
  321. package/src/HashMap.ts +6 -0
  322. package/src/Iterable.ts +26 -0
  323. package/src/List.ts +24 -0
  324. package/src/Logger.ts +34 -0
  325. package/src/Mailbox.ts +2 -0
  326. package/src/ManagedRuntime.ts +2 -0
  327. package/src/Metric.ts +18 -0
  328. package/src/Micro.ts +14 -0
  329. package/src/Number.ts +104 -0
  330. package/src/Option.ts +142 -0
  331. package/src/Order.ts +2 -0
  332. package/src/Ordering.ts +8 -0
  333. package/src/Predicate.ts +104 -0
  334. package/src/Random.ts +4 -0
  335. package/src/RateLimiter.ts +4 -0
  336. package/src/RcMap.ts +6 -0
  337. package/src/RcRef.ts +2 -0
  338. package/src/Record.ts +136 -0
  339. package/src/Redacted.ts +8 -0
  340. package/src/RegExp.ts +4 -0
  341. package/src/Request.ts +4 -0
  342. package/src/RequestResolver.ts +6 -0
  343. package/src/Runtime.ts +18 -0
  344. package/src/Schema.ts +64 -0
  345. package/src/Stream.ts +344 -0
  346. package/src/String.ts +94 -0
  347. package/src/Struct.ts +24 -0
  348. package/src/Symbol.ts +2 -0
  349. package/src/Trie.ts +132 -0
  350. package/src/Tuple.ts +42 -0
  351. package/src/Types.ts +24 -0
  352. package/src/internal/stream.ts +1 -1
  353. package/src/internal/version.ts +1 -1
@@ -36,6 +36,7 @@ export const isEffect = core.isEffect;
36
36
  * be recomputed upon next evaluation.
37
37
  *
38
38
  * @example
39
+ * ```ts
39
40
  * import { Effect, Console } from "effect"
40
41
  *
41
42
  * let i = 1
@@ -63,6 +64,7 @@ export const isEffect = core.isEffect;
63
64
  * // result 1
64
65
  * // expensive task...
65
66
  * // result 2
67
+ * ```
66
68
  *
67
69
  * @since 2.0.0
68
70
  * @category Caching
@@ -74,6 +76,7 @@ export const cachedWithTTL = circular.cached;
74
76
  * invalidating the cached value before it naturally expires.
75
77
  *
76
78
  * @example
79
+ * ```ts
77
80
  * import { Effect, Console } from "effect"
78
81
  *
79
82
  * let i = 1
@@ -104,6 +107,7 @@ export const cachedWithTTL = circular.cached;
104
107
  * // result 1
105
108
  * // expensive task...
106
109
  * // result 2
110
+ * ```
107
111
  *
108
112
  * @since 2.0.0
109
113
  * @category Caching
@@ -115,6 +119,7 @@ export const cachedInvalidateWithTTL = circular.cachedInvalidateWithTTL;
115
119
  * the logic.
116
120
  *
117
121
  * @example
122
+ * ```ts
118
123
  * import { Effect, Console } from "effect"
119
124
  *
120
125
  * let i = 1
@@ -148,6 +153,7 @@ export const cachedInvalidateWithTTL = circular.cachedInvalidateWithTTL;
148
153
  * // expensive task...
149
154
  * // result 3
150
155
  * // result 3
156
+ * ```
151
157
  *
152
158
  * @since 2.0.0
153
159
  * @category Caching
@@ -159,6 +165,7 @@ export const cached = effect.memoize;
159
165
  * recompute them.
160
166
  *
161
167
  * @example
168
+ * ```ts
162
169
  * import { Effect, Random } from "effect"
163
170
  *
164
171
  * const program = Effect.gen(function* () {
@@ -181,6 +188,7 @@ export const cached = effect.memoize;
181
188
  * // memoized version:
182
189
  * // 5
183
190
  * // 5
191
+ * ```
184
192
  *
185
193
  * @since 2.0.0
186
194
  * @category Caching
@@ -191,6 +199,7 @@ export const cachedFunction = circular.cachedFunction;
191
199
  * called.
192
200
  *
193
201
  * @example
202
+ * ```ts
194
203
  * import { Effect, Console } from "effect"
195
204
  *
196
205
  * const program = Effect.gen(function* () {
@@ -206,6 +215,7 @@ export const cachedFunction = circular.cachedFunction;
206
215
  * // task1
207
216
  * // task1
208
217
  * // task2
218
+ * ```
209
219
  *
210
220
  * @since 2.0.0
211
221
  * @category Caching
@@ -261,6 +271,7 @@ export const once = effect.once;
261
271
  * @see {@link forEach} for iterating over elements and applying an effect.
262
272
  *
263
273
  * @example
274
+ * ```ts
264
275
  * // Title: Combining Effects in Tuples
265
276
  * import { Effect, Console } from "effect"
266
277
  *
@@ -278,6 +289,7 @@ export const once = effect.once;
278
289
  * // 42
279
290
  * // Hello
280
291
  * // [ 42, 'Hello' ]
292
+ * ```
281
293
  *
282
294
  * @example
283
295
  * // Title: Combining Effects in Iterables
@@ -426,6 +438,7 @@ export const all = fiberRuntime.all;
426
438
  * your data and then apply operations to it.
427
439
  *
428
440
  * @example
441
+ * ```ts
429
442
  * import { Effect, pipe } from "effect"
430
443
  *
431
444
  * const task1 = Effect.succeed(1).pipe(
@@ -449,6 +462,7 @@ export const all = fiberRuntime.all;
449
462
  * // timestamp=... level=INFO fiber=#3 message="task2 done"
450
463
  * // timestamp=... level=INFO fiber=#2 message="task1 done"
451
464
  * // [ 1, 'hello' ]
465
+ * ```
452
466
  *
453
467
  * @since 2.0.0
454
468
  * @category Collecting
@@ -510,6 +524,7 @@ export const filter = fiberRuntime.filter;
510
524
  * @see {@link filter} for concurrent filtering without mapping.
511
525
  *
512
526
  * @example
527
+ * ```ts
513
528
  * import { Console, Effect, Option } from "effect"
514
529
  *
515
530
  * const task = (n: number) =>
@@ -530,6 +545,7 @@ export const filter = fiberRuntime.filter;
530
545
  * // task3 done
531
546
  * // task4 done
532
547
  * // [ 2, 4 ]
548
+ * ```
533
549
  *
534
550
  * @since 2.0.0
535
551
  * @category Filtering
@@ -566,6 +582,7 @@ export const findFirst = effect.findFirst;
566
582
  * @see {@link all} for combining multiple effects into one.
567
583
  *
568
584
  * @example
585
+ * ```ts
569
586
  * // Title: Applying Effects to Iterable Elements
570
587
  * import { Effect, Console } from "effect"
571
588
  *
@@ -581,6 +598,7 @@ export const findFirst = effect.findFirst;
581
598
  * // Currently at index 3
582
599
  * // Currently at index 4
583
600
  * // [ 2, 4, 6, 8, 10 ]
601
+ * ```
584
602
  *
585
603
  * @example
586
604
  * // Title: Using discard to Ignore Results
@@ -639,6 +657,7 @@ export const mergeAll = fiberRuntime.mergeAll;
639
657
  * @see {@link validateFirst} for a function that stops at the first success.
640
658
  *
641
659
  * @example
660
+ * ```ts
642
661
  * import { Effect } from "effect"
643
662
  *
644
663
  * // ┌─── Effect<[string[], number[]], never, never>
@@ -654,6 +673,7 @@ export const mergeAll = fiberRuntime.mergeAll;
654
673
  * Effect.runPromise(program).then(console.log, console.error)
655
674
  * // Output:
656
675
  * // [ [ '1 is not even', '3 is not even' ], [ 0, 2, 4 ] ]
676
+ * ```
657
677
  *
658
678
  * @since 2.0.0
659
679
  * @category Error Accumulation
@@ -734,6 +754,7 @@ export const takeWhile = effect.takeWhile;
734
754
  * @see {@link partition} when you need to separate successes and failures instead of losing successes with errors.
735
755
  *
736
756
  * @example
757
+ * ```ts
737
758
  * import { Effect, Console } from "effect"
738
759
  *
739
760
  * // ┌─── Effect<number[], string[], never>
@@ -760,6 +781,7 @@ export const takeWhile = effect.takeWhile;
760
781
  * // failure: [ '4 is not less that 4', '5 is not less that 4' ]
761
782
  * // }
762
783
  * // }
784
+ * ```
763
785
  *
764
786
  * @since 2.0.0
765
787
  * @category Error Accumulation
@@ -781,6 +803,7 @@ export const validateAll = fiberRuntime.validateAll;
781
803
  * @see {@link firstSuccessOf} for a similar function that processes multiple effects and returns the first successful one or the last error.
782
804
  *
783
805
  * @example
806
+ * ```ts
784
807
  * import { Effect, Console } from "effect"
785
808
  *
786
809
  * // ┌─── Effect<number, string[], never>
@@ -797,6 +820,7 @@ export const validateAll = fiberRuntime.validateAll;
797
820
  * // Output:
798
821
  * // item 4
799
822
  * // 4
823
+ * ```
800
824
  *
801
825
  * @since 2.0.0
802
826
  * @category Error Accumulation
@@ -827,6 +851,7 @@ export const validateFirst = fiberRuntime.validateFirst;
827
851
  * behavior of the returned effect.
828
852
  *
829
853
  * @example
854
+ * ```ts
830
855
  * // Title: Wrapping a Callback API
831
856
  * import { Effect } from "effect"
832
857
  * import * as NodeFS from "node:fs"
@@ -847,6 +872,7 @@ export const validateFirst = fiberRuntime.validateFirst;
847
872
  * // ┌─── Effect<Buffer, Error, never>
848
873
  * // ▼
849
874
  * const program = readFile("example.txt")
875
+ * ```
850
876
  *
851
877
  * @example
852
878
  * // Title: Handling Interruption with Cleanup
@@ -937,12 +963,14 @@ export const asyncEffect = _runtime.asyncEffect;
937
963
  * the "this" of the effect.
938
964
  *
939
965
  * @example
966
+ * ```ts
940
967
  * import { Effect } from "effect"
941
968
  *
942
969
  * const throwingFunction = () => { throw new Error() }
943
970
  * const blowUp = Effect.custom(throwingFunction, function() {
944
971
  * return Effect.succeed(this.effect_instruction_i0())
945
972
  * })
973
+ * ```
946
974
  *
947
975
  * @since 2.0.0
948
976
  * @category Creating Effects
@@ -965,6 +993,7 @@ export const withFiberRuntime = core.withFiberRuntime;
965
993
  * @see {@link succeed} to create an effect that represents a successful value.
966
994
  *
967
995
  * @example
996
+ * ```ts
968
997
  * // Title: Creating a Failed Effect
969
998
  * import { Effect } from "effect"
970
999
  *
@@ -973,6 +1002,7 @@ export const withFiberRuntime = core.withFiberRuntime;
973
1002
  * const failure = Effect.fail(
974
1003
  * new Error("Operation failed due to network error")
975
1004
  * )
1005
+ * ```
976
1006
  *
977
1007
  * @since 2.0.0
978
1008
  * @category Creating Effects
@@ -1014,6 +1044,7 @@ export const failCauseSync = core.failCauseSync;
1014
1044
  * @see {@link dieMessage} for a variant that throws a `RuntimeException` with a message.
1015
1045
  *
1016
1046
  * @example
1047
+ * ```ts
1017
1048
  * // Title: Terminating on Division by Zero with a Specified Error
1018
1049
  * import { Effect } from "effect"
1019
1050
  *
@@ -1030,6 +1061,7 @@ export const failCauseSync = core.failCauseSync;
1030
1061
  * // Output:
1031
1062
  * // (FiberFailure) Error: Cannot divide by zero
1032
1063
  * // ...stack trace...
1064
+ * ```
1033
1065
  *
1034
1066
  * @since 2.0.0
1035
1067
  * @category Creating Effects
@@ -1058,6 +1090,7 @@ export const die = core.die;
1058
1090
  * lazily.
1059
1091
  *
1060
1092
  * @example
1093
+ * ```ts
1061
1094
  * // Title: Terminating on Division by Zero with a Specified Message
1062
1095
  * import { Effect } from "effect"
1063
1096
  *
@@ -1074,6 +1107,7 @@ export const die = core.die;
1074
1107
  * // Output:
1075
1108
  * // (FiberFailure) RuntimeException: Cannot divide by zero
1076
1109
  * // ...stack trace...
1110
+ * ```
1077
1111
  *
1078
1112
  * @since 2.0.0
1079
1113
  * @category Creating Effects
@@ -1107,6 +1141,7 @@ export const dieSync = core.dieSync;
1107
1141
  * effects and return the final result at the end.
1108
1142
  *
1109
1143
  * @example
1144
+ * ```ts
1110
1145
  * import { Effect } from "effect"
1111
1146
  *
1112
1147
  * const addServiceCharge = (amount: number) => amount + 1
@@ -1133,6 +1168,7 @@ export const dieSync = core.dieSync;
1133
1168
  * const finalAmount = addServiceCharge(discountedAmount)
1134
1169
  * return `Final amount to charge: ${finalAmount}`
1135
1170
  * })
1171
+ * ```
1136
1172
  *
1137
1173
  * @since 2.0.0
1138
1174
  * @category Creating Effects
@@ -1179,6 +1215,7 @@ export const none = effect.none;
1179
1215
  * @see {@link tryPromise} for a version that can handle failures.
1180
1216
  *
1181
1217
  * @example
1218
+ * ```ts
1182
1219
  * // Title: Delayed Message
1183
1220
  * import { Effect } from "effect"
1184
1221
  *
@@ -1195,6 +1232,7 @@ export const none = effect.none;
1195
1232
  * // ┌─── Effect<string, never, never>
1196
1233
  * // ▼
1197
1234
  * const program = delay("Async operation completed successfully!")
1235
+ * ```
1198
1236
  *
1199
1237
  * @since 2.0.0
1200
1238
  * @category Creating Effects
@@ -1211,6 +1249,7 @@ export const promise = effect.promise;
1211
1249
  * @see {@link fail} to create an effect that represents a failure.
1212
1250
  *
1213
1251
  * @example
1252
+ * ```ts
1214
1253
  * // Title: Creating a Successful Effect
1215
1254
  * import { Effect } from "effect"
1216
1255
  *
@@ -1219,6 +1258,7 @@ export const promise = effect.promise;
1219
1258
  * // ┌─── Effect<number, never, never>
1220
1259
  * // ▼
1221
1260
  * const success = Effect.succeed(42)
1261
+ * ```
1222
1262
  *
1223
1263
  * @since 2.0.0
1224
1264
  * @category Creating Effects
@@ -1253,6 +1293,7 @@ export const succeedSome = effect.succeedSome;
1253
1293
  * - **Unifying Return Types**: Can help TypeScript unify return types in situations where multiple branches of logic return different effects, simplifying type inference.
1254
1294
  *
1255
1295
  * @example
1296
+ * ```ts
1256
1297
  * // Title: Lazy Evaluation with Side Effects
1257
1298
  * import { Effect } from "effect"
1258
1299
  *
@@ -1267,6 +1308,7 @@ export const succeedSome = effect.succeedSome;
1267
1308
  *
1268
1309
  * console.log(Effect.runSync(good)) // Output: 1
1269
1310
  * console.log(Effect.runSync(good)) // Output: 2
1311
+ * ```
1270
1312
  *
1271
1313
  * @example
1272
1314
  * // Title: Recursive Fibonacci
@@ -1339,6 +1381,7 @@ export const suspend = core.suspend;
1339
1381
  * @see {@link try_ | try} for a version that can handle failures.
1340
1382
  *
1341
1383
  * @example
1384
+ * ```ts
1342
1385
  * // Title: Logging a Message
1343
1386
  * import { Effect } from "effect"
1344
1387
  *
@@ -1350,6 +1393,7 @@ export const suspend = core.suspend;
1350
1393
  * // ┌─── Effect<void, never, never>
1351
1394
  * // ▼
1352
1395
  * const program = log("Hello, World!")
1396
+ * ```
1353
1397
  *
1354
1398
  * @since 2.0.0
1355
1399
  * @category Creating Effects
@@ -1392,6 +1436,7 @@ _catch as catch };
1392
1436
  * @see {@link catchAllCause} for a version that can recover from both recoverable and unrecoverable errors.
1393
1437
  *
1394
1438
  * @example
1439
+ * ```ts
1395
1440
  * // Title: Providing Recovery Logic for Recoverable Errors
1396
1441
  * import { Effect, Random } from "effect"
1397
1442
  *
@@ -1424,6 +1469,7 @@ _catch as catch };
1424
1469
  * Effect.succeed(`Recovering from ${error._tag}`)
1425
1470
  * )
1426
1471
  * )
1472
+ * ```
1427
1473
  *
1428
1474
  * @since 2.0.0
1429
1475
  * @category Error handling
@@ -1447,6 +1493,7 @@ export const catchAll = core.catchAll;
1447
1493
  * dynamically loaded plugins, controlled recovery might be needed.
1448
1494
  *
1449
1495
  * @example
1496
+ * ```ts
1450
1497
  * // Title: Recovering from All Errors
1451
1498
  * import { Cause, Effect } from "effect"
1452
1499
  *
@@ -1464,6 +1511,7 @@ export const catchAll = core.catchAll;
1464
1511
  *
1465
1512
  * Effect.runPromise(recovered).then(console.log)
1466
1513
  * // Output: "Recovered from a regular error"
1514
+ * ```
1467
1515
  *
1468
1516
  * @since 2.0.0
1469
1517
  * @category Error handling
@@ -1493,6 +1541,7 @@ export const catchAllCause = core.catchAllCause;
1493
1541
  * dynamically loaded plugins, controlled recovery might be needed.
1494
1542
  *
1495
1543
  * @example
1544
+ * ```ts
1496
1545
  * // Title: Handling All Defects
1497
1546
  * import { Effect, Cause, Console } from "effect"
1498
1547
  *
@@ -1517,6 +1566,7 @@ export const catchAllCause = core.catchAllCause;
1517
1566
  * // _tag: "Success",
1518
1567
  * // value: undefined
1519
1568
  * // }
1569
+ * ```
1520
1570
  *
1521
1571
  * @since 2.0.0
1522
1572
  * @category Error handling
@@ -1534,6 +1584,7 @@ export const catchAllDefect = effect.catchAllDefect;
1534
1584
  * error type unless a user-defined type guard is used to narrow the type.
1535
1585
  *
1536
1586
  * @example
1587
+ * ```ts
1537
1588
  * // Title: Catching Specific Errors with a Predicate
1538
1589
  * import { Effect, Random } from "effect"
1539
1590
  *
@@ -1568,6 +1619,7 @@ export const catchAllDefect = effect.catchAllDefect;
1568
1619
  * () => Effect.succeed("Recovering from HttpError")
1569
1620
  * )
1570
1621
  * )
1622
+ * ```
1571
1623
  *
1572
1624
  * @since 2.0.0
1573
1625
  * @category Error handling
@@ -1588,6 +1640,7 @@ export const catchIf = core.catchIf;
1588
1640
  * @see {@link catchIf} for a version that allows you to recover from errors based on a predicate.
1589
1641
  *
1590
1642
  * @example
1643
+ * ```ts
1591
1644
  * // Title: Handling Specific Errors with Effect.catchSome
1592
1645
  * import { Effect, Random, Option } from "effect"
1593
1646
  *
@@ -1625,6 +1678,7 @@ export const catchIf = core.catchIf;
1625
1678
  * }
1626
1679
  * })
1627
1680
  * )
1681
+ * ```
1628
1682
  *
1629
1683
  * @since 2.0.0
1630
1684
  * @category Error handling
@@ -1664,6 +1718,7 @@ export const catchSomeCause = effect.catchSomeCause;
1664
1718
  * - If the defect does not match, the function returns `Option.none`, allowing the defect to propagate.
1665
1719
  *
1666
1720
  * @example
1721
+ * ```ts
1667
1722
  * // Title: Handling Specific Defects
1668
1723
  * import { Effect, Cause, Option, Console } from "effect"
1669
1724
  *
@@ -1694,6 +1749,7 @@ export const catchSomeCause = effect.catchSomeCause;
1694
1749
  * // defect: { _tag: 'RuntimeException' }
1695
1750
  * // }
1696
1751
  * // }
1752
+ * ```
1697
1753
  *
1698
1754
  * @since 2.0.0
1699
1755
  * @category Error handling
@@ -1717,6 +1773,7 @@ export const catchSomeDefect = effect.catchSomeDefect;
1717
1773
  * types at once.
1718
1774
  *
1719
1775
  * @example
1776
+ * ```ts
1720
1777
  * // Title: Handling Errors by Tag
1721
1778
  * import { Effect, Random } from "effect"
1722
1779
  *
@@ -1750,6 +1807,7 @@ export const catchSomeDefect = effect.catchSomeDefect;
1750
1807
  * Effect.succeed("Recovering from HttpError")
1751
1808
  * )
1752
1809
  * )
1810
+ * ```
1753
1811
  *
1754
1812
  * @since 2.0.0
1755
1813
  * @category Error handling
@@ -1770,6 +1828,7 @@ export const catchTag = effect.catchTag;
1770
1828
  * field is used to identify and match errors.
1771
1829
  *
1772
1830
  * @example
1831
+ * ```ts
1773
1832
  * // Title: Handling Multiple Tagged Error Types at Once
1774
1833
  * import { Effect, Random } from "effect"
1775
1834
  *
@@ -1805,6 +1864,7 @@ export const catchTag = effect.catchTag;
1805
1864
  * Effect.succeed(`Recovering from ValidationError`)
1806
1865
  * })
1807
1866
  * )
1867
+ * ```
1808
1868
  *
1809
1869
  * @since 2.0.0
1810
1870
  * @category Error handling
@@ -1822,6 +1882,7 @@ export const catchTags = effect.catchTags;
1822
1882
  * interruptions, etc.).
1823
1883
  *
1824
1884
  * @example
1885
+ * ```ts
1825
1886
  * import { Effect, Console } from "effect"
1826
1887
  *
1827
1888
  * // ┌─── Effect<number, string, never>
@@ -1834,6 +1895,7 @@ export const catchTags = effect.catchTags;
1834
1895
  * const cause = yield* Effect.cause(program)
1835
1896
  * yield* Console.log(cause)
1836
1897
  * })
1898
+ * ```
1837
1899
  *
1838
1900
  * @since 2.0.0
1839
1901
  * @category Error handling
@@ -1855,6 +1917,7 @@ export const eventually = effect.eventually;
1855
1917
  * side effects of the effect and do not need to handle or process its outcome.
1856
1918
  *
1857
1919
  * @example
1920
+ * ```ts
1858
1921
  * import { Effect } from "effect"
1859
1922
  *
1860
1923
  * // ┌─── Effect<number, string, never>
@@ -1864,6 +1927,7 @@ export const eventually = effect.eventually;
1864
1927
  * // ┌─── Effect<void, never, never>
1865
1928
  * // ▼
1866
1929
  * const program = Effect.ignore(task)
1930
+ * ```
1867
1931
  *
1868
1932
  * @since 2.0.0
1869
1933
  * @category Error handling
@@ -1889,6 +1953,7 @@ export const ignoreLogged = effect.ignoreLogged;
1889
1953
  * it easier to manage and respond to errors from multiple operations at once.
1890
1954
  *
1891
1955
  * @example
1956
+ * ```ts
1892
1957
  * import { Effect } from "effect"
1893
1958
  *
1894
1959
  * const fail1 = Effect.fail("Oh uh!")
@@ -1907,6 +1972,7 @@ export const ignoreLogged = effect.ignoreLogged;
1907
1972
  * // _tag: 'Failure',
1908
1973
  * // cause: { _id: 'Cause', _tag: 'Fail', failure: [ 'Oh uh!', 'Oh no!' ] }
1909
1974
  * // }
1975
+ * ```
1910
1976
  *
1911
1977
  * @since 2.0.0
1912
1978
  * @category Error handling
@@ -1928,6 +1994,7 @@ export const parallelErrors = effect.parallelErrors;
1928
1994
  * @see {@link unsandbox} to restore the original error handling.
1929
1995
  *
1930
1996
  * @example
1997
+ * ```ts
1931
1998
  * import { Effect, Console } from "effect"
1932
1999
  *
1933
2000
  * // ┌─── Effect<string, Error, never>
@@ -1962,6 +2029,7 @@ export const parallelErrors = effect.parallelErrors;
1962
2029
  * // Output:
1963
2030
  * // Caught a defect: Oh uh!
1964
2031
  * // fallback result on failure
2032
+ * ```
1965
2033
  *
1966
2034
  * @since 2.0.0
1967
2035
  * @category Error handling
@@ -1984,6 +2052,7 @@ export const sandbox = effect.sandbox;
1984
2052
  * @see {@link retryOrElse} for a version that allows you to run a fallback.
1985
2053
  *
1986
2054
  * @example
2055
+ * ```ts
1987
2056
  * import { Effect, Schedule } from "effect"
1988
2057
  *
1989
2058
  * let count = 0
@@ -2012,6 +2081,7 @@ export const sandbox = effect.sandbox;
2012
2081
  * // failure
2013
2082
  * // success
2014
2083
  * // yay!
2084
+ * ```
2015
2085
  *
2016
2086
  * @since 2.0.0
2017
2087
  * @category Error handling
@@ -2029,6 +2099,7 @@ export const retry = _schedule.retry_combined;
2029
2099
  * @see {@link retry} for a version that does not run a fallback effect.
2030
2100
  *
2031
2101
  * @example
2102
+ * ```ts
2032
2103
  * import { Effect, Schedule, Console } from "effect"
2033
2104
  *
2034
2105
  * let count = 0
@@ -2060,6 +2131,7 @@ export const retry = _schedule.retry_combined;
2060
2131
  * // failure
2061
2132
  * // orElse
2062
2133
  * // default value
2134
+ * ```
2063
2135
  *
2064
2136
  * @since 2.0.0
2065
2137
  * @category Error handling
@@ -2091,6 +2163,7 @@ export {
2091
2163
  * throw errors.
2092
2164
  *
2093
2165
  * @example
2166
+ * ```ts
2094
2167
  * // Title: Safe JSON Parsing
2095
2168
  * import { Effect } from "effect"
2096
2169
  *
@@ -2102,6 +2175,7 @@ export {
2102
2175
  * // ▼
2103
2176
  * const program = parse("")
2104
2177
  *
2178
+ * ```
2105
2179
  * @example
2106
2180
  * // Title: Custom Error Handling
2107
2181
  * import { Effect } from "effect"
@@ -2172,6 +2246,7 @@ export const tryMapPromise = effect.tryMapPromise;
2172
2246
  * @see {@link promise} if the effectful computation is asynchronous and does not throw errors.
2173
2247
  *
2174
2248
  * @example
2249
+ * ```ts
2175
2250
  * // Title: Fetching a TODO Item
2176
2251
  * import { Effect } from "effect"
2177
2252
  *
@@ -2184,6 +2259,7 @@ export const tryMapPromise = effect.tryMapPromise;
2184
2259
  * // ┌─── Effect<Response, UnknownException, never>
2185
2260
  * // ▼
2186
2261
  * const program = getTodo(1)
2262
+ * ```
2187
2263
  *
2188
2264
  * @example
2189
2265
  * // Title: Custom Error Handling
@@ -2266,6 +2342,7 @@ export const checkInterruptible = core.checkInterruptible;
2266
2342
  * @see {@link Effect.uninterruptible} for creating an uninterruptible effect.
2267
2343
  *
2268
2344
  * @example
2345
+ * ```ts
2269
2346
  * import { Effect } from "effect"
2270
2347
  *
2271
2348
  * const longRunningTask = Effect.gen(function* () {
@@ -2295,6 +2372,7 @@ export const checkInterruptible = core.checkInterruptible;
2295
2372
  * // }
2296
2373
  * // }
2297
2374
  * // Heavy processing done.
2375
+ * ```
2298
2376
  *
2299
2377
  * @since 2.0.0
2300
2378
  * @category Interruption
@@ -2340,6 +2418,7 @@ export const uninterruptibleMask = core.uninterruptibleMask;
2340
2418
  * or failing with specified error if the predicate fails
2341
2419
  *
2342
2420
  * @example
2421
+ * ```ts
2343
2422
  * import { Effect } from "effect"
2344
2423
  *
2345
2424
  * const isPositive = (n: number): boolean => n > 0
@@ -2349,6 +2428,7 @@ export const uninterruptibleMask = core.uninterruptibleMask;
2349
2428
  *
2350
2429
  * // fails with `"0 is not positive"`
2351
2430
  * Effect.liftPredicate(0, isPositive, n => `${n} is not positive`)
2431
+ * ```
2352
2432
  *
2353
2433
  * @category Condition Checking
2354
2434
  * @since 3.4.0
@@ -2361,6 +2441,7 @@ export const liftPredicate = effect.liftPredicate;
2361
2441
  * replace it with a new constant value.
2362
2442
  *
2363
2443
  * @example
2444
+ * ```ts
2364
2445
  * // Title: Replacing a Value
2365
2446
  * import { pipe, Effect } from "effect"
2366
2447
  *
@@ -2369,6 +2450,7 @@ export const liftPredicate = effect.liftPredicate;
2369
2450
  *
2370
2451
  * Effect.runPromise(program).then(console.log)
2371
2452
  * // Output: "new value"
2453
+ * ```
2372
2454
  *
2373
2455
  * @since 2.0.0
2374
2456
  * @category Mapping
@@ -2412,6 +2494,7 @@ export const asVoid = core.asVoid;
2412
2494
  * treat an error as a valid result.
2413
2495
  *
2414
2496
  * @example
2497
+ * ```ts
2415
2498
  * import { Effect } from "effect"
2416
2499
  *
2417
2500
  * // ┌─── Effect<number, string, never>
@@ -2421,6 +2504,7 @@ export const asVoid = core.asVoid;
2421
2504
  * // ┌─── Effect<string, number, never>
2422
2505
  * // ▼
2423
2506
  * const flipped = Effect.flip(program)
2507
+ * ```
2424
2508
  *
2425
2509
  * @since 2.0.0
2426
2510
  * @category Mapping
@@ -2461,6 +2545,7 @@ export const flipWith = effect.flipWith;
2461
2545
  * @see {@link flatMap} or {@link andThen} for a version that can return a new effect.
2462
2546
  *
2463
2547
  * @example
2548
+ * ```ts
2464
2549
  * // Title: Adding a Service Charge
2465
2550
  * import { pipe, Effect } from "effect"
2466
2551
  *
@@ -2475,6 +2560,7 @@ export const flipWith = effect.flipWith;
2475
2560
  *
2476
2561
  * Effect.runPromise(finalAmount).then(console.log)
2477
2562
  * // Output: 101
2563
+ * ```
2478
2564
  * @since 2.0.0
2479
2565
  * @category Mapping
2480
2566
  */
@@ -2499,6 +2585,7 @@ export const map = core.map;
2499
2585
  * input collection type.
2500
2586
  *
2501
2587
  * @example
2588
+ * ```ts
2502
2589
  * import { Effect } from "effect"
2503
2590
  *
2504
2591
  * // Define an initial state and a transformation function
@@ -2517,6 +2604,7 @@ export const map = core.map;
2517
2604
  * // Output:
2518
2605
  * // 6
2519
2606
  * // [ 'A', 'BB', 'CCC' ]
2607
+ * ```
2520
2608
  *
2521
2609
  * @since 2.0.0
2522
2610
  * @category Mapping
@@ -2535,6 +2623,7 @@ export const mapAccum = effect.mapAccum;
2535
2623
  * @see {@link mapError} for a version that operates on the error channel.
2536
2624
  *
2537
2625
  * @example
2626
+ * ```ts
2538
2627
  * import { Effect } from "effect"
2539
2628
  *
2540
2629
  * // ┌─── Effect<number, string, never>
@@ -2547,6 +2636,7 @@ export const mapAccum = effect.mapAccum;
2547
2636
  * onFailure: (message) => new Error(message),
2548
2637
  * onSuccess: (n) => n > 0
2549
2638
  * })
2639
+ * ```
2550
2640
  *
2551
2641
  * @since 2.0.0
2552
2642
  * @category Mapping
@@ -2566,6 +2656,7 @@ export const mapBoth = core.mapBoth;
2566
2656
  * @see {@link orElseFail} if you want to replace the error with a new one.
2567
2657
  *
2568
2658
  * @example
2659
+ * ```ts
2569
2660
  * import { Effect } from "effect"
2570
2661
  *
2571
2662
  * // ┌─── Effect<number, string, never>
@@ -2578,6 +2669,7 @@ export const mapBoth = core.mapBoth;
2578
2669
  * simulatedTask,
2579
2670
  * (message) => new Error(message)
2580
2671
  * )
2672
+ * ```
2581
2673
  *
2582
2674
  * @since 2.0.0
2583
2675
  * @category Mapping
@@ -2605,6 +2697,7 @@ export const mapErrorCause = effect.mapErrorCause;
2605
2697
  * errors as part of the outcome.
2606
2698
  *
2607
2699
  * @example
2700
+ * ```ts
2608
2701
  * import { Effect } from "effect"
2609
2702
  *
2610
2703
  * // ┌─── Effect<number, string, never>
@@ -2614,6 +2707,7 @@ export const mapErrorCause = effect.mapErrorCause;
2614
2707
  * // ┌─── Effect<number | string, never, never>
2615
2708
  * // ▼
2616
2709
  * const recovered = Effect.merge(program)
2710
+ * ```
2617
2711
  *
2618
2712
  * @since 2.0.0
2619
2713
  * @category Mapping
@@ -3085,6 +3179,7 @@ export const timedWith = effect.timedWith;
3085
3179
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
3086
3180
  *
3087
3181
  * @example
3182
+ * ```ts
3088
3183
  * import { Effect } from "effect"
3089
3184
  *
3090
3185
  * const task = Effect.gen(function* () {
@@ -3110,6 +3205,7 @@ export const timedWith = effect.timedWith;
3110
3205
  * // failure: { _tag: 'TimeoutException' }
3111
3206
  * // }
3112
3207
  * // }
3208
+ * ```
3113
3209
  *
3114
3210
  * @since 2.0.0
3115
3211
  * @category delays & timeouts
@@ -3135,6 +3231,7 @@ export const timeout = circular.timeout;
3135
3231
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
3136
3232
  *
3137
3233
  * @example
3234
+ * ```ts
3138
3235
  * import { Effect } from "effect"
3139
3236
  *
3140
3237
  * const task = Effect.gen(function* () {
@@ -3158,6 +3255,7 @@ export const timeout = circular.timeout;
3158
3255
  * // { _id: 'Option', _tag: 'Some', value: 'Result' },
3159
3256
  * // { _id: 'Option', _tag: 'None' }
3160
3257
  * // ]
3258
+ * ```
3161
3259
  *
3162
3260
  * @since 3.1.0
3163
3261
  * @category delays & timeouts
@@ -3182,6 +3280,7 @@ export const timeoutOption = circular.timeoutOption;
3182
3280
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
3183
3281
  *
3184
3282
  * @example
3283
+ * ```ts
3185
3284
  * import { Effect } from "effect"
3186
3285
  *
3187
3286
  * const task = Effect.gen(function* () {
@@ -3214,6 +3313,7 @@ export const timeoutOption = circular.timeoutOption;
3214
3313
  * // failure: MyTimeoutError { _tag: 'MyTimeoutError' }
3215
3314
  * // }
3216
3315
  * // }
3316
+ * ```
3217
3317
  *
3218
3318
  * @since 2.0.0
3219
3319
  * @category delays & timeouts
@@ -3237,6 +3337,7 @@ export const timeoutFail = circular.timeoutFail;
3237
3337
  * @see {@link timeoutTo} for a version that allows specifying both success and timeout handlers.
3238
3338
  *
3239
3339
  * @example
3340
+ * ```ts
3240
3341
  * import { Effect, Cause } from "effect"
3241
3342
  *
3242
3343
  * const task = Effect.gen(function* () {
@@ -3261,6 +3362,7 @@ export const timeoutFail = circular.timeoutFail;
3261
3362
  * // _tag: 'Failure',
3262
3363
  * // cause: { _id: 'Cause', _tag: 'Die', defect: 'Timed out!' }
3263
3364
  * // }
3365
+ * ```
3264
3366
  *
3265
3367
  * @since 2.0.0
3266
3368
  * @category delays & timeouts
@@ -3288,6 +3390,7 @@ export const timeoutFailCause = circular.timeoutFailCause;
3288
3390
  * @see {@link timeoutFailCause} for a version that raises a custom defect.
3289
3391
  *
3290
3392
  * @example
3393
+ * ```ts
3291
3394
  * import { Effect, Either } from "effect"
3292
3395
  *
3293
3396
  * const task = Effect.gen(function* () {
@@ -3315,6 +3418,7 @@ export const timeoutFailCause = circular.timeoutFailCause;
3315
3418
  * // _tag: "Left",
3316
3419
  * // left: "Timed out!"
3317
3420
  * // }
3421
+ * ```
3318
3422
  *
3319
3423
  * @since 2.0.0
3320
3424
  * @category delays & timeouts
@@ -3381,6 +3485,7 @@ export const mapInputContext = core.mapInputContext;
3381
3485
  * @see {@link provideService} for providing a service to an effect.
3382
3486
  *
3383
3487
  * @example
3488
+ * ```ts
3384
3489
  * import { Context, Effect, Layer } from "effect"
3385
3490
  *
3386
3491
  * class Database extends Context.Tag("Database")<
@@ -3412,6 +3517,7 @@ export const mapInputContext = core.mapInputContext;
3412
3517
  * // Output:
3413
3518
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
3414
3519
  * // []
3520
+ * ```
3415
3521
  *
3416
3522
  * @since 2.0.0
3417
3523
  * @category Context
@@ -3430,6 +3536,7 @@ export const provide = layer.effect_provide;
3430
3536
  * @see {@link provide} for providing multiple layers to an effect.
3431
3537
  *
3432
3538
  * @example
3539
+ * ```ts
3433
3540
  * import { Effect, Context } from "effect"
3434
3541
  *
3435
3542
  * // Declaring a tag for a service that generates random numbers
@@ -3457,6 +3564,7 @@ export const provide = layer.effect_provide;
3457
3564
  * Effect.runPromise(runnable)
3458
3565
  * // Example Output:
3459
3566
  * // random number: 0.8241872233134417
3567
+ * ```
3460
3568
  *
3461
3569
  * @since 2.0.0
3462
3570
  * @category Context
@@ -3527,6 +3635,7 @@ export const updateService = effect.updateService;
3527
3635
  * @see {@link let_ let}
3528
3636
  *
3529
3637
  * @example
3638
+ * ```ts
3530
3639
  * import { Effect, pipe } from "effect"
3531
3640
  *
3532
3641
  * const result = pipe(
@@ -3536,6 +3645,7 @@ export const updateService = effect.updateService;
3536
3645
  * Effect.let("sum", ({ x, y }) => x + y)
3537
3646
  * )
3538
3647
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
3648
+ * ```
3539
3649
  *
3540
3650
  * @category Do notation
3541
3651
  * @since 2.0.0
@@ -3556,6 +3666,7 @@ export const Do = effect.Do;
3556
3666
  * @see {@link let_ let}
3557
3667
  *
3558
3668
  * @example
3669
+ * ```ts
3559
3670
  * import { Effect, pipe } from "effect"
3560
3671
  *
3561
3672
  * const result = pipe(
@@ -3565,6 +3676,7 @@ export const Do = effect.Do;
3565
3676
  * Effect.let("sum", ({ x, y }) => x + y)
3566
3677
  * )
3567
3678
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
3679
+ * ```
3568
3680
  *
3569
3681
  * @category Do notation
3570
3682
  * @since 2.0.0
@@ -3576,6 +3688,7 @@ export const bind = effect.bind;
3576
3688
  * results in a Do notation pipeline.
3577
3689
  *
3578
3690
  * @example
3691
+ * ```ts
3579
3692
  * import { Effect, Either, pipe } from "effect"
3580
3693
  *
3581
3694
  * const result = pipe(
@@ -3587,6 +3700,7 @@ export const bind = effect.bind;
3587
3700
  * }), { concurrency: 2, mode: "either" })
3588
3701
  * )
3589
3702
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, a: Either.right(2), b: Either.left("oops") })
3703
+ * ```
3590
3704
  *
3591
3705
  * @category Do notation
3592
3706
  * @since 3.7.0
@@ -3607,6 +3721,7 @@ export const bindAll = circular.bindAll;
3607
3721
  * @see {@link let_ let}
3608
3722
  *
3609
3723
  * @example
3724
+ * ```ts
3610
3725
  * import { Effect, pipe } from "effect"
3611
3726
  *
3612
3727
  * const result = pipe(
@@ -3616,6 +3731,7 @@ export const bindAll = circular.bindAll;
3616
3731
  * Effect.let("sum", ({ x, y }) => x + y)
3617
3732
  * )
3618
3733
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
3734
+ * ```
3619
3735
  *
3620
3736
  * @category Do notation
3621
3737
  * @since 2.0.0
@@ -3638,6 +3754,7 @@ export {
3638
3754
  * @see {@link bindTo}
3639
3755
  *
3640
3756
  * @example
3757
+ * ```ts
3641
3758
  * import { Effect, pipe } from "effect"
3642
3759
  *
3643
3760
  * const result = pipe(
@@ -3648,6 +3765,7 @@ export {
3648
3765
  * )
3649
3766
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
3650
3767
  *
3768
+ * ```
3651
3769
  * @category Do notation
3652
3770
  * @since 2.0.0
3653
3771
  */
@@ -3670,6 +3788,7 @@ let_ as let };
3670
3788
  * @see {@link exit} for a version that uses `Exit` instead.
3671
3789
  *
3672
3790
  * @example
3791
+ * ```ts
3673
3792
  * // Title: Using Effect.option to Handle Errors
3674
3793
  * import { Effect } from "effect"
3675
3794
  *
@@ -3702,6 +3821,7 @@ let_ as let };
3702
3821
  * // _tag: 'Failure',
3703
3822
  * // cause: { _id: 'Cause', _tag: 'Die', defect: 'Boom!' }
3704
3823
  * // }
3824
+ * ```
3705
3825
  *
3706
3826
  * @since 2.0.0
3707
3827
  * @category Outcome Encapsulation
@@ -3726,6 +3846,7 @@ export const option = effect.option;
3726
3846
  * @see {@link exit} for a version that uses `Exit` instead.
3727
3847
  *
3728
3848
  * @example
3849
+ * ```ts
3729
3850
  * import { Effect, Either, Random } from "effect"
3730
3851
  *
3731
3852
  * class HttpError {
@@ -3761,6 +3882,7 @@ export const option = effect.option;
3761
3882
  * onRight: (value) => value // Do nothing in case of success
3762
3883
  * })
3763
3884
  * })
3885
+ * ```
3764
3886
  *
3765
3887
  * @since 2.0.0
3766
3888
  * @category Outcome Encapsulation
@@ -3783,6 +3905,7 @@ export const either = core.either;
3783
3905
  * @see {@link either} for a version that uses `Either` instead.
3784
3906
  *
3785
3907
  * @example
3908
+ * ```ts
3786
3909
  * import { Effect, Cause, Console, Exit } from "effect"
3787
3910
  *
3788
3911
  * // Simulating a runtime error
@@ -3814,6 +3937,7 @@ export const either = core.either;
3814
3937
  * // _tag: "Success",
3815
3938
  * // value: undefined
3816
3939
  * // }
3940
+ * ```
3817
3941
  *
3818
3942
  * @since 2.0.0
3819
3943
  * @category Outcome Encapsulation
@@ -3830,6 +3954,7 @@ export const exit = core.exit;
3830
3954
  * failure. Additionally, if the effect is interrupted, the `Deferred` will also be interrupted.
3831
3955
  *
3832
3956
  * @example
3957
+ * ```ts
3833
3958
  * import { Deferred, Effect } from "effect"
3834
3959
  *
3835
3960
  * // Define an effect that succeeds
@@ -3853,6 +3978,7 @@ export const exit = core.exit;
3853
3978
  * // Output:
3854
3979
  * // 42
3855
3980
  * // true
3981
+ * ```
3856
3982
  *
3857
3983
  * @since 2.0.0
3858
3984
  * @category Synchronization Utilities
@@ -3868,6 +3994,7 @@ export {
3868
3994
  * is executed. If it is `false`, the `onFalse` effect is executed instead.
3869
3995
  *
3870
3996
  * @example
3997
+ * ```ts
3871
3998
  * // Title: Simulating a Coin Flip
3872
3999
  * import { Effect, Random, Console } from "effect"
3873
4000
  *
@@ -3878,6 +4005,7 @@ export {
3878
4005
  *
3879
4006
  * Effect.runFork(flipTheCoin)
3880
4007
  *
4008
+ * ```
3881
4009
  * @since 2.0.0
3882
4010
  * @category Conditional Operators
3883
4011
  */
@@ -3917,6 +4045,7 @@ export const filterOrElse = effect.filterOrElse;
3917
4045
  * Let's explore this concept through an example:
3918
4046
  *
3919
4047
  * @example
4048
+ * ```ts
3920
4049
  * import { Effect, pipe } from "effect"
3921
4050
  *
3922
4051
  * // Define a user interface
@@ -3937,6 +4066,7 @@ export const filterOrElse = effect.filterOrElse;
3937
4066
  * // 'user' now has the type `User` (not `User | null`)
3938
4067
  * Effect.andThen((user) => user.name)
3939
4068
  * )
4069
+ * ```
3940
4070
  *
3941
4071
  * @since 2.0.0
3942
4072
  * @category Filtering
@@ -3980,6 +4110,7 @@ export const unlessEffect = effect.unlessEffect;
3980
4110
  * @see {@link unless} for a version that executes the effect when the condition is `false`.
3981
4111
  *
3982
4112
  * @example
4113
+ * ```ts
3983
4114
  * // Title: Conditional Effect Execution
3984
4115
  * import { Effect, Option } from "effect"
3985
4116
  *
@@ -4005,6 +4136,7 @@ export const unlessEffect = effect.unlessEffect;
4005
4136
  * // _id: "Option",
4006
4137
  * // _tag: "None"
4007
4138
  * // }
4139
+ * ```
4008
4140
  *
4009
4141
  * @since 2.0.0
4010
4142
  * @category Conditional Operators
@@ -4028,6 +4160,7 @@ export const when = effect.when;
4028
4160
  * @see {@link unlessEffect} for a version that executes the effect when the condition is `false`.
4029
4161
  *
4030
4162
  * @example
4163
+ * ```ts
4031
4164
  * // Title: Using an Effect as a Condition
4032
4165
  * import { Effect, Random } from "effect"
4033
4166
  *
@@ -4038,6 +4171,7 @@ export const when = effect.when;
4038
4171
  * console.log(Effect.runSync(randomIntOption))
4039
4172
  * // Example Output:
4040
4173
  * // { _id: 'Option', _tag: 'Some', value: 8609104974198840 }
4174
+ * ```
4041
4175
  *
4042
4176
  * @since 2.0.0
4043
4177
  * @category Conditional Operators
@@ -4088,6 +4222,7 @@ export const whenRef = effect.whenRef;
4088
4222
  * changing the original one.
4089
4223
  *
4090
4224
  * @example
4225
+ * ```ts
4091
4226
  * import { pipe, Effect } from "effect"
4092
4227
  *
4093
4228
  * // Function to apply a discount safely to a transaction amount
@@ -4110,6 +4245,7 @@ export const whenRef = effect.whenRef;
4110
4245
  *
4111
4246
  * Effect.runPromise(finalAmount).then(console.log)
4112
4247
  * // Output: 95
4248
+ * ```
4113
4249
  *
4114
4250
  * @since 2.0.0
4115
4251
  * @category sequencing
@@ -4149,6 +4285,7 @@ export const flatMap = core.flatMap;
4149
4285
  * treating them as effects.
4150
4286
  *
4151
4287
  * @example
4288
+ * ```ts
4152
4289
  * // Title: Applying a Discount Based on Fetched Amount
4153
4290
  * import { pipe, Effect } from "effect"
4154
4291
  *
@@ -4183,6 +4320,7 @@ export const flatMap = core.flatMap;
4183
4320
  *
4184
4321
  * Effect.runPromise(result2).then(console.log)
4185
4322
  * // Output: 190
4323
+ * ```
4186
4324
  *
4187
4325
  * @since 2.0.0
4188
4326
  * @category sequencing
@@ -4263,6 +4401,7 @@ export const summarized = effect.summarized;
4263
4401
  * will fail too.
4264
4402
  *
4265
4403
  * @example
4404
+ * ```ts
4266
4405
  * // Title: Logging a step in a pipeline
4267
4406
  * import { Console, Effect, pipe } from "effect"
4268
4407
  *
@@ -4290,6 +4429,7 @@ export const summarized = effect.summarized;
4290
4429
  * // Output:
4291
4430
  * // Apply a discount to: 100
4292
4431
  * // 95
4432
+ * ```
4293
4433
  *
4294
4434
  * @since 2.0.0
4295
4435
  * @category sequencing
@@ -4307,6 +4447,7 @@ export const tap = core.tap;
4307
4447
  * altering the result.
4308
4448
  *
4309
4449
  * @example
4450
+ * ```ts
4310
4451
  * import { Effect, Random, Console } from "effect"
4311
4452
  *
4312
4453
  * // Simulate a task that might fail
@@ -4326,6 +4467,7 @@ export const tap = core.tap;
4326
4467
  * Effect.runFork(tapping)
4327
4468
  * // Example Output:
4328
4469
  * // failure: random number is negative
4470
+ * ```
4329
4471
  *
4330
4472
  * @since 2.0.0
4331
4473
  * @category sequencing
@@ -4342,6 +4484,7 @@ export const tapBoth = effect.tapBoth;
4342
4484
  * severe errors.
4343
4485
  *
4344
4486
  * @example
4487
+ * ```ts
4345
4488
  * import { Effect, Console } from "effect"
4346
4489
  *
4347
4490
  * // Simulate a task that fails with a recoverable error
@@ -4369,6 +4512,7 @@ export const tapBoth = effect.tapBoth;
4369
4512
  * // Output:
4370
4513
  * // defect: RuntimeException: Something went wrong
4371
4514
  * // ... stack trace ...
4515
+ * ```
4372
4516
  *
4373
4517
  * @since 2.0.0
4374
4518
  * @category sequencing
@@ -4384,6 +4528,7 @@ export const tapDefect = effect.tapDefect;
4384
4528
  * while the operation you provide can inspect or act on it.
4385
4529
  *
4386
4530
  * @example
4531
+ * ```ts
4387
4532
  * import { Effect, Console } from "effect"
4388
4533
  *
4389
4534
  * // Simulate a task that fails with an error
@@ -4397,6 +4542,7 @@ export const tapDefect = effect.tapDefect;
4397
4542
  * Effect.runFork(tapping)
4398
4543
  * // Output:
4399
4544
  * // expected error: NetworkError
4545
+ * ```
4400
4546
  *
4401
4547
  * @since 2.0.0
4402
4548
  * @category sequencing
@@ -4412,6 +4558,7 @@ export const tapError = effect.tapError;
4412
4558
  * without modifying the error or the overall result of the effect.
4413
4559
  *
4414
4560
  * @example
4561
+ * ```ts
4415
4562
  * import { Effect, Console } from "effect"
4416
4563
  *
4417
4564
  * class NetworkError {
@@ -4436,6 +4583,7 @@ export const tapError = effect.tapError;
4436
4583
  * Effect.runFork(tapping)
4437
4584
  * // Output:
4438
4585
  * // expected error: 504
4586
+ * ```
4439
4587
  *
4440
4588
  * @since 2.0.0
4441
4589
  * @category sequencing
@@ -4451,6 +4599,7 @@ export const tapErrorTag = effect.tapErrorTag;
4451
4599
  * altering the error or the overall result of the effect.
4452
4600
  *
4453
4601
  * @example
4602
+ * ```ts
4454
4603
  * import { Effect, Console } from "effect"
4455
4604
  *
4456
4605
  * // Create a task that fails with a NetworkError
@@ -4477,6 +4626,7 @@ export const tapErrorTag = effect.tapErrorTag;
4477
4626
  * // Output:
4478
4627
  * // error cause: RuntimeException: Something went wrong
4479
4628
  * // ... stack trace ...
4629
+ * ```
4480
4630
  *
4481
4631
  * @since 2.0.0
4482
4632
  * @category sequencing
@@ -4508,6 +4658,7 @@ export const forever = effect.forever;
4508
4658
  * ```
4509
4659
  *
4510
4660
  * @example
4661
+ * ```ts
4511
4662
  * // Title: Effectful Iteration
4512
4663
  * import { Effect } from "effect"
4513
4664
  *
@@ -4524,6 +4675,7 @@ export const forever = effect.forever;
4524
4675
  *
4525
4676
  * Effect.runPromise(result).then(console.log)
4526
4677
  * // Output: 6
4678
+ * ```
4527
4679
  *
4528
4680
  * @since 2.0.0
4529
4681
  * @category Looping
@@ -4556,6 +4708,7 @@ export const iterate = effect.iterate;
4556
4708
  * discarded, and the final result will be `void`.
4557
4709
  *
4558
4710
  * @example
4711
+ * ```ts
4559
4712
  * // Title: Looping with Collected Results
4560
4713
  * import { Effect } from "effect"
4561
4714
  *
@@ -4575,6 +4728,7 @@ export const iterate = effect.iterate;
4575
4728
  *
4576
4729
  * Effect.runPromise(result).then(console.log)
4577
4730
  * // Output: [1, 2, 3, 4, 5]
4731
+ * ```
4578
4732
  *
4579
4733
  * @example
4580
4734
  * // Title: Loop with Discarded Results
@@ -4616,6 +4770,7 @@ export const loop = effect.loop;
4616
4770
  * an additional time.
4617
4771
  *
4618
4772
  * @example
4773
+ * ```ts
4619
4774
  * // Success Example
4620
4775
  * import { Effect, Schedule, Console } from "effect"
4621
4776
  *
@@ -4624,6 +4779,7 @@ export const loop = effect.loop;
4624
4779
  * const program = Effect.repeat(action, policy)
4625
4780
  *
4626
4781
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
4782
+ * ```
4627
4783
  *
4628
4784
  * @example
4629
4785
  * // Failure Example
@@ -4659,12 +4815,14 @@ export const repeat = _schedule.repeat_combined;
4659
4815
  * initially and then repeats it one additional time if it succeeds.
4660
4816
  *
4661
4817
  * @example
4818
+ * ```ts
4662
4819
  * import { Effect, Console } from "effect"
4663
4820
  *
4664
4821
  * const action = Console.log("success")
4665
4822
  * const program = Effect.repeatN(action, 2)
4666
4823
  *
4667
4824
  * Effect.runPromise(program)
4825
+ * ```
4668
4826
  *
4669
4827
  * @since 2.0.0
4670
4828
  * @category repetition / recursion
@@ -4679,6 +4837,7 @@ export const repeatN = effect.repeatN;
4679
4837
  * initially and then repeats it an additional time if it succeeds.
4680
4838
  *
4681
4839
  * @example
4840
+ * ```ts
4682
4841
  * import { Effect, Schedule } from "effect"
4683
4842
  *
4684
4843
  * let count = 0
@@ -4708,6 +4867,7 @@ export const repeatN = effect.repeatN;
4708
4867
  * )
4709
4868
  *
4710
4869
  * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
4870
+ * ```
4711
4871
  *
4712
4872
  * @since 2.0.0
4713
4873
  * @category repetition / recursion
@@ -4830,6 +4990,7 @@ export const isSuccess = effect.isSuccess;
4830
4990
  * @see {@link matchEffect} if you need to perform side effects in the handlers.
4831
4991
  *
4832
4992
  * @example
4993
+ * ```ts
4833
4994
  * import { Effect } from "effect"
4834
4995
  *
4835
4996
  * const success: Effect.Effect<number, Error> = Effect.succeed(42)
@@ -4855,6 +5016,7 @@ export const isSuccess = effect.isSuccess;
4855
5016
  * // Run and log the result of the failed effect
4856
5017
  * Effect.runPromise(program2).then(console.log)
4857
5018
  * // Output: "failure: Uh oh!"
5019
+ * ```
4858
5020
  *
4859
5021
  * @since 2.0.0
4860
5022
  * @category getters & folding
@@ -4890,6 +5052,7 @@ export const matchCause = core.matchCause;
4890
5052
  * @see {@link matchEffect} if you don't need to handle the cause of the failure.
4891
5053
  *
4892
5054
  * @example
5055
+ * ```ts
4893
5056
  * import { Effect, Console } from "effect"
4894
5057
  *
4895
5058
  * const task: Effect.Effect<number, Error> = Effect.die("Uh oh!")
@@ -4917,6 +5080,7 @@ export const matchCause = core.matchCause;
4917
5080
  *
4918
5081
  * Effect.runSync(program)
4919
5082
  * // Output: "Die: Uh oh!"
5083
+ * ```
4920
5084
  *
4921
5085
  * @since 2.0.0
4922
5086
  * @category getters & folding
@@ -4945,6 +5109,7 @@ export const matchEffect = core.matchEffect;
4945
5109
  * To adjust the log level, use the `Logger.withMinimumLogLevel` function.
4946
5110
  *
4947
5111
  * @example
5112
+ * ```ts
4948
5113
  * import { Cause, Effect } from "effect"
4949
5114
  *
4950
5115
  * const program = Effect.log(
@@ -4958,6 +5123,7 @@ export const matchEffect = core.matchEffect;
4958
5123
  * // Output:
4959
5124
  * // timestamp=... level=INFO fiber=#0 message=message1 message=message2 cause="Error: Oh no!
4960
5125
  * // Error: Oh uh!"
5126
+ * ```
4961
5127
  *
4962
5128
  * @since 2.0.0
4963
5129
  * @category Logging
@@ -4985,12 +5151,14 @@ export const logTrace = effect.logTrace;
4985
5151
  * `Logger.withMinimumLogLevel` and set the log level to `LogLevel.Debug`.
4986
5152
  *
4987
5153
  * @example
5154
+ * ```ts
4988
5155
  * import { Effect, Logger, LogLevel } from "effect"
4989
5156
  *
4990
5157
  * const program = Effect.logDebug("message1").pipe(Logger.withMinimumLogLevel(LogLevel.Debug))
4991
5158
  *
4992
5159
  * // Effect.runFork(program)
4993
5160
  * // timestamp=... level=DEBUG fiber=#0 message=message1
5161
+ * ```
4994
5162
  *
4995
5163
  * @since 2.0.0
4996
5164
  * @category Logging
@@ -5030,6 +5198,7 @@ export const logFatal = effect.logFatal;
5030
5198
  * time-sensitive processes.
5031
5199
  *
5032
5200
  * @example
5201
+ * ```ts
5033
5202
  * import { Effect } from "effect"
5034
5203
  *
5035
5204
  * const program = Effect.gen(function*() {
@@ -5039,6 +5208,7 @@ export const logFatal = effect.logFatal;
5039
5208
  *
5040
5209
  * // Effect.runFork(program)
5041
5210
  * // timestamp=... level=INFO fiber=#0 message="The job is finished!" myspan=1011ms
5211
+ * ```
5042
5212
  *
5043
5213
  * @since 2.0.0
5044
5214
  * @category Logging
@@ -5050,6 +5220,7 @@ export const withLogSpan = effect.withLogSpan;
5050
5220
  * to log messages, making them more informative and easier to trace.
5051
5221
  *
5052
5222
  * @example
5223
+ * ```ts
5053
5224
  * import { Effect } from "effect"
5054
5225
  *
5055
5226
  * const program = Effect.gen(function*() {
@@ -5060,6 +5231,7 @@ export const withLogSpan = effect.withLogSpan;
5060
5231
  * // Effect.runFork(program)
5061
5232
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
5062
5233
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
5234
+ * ```
5063
5235
  *
5064
5236
  * @since 2.0.0
5065
5237
  * @category Logging
@@ -5072,6 +5244,7 @@ export const annotateLogs = effect.annotateLogs;
5072
5244
  * defined `Scope`, making it easier to manage context-specific logging.
5073
5245
  *
5074
5246
  * @example
5247
+ * ```ts
5075
5248
  * import { Effect } from "effect"
5076
5249
  *
5077
5250
  * const program = Effect.gen(function*() {
@@ -5086,6 +5259,7 @@ export const annotateLogs = effect.annotateLogs;
5086
5259
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
5087
5260
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
5088
5261
  * // timestamp=... level=INFO fiber=#0 message="no annotations again"
5262
+ * ```
5089
5263
  *
5090
5264
  * @since 3.1.0
5091
5265
  * @category Logging
@@ -5121,6 +5295,7 @@ export const withUnhandledErrorLogLevel = core.withUnhandledErrorLogLevel;
5121
5295
  * @see {@link orDieWith} if you need to customize the error.
5122
5296
  *
5123
5297
  * @example
5298
+ * ```ts
5124
5299
  * // Title: Propagating an Error as a Defect
5125
5300
  * import { Effect } from "effect"
5126
5301
  *
@@ -5137,6 +5312,7 @@ export const withUnhandledErrorLogLevel = core.withUnhandledErrorLogLevel;
5137
5312
  * // Output:
5138
5313
  * // (FiberFailure) Error: Cannot divide by zero
5139
5314
  * // ...stack trace...
5315
+ * ```
5140
5316
  *
5141
5317
  * @since 2.0.0
5142
5318
  * @category Converting Failures to Defects
@@ -5160,6 +5336,7 @@ export const orDie = core.orDie;
5160
5336
  * @see {@link orDie} if you don't need to customize the error.
5161
5337
  *
5162
5338
  * @example
5339
+ * ```ts
5163
5340
  * // Title: Customizing Defect
5164
5341
  * import { Effect } from "effect"
5165
5342
  *
@@ -5179,6 +5356,7 @@ export const orDie = core.orDie;
5179
5356
  * // Output:
5180
5357
  * // (FiberFailure) Error: defect: Cannot divide by zero
5181
5358
  * // ...stack trace...
5359
+ * ```
5182
5360
  *
5183
5361
  * @since 2.0.0
5184
5362
  * @category Converting Failures to Defects
@@ -5195,6 +5373,7 @@ export const orDieWith = core.orDieWith;
5195
5373
  * @see {@link catchAll} if you need to access the error in the fallback effect.
5196
5374
  *
5197
5375
  * @example
5376
+ * ```ts
5198
5377
  * import { Effect } from "effect"
5199
5378
  *
5200
5379
  * const success = Effect.succeed("success")
@@ -5210,6 +5389,7 @@ export const orDieWith = core.orDieWith;
5210
5389
  * const program2 = Effect.orElse(failure, () => fallback)
5211
5390
  * console.log(Effect.runSync(program2))
5212
5391
  * // Output: "fallback"
5392
+ * ```
5213
5393
  *
5214
5394
  * @since 2.0.0
5215
5395
  * @category Fallback
@@ -5228,6 +5408,7 @@ export const orElse = core.orElse;
5228
5408
  * @see {@link mapError} if you need to access the error to transform it.
5229
5409
  *
5230
5410
  * @example
5411
+ * ```ts
5231
5412
  * import { Effect } from "effect"
5232
5413
  *
5233
5414
  * const validate = (age: number): Effect.Effect<number, string> => {
@@ -5249,6 +5430,7 @@ export const orElse = core.orElse;
5249
5430
  * // _tag: 'Failure',
5250
5431
  * // cause: { _id: 'Cause', _tag: 'Fail', failure: 'invalid age' }
5251
5432
  * // }
5433
+ * ```
5252
5434
  *
5253
5435
  * @since 2.0.0
5254
5436
  * @category Fallback
@@ -5272,6 +5454,7 @@ export const orElseFail = effect.orElseFail;
5272
5454
  * already succeeds, it will remain unchanged.
5273
5455
  *
5274
5456
  * @example
5457
+ * ```ts
5275
5458
  * import { Effect } from "effect"
5276
5459
  *
5277
5460
  * const validate = (age: number): Effect.Effect<number, string> => {
@@ -5289,6 +5472,7 @@ export const orElseFail = effect.orElseFail;
5289
5472
  * console.log(Effect.runSyncExit(program))
5290
5473
  * // Output:
5291
5474
  * // { _id: 'Exit', _tag: 'Success', value: 18 }
5475
+ * ```
5292
5476
  *
5293
5477
  * @since 2.0.0
5294
5478
  * @category Fallback
@@ -5312,6 +5496,7 @@ export const orElseSucceed = effect.orElseSucceed;
5312
5496
  * error.
5313
5497
  *
5314
5498
  * @example
5499
+ * ```ts
5315
5500
  * import { Effect, Console } from "effect"
5316
5501
  *
5317
5502
  * interface Config {
@@ -5358,6 +5543,7 @@ export const orElseSucceed = effect.orElseSucceed;
5358
5543
  * // Unavailable config for node2
5359
5544
  * // Config for node3 found
5360
5545
  * // { host: 'node3.example.com', port: 8080, apiKey: '12345-abcde' }
5546
+ * ```
5361
5547
  *
5362
5548
  * @since 2.0.0
5363
5549
  * @category Fallback
@@ -5489,6 +5675,7 @@ export const unsafeMakeLatch = circular.unsafeMakeLatch;
5489
5675
  * @category latch
5490
5676
  * @since 3.8.0
5491
5677
  * @example
5678
+ * ```ts
5492
5679
  * import { Effect } from "effect"
5493
5680
  *
5494
5681
  * Effect.gen(function*() {
@@ -5505,6 +5692,7 @@ export const unsafeMakeLatch = circular.unsafeMakeLatch;
5505
5692
  * yield* latch.open
5506
5693
  * yield* fiber.await
5507
5694
  * })
5695
+ * ```
5508
5696
  */
5509
5697
  export const makeLatch = circular.makeLatch;
5510
5698
  /**
@@ -5521,6 +5709,7 @@ export const makeLatch = circular.makeLatch;
5521
5709
  * `runFork` is a good default choice.
5522
5710
  *
5523
5711
  * @example
5712
+ * ```ts
5524
5713
  * // Title: Running an Effect in the Background
5525
5714
  * import { Effect, Console, Schedule, Fiber } from "effect"
5526
5715
  *
@@ -5538,6 +5727,7 @@ export const makeLatch = circular.makeLatch;
5538
5727
  * setTimeout(() => {
5539
5728
  * Effect.runFork(Fiber.interrupt(fiber))
5540
5729
  * }, 500)
5730
+ * ```
5541
5731
  *
5542
5732
  * @since 2.0.0
5543
5733
  * @category Running Effects
@@ -5563,11 +5753,13 @@ export const runCallback = _runtime.unsafeRunEffect;
5563
5753
  * @see {@link runPromiseExit} for a version that returns an `Exit` type instead of rejecting.
5564
5754
  *
5565
5755
  * @example
5756
+ * ```ts
5566
5757
  * // Title: Running a Successful Effect as a Promise
5567
5758
  * import { Effect } from "effect"
5568
5759
  *
5569
5760
  * Effect.runPromise(Effect.succeed(1)).then(console.log)
5570
5761
  * // Output: 1
5762
+ * ```
5571
5763
  *
5572
5764
  * @example
5573
5765
  * //Example: Handling a Failing Effect as a Rejected Promise
@@ -5598,6 +5790,7 @@ export const runPromise = _runtime.unsafeRunPromiseEffect;
5598
5790
  * a `Cause` type.
5599
5791
  *
5600
5792
  * @example
5793
+ * ```ts
5601
5794
  * // Title: Handling Results as Exit
5602
5795
  * import { Effect } from "effect"
5603
5796
  *
@@ -5622,6 +5815,7 @@ export const runPromise = _runtime.unsafeRunPromiseEffect;
5622
5815
  * // failure: "my error"
5623
5816
  * // }
5624
5817
  * // }
5818
+ * ```
5625
5819
  *
5626
5820
  * @since 2.0.0
5627
5821
  * @category Running Effects
@@ -5643,6 +5837,7 @@ export const runPromiseExit = _runtime.unsafeRunPromiseExitEffect;
5643
5837
  * throwing an error.
5644
5838
  *
5645
5839
  * @example
5840
+ * ```ts
5646
5841
  * // Title: Synchronous Logging
5647
5842
  * import { Effect } from "effect"
5648
5843
  *
@@ -5656,6 +5851,7 @@ export const runPromiseExit = _runtime.unsafeRunPromiseExitEffect;
5656
5851
  *
5657
5852
  * console.log(result)
5658
5853
  * // Output: 1
5854
+ * ```
5659
5855
  *
5660
5856
  * @example
5661
5857
  * // Title: Incorrect Usage with Failing or Async Effects
@@ -5704,6 +5900,7 @@ export const runSync = _runtime.unsafeRunSyncEffect;
5704
5900
  * resolved synchronously.
5705
5901
  *
5706
5902
  * @example
5903
+ * ```ts
5707
5904
  * // Title: Handling Results as Exit
5708
5905
  * import { Effect } from "effect"
5709
5906
  *
@@ -5726,6 +5923,7 @@ export const runSync = _runtime.unsafeRunSyncEffect;
5726
5923
  * // failure: "my error"
5727
5924
  * // }
5728
5925
  * // }
5926
+ * ```
5729
5927
  *
5730
5928
  * @example
5731
5929
  * // Title: Asynchronous Operation Resulting in Die
@@ -5766,6 +5964,7 @@ export const runSyncExit = _runtime.unsafeRunSyncExitEffect;
5766
5964
  * @see {@link zip} for a version that stops at the first error.
5767
5965
  *
5768
5966
  * @example
5967
+ * ```ts
5769
5968
  * import { Effect, Console } from "effect"
5770
5969
  *
5771
5970
  * const task1 = Console.log("task1").pipe(Effect.as(1))
@@ -5793,6 +5992,7 @@ export const runSyncExit = _runtime.unsafeRunSyncExitEffect;
5793
5992
  * // right: { _id: 'Cause', _tag: 'Fail', failure: 'Oh no!' }
5794
5993
  * // }
5795
5994
  * // }
5995
+ * ```
5796
5996
  *
5797
5997
  * @since 2.0.0
5798
5998
  * @category Error Accumulation
@@ -5821,6 +6021,7 @@ export const validateWith = fiberRuntime.validateWith;
5821
6021
  * @see {@link validate} for a version that accumulates errors.
5822
6022
  *
5823
6023
  * @example
6024
+ * ```ts
5824
6025
  * // Title: Combining Two Effects Sequentially
5825
6026
  * import { Effect } from "effect"
5826
6027
  *
@@ -5844,6 +6045,7 @@ export const validateWith = fiberRuntime.validateWith;
5844
6045
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
5845
6046
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
5846
6047
  * // [ 1, 'hello' ]
6048
+ * ```
5847
6049
  *
5848
6050
  * @example
5849
6051
  * // Title: Combining Two Effects Concurrently
@@ -5889,6 +6091,7 @@ export const zip = fiberRuntime.zipOptions;
5889
6091
  * @see {@link zipRight} for a version that returns the result of the second effect.
5890
6092
  *
5891
6093
  * @example
6094
+ * ```ts
5892
6095
  * import { Effect } from "effect"
5893
6096
  *
5894
6097
  * const task1 = Effect.succeed(1).pipe(
@@ -5907,6 +6110,7 @@ export const zip = fiberRuntime.zipOptions;
5907
6110
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
5908
6111
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
5909
6112
  * // 1
6113
+ * ```
5910
6114
  *
5911
6115
  * @since 2.0.0
5912
6116
  * @category Zipping
@@ -5930,6 +6134,7 @@ export const zipLeft = fiberRuntime.zipLeftOptions;
5930
6134
  * @see {@link zipLeft} for a version that returns the result of the first effect.
5931
6135
  *
5932
6136
  * @example
6137
+ * ```ts
5933
6138
  * import { Effect } from "effect"
5934
6139
  *
5935
6140
  * const task1 = Effect.succeed(1).pipe(
@@ -5948,6 +6153,7 @@ export const zipLeft = fiberRuntime.zipLeftOptions;
5948
6153
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
5949
6154
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
5950
6155
  * // hello
6156
+ * ```
5951
6157
  *
5952
6158
  * @since 2.0.0
5953
6159
  * @category Zipping
@@ -5969,6 +6175,7 @@ export const zipRight = fiberRuntime.zipRightOptions;
5969
6175
  * use the `{ concurrent: true }` option.
5970
6176
  *
5971
6177
  * @example
6178
+ * ```ts
5972
6179
  * // Title: Combining Effects with a Custom Function
5973
6180
  * import { Effect } from "effect"
5974
6181
  *
@@ -5993,6 +6200,7 @@ export const zipRight = fiberRuntime.zipRightOptions;
5993
6200
  * // timestamp=... level=INFO fiber=#3 message="task1 done"
5994
6201
  * // timestamp=... level=INFO fiber=#2 message="task2 done"
5995
6202
  * // 6
6203
+ * ```
5996
6204
  *
5997
6205
  * @since 2.0.0
5998
6206
  * @category Zipping
@@ -6069,6 +6277,7 @@ export const withTracerScoped = fiberRuntime.withTracerScoped;
6069
6277
  * @since 2.0.0
6070
6278
  * @category Tracing
6071
6279
  * @example
6280
+ * ```ts
6072
6281
  * import { Effect } from "effect"
6073
6282
  *
6074
6283
  * Effect.succeed(42).pipe(
@@ -6076,6 +6285,7 @@ export const withTracerScoped = fiberRuntime.withTracerScoped;
6076
6285
  * // the span will not be registered with the tracer
6077
6286
  * Effect.withTracerEnabled(false)
6078
6287
  * )
6288
+ * ```
6079
6289
  */
6080
6290
  export const withTracerEnabled = core.withTracerEnabled;
6081
6291
  /**
@@ -6166,6 +6376,7 @@ export const withSpan = effect.withSpan;
6166
6376
  * @since 3.2.0
6167
6377
  * @category Tracing
6168
6378
  * @example
6379
+ * ```ts
6169
6380
  * import { Effect } from "effect"
6170
6381
  *
6171
6382
  * const getTodo = Effect.functionWithSpan({
@@ -6175,6 +6386,7 @@ export const withSpan = effect.withSpan;
6175
6386
  * attributes: { id }
6176
6387
  * })
6177
6388
  * })
6389
+ * ```
6178
6390
  */
6179
6391
  export const functionWithSpan = effect.functionWithSpan;
6180
6392
  /**
@@ -6205,6 +6417,7 @@ export const withParentSpan = effect.withParentSpan;
6205
6417
  * value.
6206
6418
  *
6207
6419
  * @example
6420
+ * ```ts
6208
6421
  * import { Effect } from "effect"
6209
6422
  *
6210
6423
  * // ┌─── Effect<number, NoSuchElementException, never>
@@ -6230,6 +6443,7 @@ export const withParentSpan = effect.withParentSpan;
6230
6443
  * // failure: { _tag: 'NoSuchElementException' }
6231
6444
  * // }
6232
6445
  * // }
6446
+ * ```
6233
6447
  *
6234
6448
  * @since 2.0.0
6235
6449
  * @category Optional Wrapping
@@ -6247,6 +6461,7 @@ export const fromNullable = effect.fromNullable;
6247
6461
  * unchanged.
6248
6462
  *
6249
6463
  * @example
6464
+ * ```ts
6250
6465
  * import { Effect } from "effect"
6251
6466
  *
6252
6467
  * // ┌─── Effect<number, NoSuchElementException, never>
@@ -6270,6 +6485,7 @@ export const fromNullable = effect.fromNullable;
6270
6485
  *
6271
6486
  * Effect.runPromise(option2).then(console.log)
6272
6487
  * // Output: { _tag: 'None' }
6488
+ * ```
6273
6489
  *
6274
6490
  * @since 2.0.0
6275
6491
  * @category Optional Wrapping
@@ -6303,6 +6519,7 @@ const makeTagProxy = TagClass => {
6303
6519
  };
6304
6520
  /**
6305
6521
  * @example
6522
+ * ```ts
6306
6523
  * import { Effect, Layer } from "effect"
6307
6524
  *
6308
6525
  * class MapTag extends Effect.Tag("MapTag")<MapTag, Map<string, string>>() {
@@ -6311,6 +6528,7 @@ const makeTagProxy = TagClass => {
6311
6528
  * Effect.sync(() => new Map())
6312
6529
  * )
6313
6530
  * }
6531
+ * ```
6314
6532
  *
6315
6533
  * @since 2.0.0
6316
6534
  * @category Context
@@ -6337,6 +6555,7 @@ export const Tag = id => () => {
6337
6555
  };
6338
6556
  /**
6339
6557
  * @example
6558
+ * ```ts
6340
6559
  * import { Effect } from 'effect';
6341
6560
  *
6342
6561
  * class Prefix extends Effect.Service<Prefix>()("Prefix", {
@@ -6356,6 +6575,7 @@ export const Tag = id => () => {
6356
6575
  * }),
6357
6576
  * dependencies: [Prefix.Default]
6358
6577
  * }) {}
6578
+ * ```
6359
6579
  *
6360
6580
  * @since 3.9.0
6361
6581
  * @category Context