effect 3.13.9 → 3.13.11

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 (119) hide show
  1. package/dist/cjs/Arbitrary.js +38 -22
  2. package/dist/cjs/Arbitrary.js.map +1 -1
  3. package/dist/cjs/Array.js +50 -50
  4. package/dist/cjs/Array.js.map +1 -1
  5. package/dist/cjs/Brand.js +9 -4
  6. package/dist/cjs/Brand.js.map +1 -1
  7. package/dist/cjs/Cause.js +1 -0
  8. package/dist/cjs/Cause.js.map +1 -1
  9. package/dist/cjs/Chunk.js +25 -23
  10. package/dist/cjs/Chunk.js.map +1 -1
  11. package/dist/cjs/Config.js +2 -1
  12. package/dist/cjs/Config.js.map +1 -1
  13. package/dist/cjs/Context.js +4 -4
  14. package/dist/cjs/Effect.js +823 -632
  15. package/dist/cjs/Effect.js.map +1 -1
  16. package/dist/cjs/Either.js +12 -12
  17. package/dist/cjs/Either.js.map +1 -1
  18. package/dist/cjs/LogLevel.js +1 -1
  19. package/dist/cjs/Logger.js +12 -12
  20. package/dist/cjs/Match.js +26 -26
  21. package/dist/cjs/Option.js +43 -43
  22. package/dist/cjs/Predicate.js +6 -2
  23. package/dist/cjs/Predicate.js.map +1 -1
  24. package/dist/cjs/Schema.js +21 -17
  25. package/dist/cjs/Schema.js.map +1 -1
  26. package/dist/cjs/SchemaAST.js +49 -25
  27. package/dist/cjs/SchemaAST.js.map +1 -1
  28. package/dist/cjs/Scope.js +2 -0
  29. package/dist/cjs/Scope.js.map +1 -1
  30. package/dist/cjs/Stream.js +93 -93
  31. package/dist/cjs/internal/core.js +1 -1
  32. package/dist/cjs/internal/core.js.map +1 -1
  33. package/dist/cjs/internal/schema/util.js +23 -14
  34. package/dist/cjs/internal/schema/util.js.map +1 -1
  35. package/dist/cjs/internal/version.js +1 -1
  36. package/dist/cjs/internal/version.js.map +1 -1
  37. package/dist/dts/Array.d.ts +47 -47
  38. package/dist/dts/Array.d.ts.map +1 -1
  39. package/dist/dts/Brand.d.ts +14 -6
  40. package/dist/dts/Brand.d.ts.map +1 -1
  41. package/dist/dts/Cause.d.ts +1 -0
  42. package/dist/dts/Cause.d.ts.map +1 -1
  43. package/dist/dts/Chunk.d.ts +91 -89
  44. package/dist/dts/Chunk.d.ts.map +1 -1
  45. package/dist/dts/Config.d.ts +2 -1
  46. package/dist/dts/Config.d.ts.map +1 -1
  47. package/dist/dts/Context.d.ts +4 -4
  48. package/dist/dts/Effect.d.ts +2107 -1621
  49. package/dist/dts/Effect.d.ts.map +1 -1
  50. package/dist/dts/Either.d.ts +33 -33
  51. package/dist/dts/LogLevel.d.ts +3 -3
  52. package/dist/dts/Logger.d.ts +16 -16
  53. package/dist/dts/Match.d.ts +26 -26
  54. package/dist/dts/Option.d.ts +84 -84
  55. package/dist/dts/Predicate.d.ts.map +1 -1
  56. package/dist/dts/Schema.d.ts +53 -21
  57. package/dist/dts/Schema.d.ts.map +1 -1
  58. package/dist/dts/SchemaAST.d.ts.map +1 -1
  59. package/dist/dts/Scope.d.ts +2 -0
  60. package/dist/dts/Scope.d.ts.map +1 -1
  61. package/dist/dts/Stream.d.ts +229 -229
  62. package/dist/esm/Arbitrary.js +38 -22
  63. package/dist/esm/Arbitrary.js.map +1 -1
  64. package/dist/esm/Array.js +50 -50
  65. package/dist/esm/Array.js.map +1 -1
  66. package/dist/esm/Brand.js +9 -4
  67. package/dist/esm/Brand.js.map +1 -1
  68. package/dist/esm/Cause.js +1 -0
  69. package/dist/esm/Cause.js.map +1 -1
  70. package/dist/esm/Chunk.js +25 -23
  71. package/dist/esm/Chunk.js.map +1 -1
  72. package/dist/esm/Config.js +2 -1
  73. package/dist/esm/Config.js.map +1 -1
  74. package/dist/esm/Context.js +4 -4
  75. package/dist/esm/Effect.js +845 -648
  76. package/dist/esm/Effect.js.map +1 -1
  77. package/dist/esm/Either.js +17 -17
  78. package/dist/esm/Either.js.map +1 -1
  79. package/dist/esm/LogLevel.js +1 -1
  80. package/dist/esm/Logger.js +12 -12
  81. package/dist/esm/Match.js +26 -26
  82. package/dist/esm/Option.js +48 -48
  83. package/dist/esm/Predicate.js +3 -0
  84. package/dist/esm/Predicate.js.map +1 -1
  85. package/dist/esm/Schema.js +21 -17
  86. package/dist/esm/Schema.js.map +1 -1
  87. package/dist/esm/SchemaAST.js +46 -22
  88. package/dist/esm/SchemaAST.js.map +1 -1
  89. package/dist/esm/Scope.js +2 -0
  90. package/dist/esm/Scope.js.map +1 -1
  91. package/dist/esm/Stream.js +101 -101
  92. package/dist/esm/internal/core.js +1 -1
  93. package/dist/esm/internal/core.js.map +1 -1
  94. package/dist/esm/internal/schema/util.js +23 -14
  95. package/dist/esm/internal/schema/util.js.map +1 -1
  96. package/dist/esm/internal/version.js +1 -1
  97. package/dist/esm/internal/version.js.map +1 -1
  98. package/package.json +1 -1
  99. package/src/Arbitrary.ts +39 -24
  100. package/src/Array.ts +116 -113
  101. package/src/Brand.ts +14 -6
  102. package/src/Cause.ts +1 -0
  103. package/src/Chunk.ts +97 -95
  104. package/src/Config.ts +2 -1
  105. package/src/Context.ts +4 -4
  106. package/src/Effect.ts +2107 -1621
  107. package/src/Either.ts +34 -34
  108. package/src/LogLevel.ts +3 -3
  109. package/src/Logger.ts +16 -16
  110. package/src/Match.ts +26 -26
  111. package/src/Option.ts +84 -84
  112. package/src/Predicate.ts +4 -0
  113. package/src/Schema.ts +87 -41
  114. package/src/SchemaAST.ts +47 -22
  115. package/src/Scope.ts +2 -0
  116. package/src/Stream.ts +229 -229
  117. package/src/internal/core.ts +2 -1
  118. package/src/internal/schema/util.ts +34 -25
  119. package/src/internal/version.ts +1 -1
@@ -73,12 +73,8 @@ const isEffect = exports.isEffect = core.isEffect;
73
73
  * By caching the result, you can improve efficiency and reduce unnecessary
74
74
  * computations, especially in performance-critical applications.
75
75
  *
76
- * @see {@link cached} for a similar function that caches the result
77
- * indefinitely.
78
- * @see {@link cachedInvalidateWithTTL} for a similar function that includes an
79
- * additional effect for manually invalidating the cached value.
76
+ * **Example**
80
77
  *
81
- * @example
82
78
  * ```ts
83
79
  * import { Effect, Console } from "effect"
84
80
  *
@@ -100,7 +96,7 @@ const isEffect = exports.isEffect = core.isEffect;
100
96
  * yield* cached.pipe(Effect.andThen(Console.log))
101
97
  * })
102
98
  *
103
- * // Effect.runFork(program)
99
+ * Effect.runFork(program)
104
100
  * // Output:
105
101
  * // expensive task...
106
102
  * // result 1
@@ -109,6 +105,11 @@ const isEffect = exports.isEffect = core.isEffect;
109
105
  * // result 2
110
106
  * ```
111
107
  *
108
+ * @see {@link cached} for a similar function that caches the result
109
+ * indefinitely.
110
+ * @see {@link cachedInvalidateWithTTL} for a similar function that includes an
111
+ * additional effect for manually invalidating the cached value.
112
+ *
112
113
  * @since 2.0.0
113
114
  * @category Caching
114
115
  */
@@ -140,12 +141,8 @@ const cachedWithTTL = exports.cachedWithTTL = circular.cached;
140
141
  * a certain period but still want to invalidate it if the underlying data
141
142
  * changes or if you want to force a recomputation.
142
143
  *
143
- * @see {@link cached} for a similar function that caches the result
144
- * indefinitely.
145
- * @see {@link cachedWithTTL} for a similar function that caches the result for
146
- * a specified duration but does not include an effect for manual invalidation.
144
+ * **Example**
147
145
  *
148
- * @example
149
146
  * ```ts
150
147
  * import { Effect, Console } from "effect"
151
148
  *
@@ -170,7 +167,7 @@ const cachedWithTTL = exports.cachedWithTTL = circular.cached;
170
167
  * yield* cached.pipe(Effect.andThen(Console.log))
171
168
  * })
172
169
  *
173
- * // Effect.runFork(program)
170
+ * Effect.runFork(program)
174
171
  * // Output:
175
172
  * // expensive task...
176
173
  * // result 1
@@ -179,6 +176,11 @@ const cachedWithTTL = exports.cachedWithTTL = circular.cached;
179
176
  * // result 2
180
177
  * ```
181
178
  *
179
+ * @see {@link cached} for a similar function that caches the result
180
+ * indefinitely.
181
+ * @see {@link cachedWithTTL} for a similar function that caches the result for
182
+ * a specified duration but does not include an effect for manual invalidation.
183
+ *
182
184
  * @since 2.0.0
183
185
  * @category Caching
184
186
  */
@@ -201,12 +203,8 @@ const cachedInvalidateWithTTL = exports.cachedInvalidateWithTTL = circular.cache
201
203
  * and all following evaluations will immediately return the cached value,
202
204
  * improving performance and reducing unnecessary work.
203
205
  *
204
- * @see {@link cachedWithTTL} for a similar function that includes a
205
- * time-to-live duration for the cached value.
206
- * @see {@link cachedInvalidateWithTTL} for a similar function that includes an
207
- * additional effect for manually invalidating the cached value.
206
+ * **Example**
208
207
  *
209
- * @example
210
208
  * ```ts
211
209
  * import { Effect, Console } from "effect"
212
210
  *
@@ -230,7 +228,7 @@ const cachedInvalidateWithTTL = exports.cachedInvalidateWithTTL = circular.cache
230
228
  * yield* cached.pipe(Effect.andThen(Console.log))
231
229
  * })
232
230
  *
233
- * // Effect.runFork(program)
231
+ * Effect.runFork(program)
234
232
  * // Output:
235
233
  * // non-cached version:
236
234
  * // expensive task...
@@ -243,6 +241,11 @@ const cachedInvalidateWithTTL = exports.cachedInvalidateWithTTL = circular.cache
243
241
  * // result 3
244
242
  * ```
245
243
  *
244
+ * @see {@link cachedWithTTL} for a similar function that includes a
245
+ * time-to-live duration for the cached value.
246
+ * @see {@link cachedInvalidateWithTTL} for a similar function that includes an
247
+ * additional effect for manually invalidating the cached value.
248
+ *
246
249
  * @since 2.0.0
247
250
  * @category Caching
248
251
  */
@@ -273,7 +276,8 @@ const cached = exports.cached = effect.memoize;
273
276
  * expensive calculations or operations that should be avoided after the first
274
277
  * execution with the same parameters.
275
278
  *
276
- * @example
279
+ * **Example**
280
+ *
277
281
  * ```ts
278
282
  * import { Effect, Random } from "effect"
279
283
  *
@@ -289,7 +293,7 @@ const cached = exports.cached = effect.memoize;
289
293
  * console.log(yield* memoized(10))
290
294
  * })
291
295
  *
292
- * // Effect.runFork(program)
296
+ * Effect.runFork(program)
293
297
  * // Example Output:
294
298
  * // non-memoized version:
295
299
  * // 2
@@ -321,7 +325,8 @@ const cachedFunction = exports.cachedFunction = circular.cachedFunction;
321
325
  * have initialization tasks, logging, or other one-time actions that should not
322
326
  * be repeated. This can help optimize performance and avoid redundant actions.
323
327
  *
324
- * @example
328
+ * **Example**
329
+ *
325
330
  * ```ts
326
331
  * import { Effect, Console } from "effect"
327
332
  *
@@ -332,7 +337,7 @@ const cachedFunction = exports.cachedFunction = circular.cachedFunction;
332
337
  * yield* Effect.repeatN(task2, 2)
333
338
  * })
334
339
  *
335
- * // Effect.runFork(program)
340
+ * Effect.runFork(program)
336
341
  * // Output:
337
342
  * // task1
338
343
  * // task1
@@ -391,12 +396,9 @@ const once = exports.once = effect.once;
391
396
  * success or failure. Each effect returns `None` for success and `Some` with
392
397
  * the error for failure.
393
398
  *
394
- * @see {@link forEach} for iterating over elements and applying an effect.
395
- * @see {@link allWith} for a data-last version of this function.
399
+ * **Example** (Combining Effects in Tuples)
396
400
  *
397
- * @example
398
401
  * ```ts
399
- * // Title: Combining Effects in Tuples
400
402
  * import { Effect, Console } from "effect"
401
403
  *
402
404
  * const tupleOfEffects = [
@@ -408,15 +410,16 @@ const once = exports.once = effect.once;
408
410
  * // ▼
409
411
  * const resultsAsTuple = Effect.all(tupleOfEffects)
410
412
  *
411
- * // Effect.runPromise(resultsAsTuple).then(console.log)
413
+ * Effect.runPromise(resultsAsTuple).then(console.log)
412
414
  * // Output:
413
415
  * // 42
414
416
  * // Hello
415
417
  * // [ 42, 'Hello' ]
416
418
  * ```
417
419
  *
418
- * @example
419
- * // Title: Combining Effects in Iterables
420
+ * **Example** (Combining Effects in Iterables)
421
+ *
422
+ * ```ts
420
423
  * import { Effect, Console } from "effect"
421
424
  *
422
425
  * const iterableOfEffects: Iterable<Effect.Effect<number>> = [1, 2, 3].map(
@@ -427,15 +430,17 @@ const once = exports.once = effect.once;
427
430
  * // ▼
428
431
  * const resultsAsArray = Effect.all(iterableOfEffects)
429
432
  *
430
- * // Effect.runPromise(resultsAsArray).then(console.log)
433
+ * Effect.runPromise(resultsAsArray).then(console.log)
431
434
  * // Output:
432
435
  * // 1
433
436
  * // 2
434
437
  * // 3
435
438
  * // [ 1, 2, 3 ]
439
+ * ```
436
440
  *
437
- * @example
438
- * // Title: Combining Effects in Structs
441
+ * **Example** (Combining Effects in Structs)
442
+ *
443
+ * ```ts
439
444
  * import { Effect, Console } from "effect"
440
445
  *
441
446
  * const structOfEffects = {
@@ -447,14 +452,16 @@ const once = exports.once = effect.once;
447
452
  * // ▼
448
453
  * const resultsAsStruct = Effect.all(structOfEffects)
449
454
  *
450
- * // Effect.runPromise(resultsAsStruct).then(console.log)
455
+ * Effect.runPromise(resultsAsStruct).then(console.log)
451
456
  * // Output:
452
457
  * // 42
453
458
  * // Hello
454
459
  * // { a: 42, b: 'Hello' }
460
+ * ```
461
+ *
462
+ * **Example** (Combining Effects in Records)
455
463
  *
456
- * @example
457
- * // Title: Combining Effects in Records
464
+ * ```ts
458
465
  * import { Effect, Console } from "effect"
459
466
  *
460
467
  * const recordOfEffects: Record<string, Effect.Effect<number>> = {
@@ -466,14 +473,16 @@ const once = exports.once = effect.once;
466
473
  * // ▼
467
474
  * const resultsAsRecord = Effect.all(recordOfEffects)
468
475
  *
469
- * // Effect.runPromise(resultsAsRecord).then(console.log)
476
+ * Effect.runPromise(resultsAsRecord).then(console.log)
470
477
  * // Output:
471
478
  * // 1
472
479
  * // 2
473
480
  * // { key1: 1, key2: 2 }
481
+ * ```
482
+ *
483
+ * **Example** (Short-Circuiting Behavior)
474
484
  *
475
- * @example
476
- * // Title: Short-Circuiting Behavior
485
+ * ```ts
477
486
  * import { Effect, Console } from "effect"
478
487
  *
479
488
  * const program = Effect.all([
@@ -483,7 +492,7 @@ const once = exports.once = effect.once;
483
492
  * Effect.succeed("Task3").pipe(Effect.tap(Console.log))
484
493
  * ])
485
494
  *
486
- * // Effect.runPromiseExit(program).then(console.log)
495
+ * Effect.runPromiseExit(program).then(console.log)
487
496
  * // Output:
488
497
  * // Task1
489
498
  * // {
@@ -491,9 +500,11 @@ const once = exports.once = effect.once;
491
500
  * // _tag: 'Failure',
492
501
  * // cause: { _id: 'Cause', _tag: 'Fail', failure: 'Task2: Oh no!' }
493
502
  * // }
503
+ * ```
504
+ *
505
+ * **Example** (Collecting Results with `mode: "either"`)
494
506
  *
495
- * @example
496
- * // Title: Collecting Results with `mode: "either"`
507
+ * ```ts
497
508
  * import { Effect, Console } from "effect"
498
509
  *
499
510
  * const effects = [
@@ -504,7 +515,7 @@ const once = exports.once = effect.once;
504
515
  *
505
516
  * const program = Effect.all(effects, { mode: "either" })
506
517
  *
507
- * // Effect.runPromiseExit(program).then(console.log)
518
+ * Effect.runPromiseExit(program).then(console.log)
508
519
  * // Output:
509
520
  * // Task1
510
521
  * // Task3
@@ -517,9 +528,11 @@ const once = exports.once = effect.once;
517
528
  * // { _id: 'Either', _tag: 'Right', right: 'Task3' }
518
529
  * // ]
519
530
  * // }
531
+ * ```
520
532
  *
521
- * @example
522
- * //Example: Collecting Results with `mode: "validate"`
533
+ * **Example** (Collecting Results with `mode: "validate"`)
534
+ *
535
+ * ```ts
523
536
  * import { Effect, Console } from "effect"
524
537
  *
525
538
  * const effects = [
@@ -530,7 +543,7 @@ const once = exports.once = effect.once;
530
543
  *
531
544
  * const program = Effect.all(effects, { mode: "validate" })
532
545
  *
533
- * // Effect.runPromiseExit(program).then((result) => console.log("%o", result))
546
+ * Effect.runPromiseExit(program).then((result) => console.log("%o", result))
534
547
  * // Output:
535
548
  * // Task1
536
549
  * // Task3
@@ -547,6 +560,10 @@ const once = exports.once = effect.once;
547
560
  * // ]
548
561
  * // }
549
562
  * // }
563
+ * ```
564
+ *
565
+ * @see {@link forEach} for iterating over elements and applying an effect.
566
+ * @see {@link allWith} for a data-last version of this function.
550
567
  *
551
568
  * @since 2.0.0
552
569
  * @category Collecting
@@ -561,7 +578,8 @@ const all = exports.all = fiberRuntime.all;
561
578
  * options such as concurrency levels. This version is useful in functional
562
579
  * pipelines where you first define your data and then apply operations to it.
563
580
  *
564
- * @example
581
+ * **Example**
582
+ *
565
583
  * ```ts
566
584
  * import { Effect, pipe } from "effect"
567
585
  *
@@ -581,7 +599,7 @@ const all = exports.all = fiberRuntime.all;
581
599
  * Effect.allWith({ concurrency: 2 })
582
600
  * )
583
601
  *
584
- * // Effect.runPromise(program).then(console.log)
602
+ * Effect.runPromise(program).then(console.log)
585
603
  * // Output:
586
604
  * // timestamp=... level=INFO fiber=#3 message="task2 done"
587
605
  * // timestamp=... level=INFO fiber=#2 message="task1 done"
@@ -609,7 +627,8 @@ const allWith = exports.allWith = fiberRuntime.allWith;
609
627
  * These options provide flexibility in running the effects concurrently or
610
628
  * adjusting other execution details.
611
629
  *
612
- * @example
630
+ * **Example**
631
+ *
613
632
  * ```ts
614
633
  * import { Effect } from "effect"
615
634
  *
@@ -625,7 +644,7 @@ const allWith = exports.allWith = fiberRuntime.allWith;
625
644
  * console.log(successfulResults)
626
645
  * })
627
646
  *
628
- * // Effect.runFork(program)
647
+ * Effect.runFork(program)
629
648
  * // Output: [1, 2]
630
649
  *
631
650
  * ```
@@ -657,10 +676,8 @@ const allSuccesses = exports.allSuccesses = fiberRuntime.allSuccesses;
657
676
  * This function allows you to conditionally skip over a part of the collection
658
677
  * based on some criteria defined in the predicate.
659
678
  *
660
- * @see {@link dropWhile} for a similar function that drops elements while the
661
- * predicate returns `true`.
679
+ * **Example**
662
680
  *
663
- * @example
664
681
  * ```ts
665
682
  * import { Effect } from "effect"
666
683
  *
@@ -672,10 +689,13 @@ const allSuccesses = exports.allSuccesses = fiberRuntime.allSuccesses;
672
689
  * console.log(result)
673
690
  * })
674
691
  *
675
- * // Effect.runFork(program)
692
+ * Effect.runFork(program)
676
693
  * // Output: [5, 6]
677
694
  * ```
678
695
  *
696
+ * @see {@link dropWhile} for a similar function that drops elements while the
697
+ * predicate returns `true`.
698
+ *
679
699
  * @since 2.0.0
680
700
  * @category Collecting
681
701
  */
@@ -702,10 +722,8 @@ const dropUntil = exports.dropUntil = effect.dropUntil;
702
722
  * based on a condition, and only keep the rest when the condition no longer
703
723
  * holds.
704
724
  *
705
- * @see {@link dropUntil} for a similar function that drops elements until the
706
- * predicate returns `true`.
725
+ * **Example**
707
726
  *
708
- * @example
709
727
  * ```ts
710
728
  * import { Effect } from "effect"
711
729
  *
@@ -717,10 +735,13 @@ const dropUntil = exports.dropUntil = effect.dropUntil;
717
735
  * console.log(result)
718
736
  * })
719
737
  *
720
- * // Effect.runFork(program)
738
+ * Effect.runFork(program)
721
739
  * // Output: [4, 5, 6]
722
740
  * ```
723
741
  *
742
+ * @see {@link dropUntil} for a similar function that drops elements until the
743
+ * predicate returns `true`.
744
+ *
724
745
  * @since 2.0.0
725
746
  * @category Collecting
726
747
  */
@@ -751,10 +772,8 @@ const dropWhile = exports.dropWhile = effect.dropWhile;
751
772
  * numbers from a list until a certain threshold is reached, or gather items
752
773
  * until a specific condition is met.
753
774
  *
754
- * @see {@link takeWhile} for a similar function that takes elements while the
755
- * predicate returns `true`.
775
+ * **Example**
756
776
  *
757
- * @example
758
777
  * ```ts
759
778
  * import { Effect } from "effect"
760
779
  *
@@ -766,10 +785,13 @@ const dropWhile = exports.dropWhile = effect.dropWhile;
766
785
  * console.log(result)
767
786
  * })
768
787
  *
769
- * // Effect.runFork(program)
788
+ * Effect.runFork(program)
770
789
  * // Output: [ 1, 2, 3, 4 ]
771
790
  * ```
772
791
  *
792
+ * @see {@link takeWhile} for a similar function that takes elements while the
793
+ * predicate returns `true`.
794
+ *
773
795
  * @since 2.0.0
774
796
  * @category Collecting
775
797
  */
@@ -790,9 +812,8 @@ const takeUntil = exports.takeUntil = effect.takeUntil;
790
812
  *
791
813
  * Once the predicate returns `false`, the remaining elements are discarded.
792
814
  *
793
- * @see {@link takeUntil} for a similar function that takes elements until the predicate returns `true`.
815
+ * **Example**
794
816
  *
795
- * @example
796
817
  * ```ts
797
818
  * import { Effect } from "effect"
798
819
  *
@@ -804,10 +825,12 @@ const takeUntil = exports.takeUntil = effect.takeUntil;
804
825
  * console.log(result)
805
826
  * })
806
827
  *
807
- * // Effect.runFork(program)
828
+ * Effect.runFork(program)
808
829
  * // Output: [1, 2, 3]
809
830
  * ```
810
831
  *
832
+ * @see {@link takeUntil} for a similar function that takes elements until the predicate returns `true`.
833
+ *
811
834
  * @since 2.0.0
812
835
  * @category Collecting
813
836
  */
@@ -833,10 +856,8 @@ const takeWhile = exports.takeWhile = effect.takeWhile;
833
856
  * collection meet certain criteria, even when the evaluation of each item
834
857
  * involves effects, such as asynchronous checks or complex computations.
835
858
  *
836
- * @see {@link exists} for a similar function that returns a boolean indicating
837
- * whether **any** element satisfies the predicate.
859
+ * **Example**
838
860
  *
839
- * @example
840
861
  * ```ts
841
862
  * import { Effect } from "effect"
842
863
  *
@@ -848,10 +869,13 @@ const takeWhile = exports.takeWhile = effect.takeWhile;
848
869
  * console.log(allEven)
849
870
  * })
850
871
  *
851
- * // Effect.runFork(program)
872
+ * Effect.runFork(program)
852
873
  * // Output: true
853
874
  * ```
854
875
  *
876
+ * @see {@link exists} for a similar function that returns a boolean indicating
877
+ * whether **any** element satisfies the predicate.
878
+ *
855
879
  * @since 2.0.0
856
880
  * @category Condition Checking
857
881
  */
@@ -878,10 +902,8 @@ const every = exports.every = effect.every;
878
902
  * This function allows you to quickly check for a condition in a collection
879
903
  * without having to manually iterate over it.
880
904
  *
881
- * @see {@link every} for a similar function that checks if **all** elements
882
- * satisfy the predicate.
905
+ * **Example**
883
906
  *
884
- * @example
885
907
  * ```ts
886
908
  * import { Effect } from "effect"
887
909
  *
@@ -893,10 +915,13 @@ const every = exports.every = effect.every;
893
915
  * console.log(hasLargeNumber)
894
916
  * })
895
917
  *
896
- * // Effect.runFork(program)
918
+ * Effect.runFork(program)
897
919
  * // Output: true
898
920
  * ```
899
921
  *
922
+ * @see {@link every} for a similar function that checks if **all** elements
923
+ * satisfy the predicate.
924
+ *
900
925
  * @since 2.0.0
901
926
  * @category Condition Checking
902
927
  */
@@ -925,7 +950,8 @@ const exists = exports.exists = fiberRuntime.exists;
925
950
  * This function allows you to selectively keep or remove elements based on a
926
951
  * condition that may involve asynchronous or side-effect-causing operations.
927
952
  *
928
- * @example
953
+ * **Example**
954
+ *
929
955
  * ```ts
930
956
  * import { Effect } from "effect"
931
957
  *
@@ -937,7 +963,7 @@ const exists = exports.exists = fiberRuntime.exists;
937
963
  * console.log(result)
938
964
  * })
939
965
  *
940
- * // Effect.runFork(program)
966
+ * Effect.runFork(program)
941
967
  * // Output: [2, 4]
942
968
  * ```
943
969
  *
@@ -953,7 +979,8 @@ const filter = exports.filter = fiberRuntime.filter;
953
979
  * element is kept; if it returns `None`, the element is removed. The operation
954
980
  * is done sequentially for each element.
955
981
  *
956
- * @example
982
+ * **Example**
983
+ *
957
984
  * ```ts
958
985
  * import { Console, Effect, Option } from "effect"
959
986
  *
@@ -968,7 +995,7 @@ const filter = exports.filter = fiberRuntime.filter;
968
995
  * (n) => n % 2 === 0 ? Option.some(n) : Option.none()
969
996
  * )
970
997
  *
971
- * // Effect.runPromise(program).then(console.log)
998
+ * Effect.runPromise(program).then(console.log)
972
999
  * // Output:
973
1000
  * // task1 done
974
1001
  * // task2 done
@@ -1003,7 +1030,8 @@ const filterMap = exports.filterMap = effect.filterMap;
1003
1030
  * condition, even when the evaluation involves effects like asynchronous
1004
1031
  * operations or side effects.
1005
1032
  *
1006
- * @example
1033
+ * **Example**
1034
+ *
1007
1035
  * ```ts
1008
1036
  * import { Effect } from "effect"
1009
1037
  *
@@ -1015,7 +1043,7 @@ const filterMap = exports.filterMap = effect.filterMap;
1015
1043
  * console.log(result)
1016
1044
  * })
1017
1045
  *
1018
- * // Effect.runFork(program)
1046
+ * Effect.runFork(program)
1019
1047
  * // Output: { _id: 'Option', _tag: 'Some', value: 4 }
1020
1048
  * ```
1021
1049
  *
@@ -1044,18 +1072,16 @@ const findFirst = exports.findFirst = effect.findFirst;
1044
1072
  * If the `discard` option is set to `true`, the intermediate results are not
1045
1073
  * collected, and the final result of the operation is `void`.
1046
1074
  *
1047
- * @see {@link all} for combining multiple effects into one.
1075
+ * **Example** (Applying Effects to Iterable Elements)
1048
1076
  *
1049
- * @example
1050
1077
  * ```ts
1051
- * // Title: Applying Effects to Iterable Elements
1052
1078
  * import { Effect, Console } from "effect"
1053
1079
  *
1054
1080
  * const result = Effect.forEach([1, 2, 3, 4, 5], (n, index) =>
1055
1081
  * Console.log(`Currently at index ${index}`).pipe(Effect.as(n * 2))
1056
1082
  * )
1057
1083
  *
1058
- * // Effect.runPromise(result).then(console.log)
1084
+ * Effect.runPromise(result).then(console.log)
1059
1085
  * // Output:
1060
1086
  * // Currently at index 0
1061
1087
  * // Currently at index 1
@@ -1065,8 +1091,9 @@ const findFirst = exports.findFirst = effect.findFirst;
1065
1091
  * // [ 2, 4, 6, 8, 10 ]
1066
1092
  * ```
1067
1093
  *
1068
- * @example
1069
- * // Title: Using discard to Ignore Results
1094
+ * **Example** (Discarding Results)
1095
+ *
1096
+ * ```ts
1070
1097
  * import { Effect, Console } from "effect"
1071
1098
  *
1072
1099
  * // Apply effects but discard the results
@@ -1077,7 +1104,7 @@ const findFirst = exports.findFirst = effect.findFirst;
1077
1104
  * { discard: true }
1078
1105
  * )
1079
1106
  *
1080
- * // Effect.runPromise(result).then(console.log)
1107
+ * Effect.runPromise(result).then(console.log)
1081
1108
  * // Output:
1082
1109
  * // Currently at index 0
1083
1110
  * // Currently at index 1
@@ -1085,6 +1112,9 @@ const findFirst = exports.findFirst = effect.findFirst;
1085
1112
  * // Currently at index 3
1086
1113
  * // Currently at index 4
1087
1114
  * // undefined
1115
+ * ```
1116
+ *
1117
+ * @see {@link all} for combining multiple effects into one.
1088
1118
  *
1089
1119
  * @since 2.0.0
1090
1120
  * @category Looping
@@ -1100,7 +1130,8 @@ const forEach = exports.forEach = fiberRuntime.forEach;
1100
1130
  * collection and want to handle the case where the collection might be empty
1101
1131
  * without causing an unhandled exception.
1102
1132
  *
1103
- * @example
1133
+ * **Example**
1134
+ *
1104
1135
  * ```ts
1105
1136
  * import { Effect } from "effect"
1106
1137
  *
@@ -1112,7 +1143,7 @@ const forEach = exports.forEach = fiberRuntime.forEach;
1112
1143
  * console.log(firstElement)
1113
1144
  * })
1114
1145
  *
1115
- * // Effect.runFork(program)
1146
+ * Effect.runFork(program)
1116
1147
  * // Output: 1
1117
1148
  * ```
1118
1149
  *
@@ -1140,7 +1171,8 @@ const head = exports.head = effect.head;
1140
1171
  * These options provide flexibility in running the effects concurrently or
1141
1172
  * adjusting other execution details.
1142
1173
  *
1143
- * @example
1174
+ * **Example**
1175
+ *
1144
1176
  * ```ts
1145
1177
  * import { Effect } from "effect"
1146
1178
  *
@@ -1153,7 +1185,7 @@ const head = exports.head = effect.head;
1153
1185
  * console.log(total)
1154
1186
  * })
1155
1187
  *
1156
- * // Effect.runFork(program)
1188
+ * Effect.runFork(program)
1157
1189
  * // Output: 6
1158
1190
  * ```
1159
1191
  *
@@ -1185,10 +1217,8 @@ const mergeAll = exports.mergeAll = fiberRuntime.mergeAll;
1185
1217
  * work with valid data. The function ensures that failures are captured, while
1186
1218
  * successes are processed normally.
1187
1219
  *
1188
- * @see {@link validateAll} for a function that either collects all failures or all successes.
1189
- * @see {@link validateFirst} for a function that stops at the first success.
1220
+ * **Example**
1190
1221
  *
1191
- * @example
1192
1222
  * ```ts
1193
1223
  * import { Effect } from "effect"
1194
1224
  *
@@ -1202,11 +1232,14 @@ const mergeAll = exports.mergeAll = fiberRuntime.mergeAll;
1202
1232
  * }
1203
1233
  * })
1204
1234
  *
1205
- * // Effect.runPromise(program).then(console.log, console.error)
1235
+ * Effect.runPromise(program).then(console.log, console.error)
1206
1236
  * // Output:
1207
1237
  * // [ [ '1 is not even', '3 is not even' ], [ 0, 2, 4 ] ]
1208
1238
  * ```
1209
1239
  *
1240
+ * @see {@link validateAll} for a function that either collects all failures or all successes.
1241
+ * @see {@link validateFirst} for a function that stops at the first success.
1242
+ *
1210
1243
  * @since 2.0.0
1211
1244
  * @category Error Accumulation
1212
1245
  */
@@ -1230,10 +1263,8 @@ const partition = exports.partition = fiberRuntime.partition;
1230
1263
  * numbers or combining results from multiple tasks. It ensures that operations
1231
1264
  * are performed one after the other, maintaining the order of the elements.
1232
1265
  *
1233
- * @see {@link reduceWhile} for a similar function that stops the process based on a predicate.
1234
- * @see {@link reduceRight} for a similar function that works from right to left.
1266
+ * **Example**
1235
1267
  *
1236
- * @example
1237
1268
  * ```ts
1238
1269
  * import { Console, Effect } from "effect"
1239
1270
  *
@@ -1249,7 +1280,7 @@ const partition = exports.partition = fiberRuntime.partition;
1249
1280
  * .pipe(Effect.map((order) => acc + order.price))
1250
1281
  * )
1251
1282
  *
1252
- * // Effect.runPromise(program).then(console.log)
1283
+ * Effect.runPromise(program).then(console.log)
1253
1284
  * // Output:
1254
1285
  * // Order 1 processed
1255
1286
  * // Order 2 processed
@@ -1258,6 +1289,9 @@ const partition = exports.partition = fiberRuntime.partition;
1258
1289
  * // 1000
1259
1290
  * ```
1260
1291
  *
1292
+ * @see {@link reduceWhile} for a similar function that stops the process based on a predicate.
1293
+ * @see {@link reduceRight} for a similar function that works from right to left.
1294
+ *
1261
1295
  * @since 2.0.0
1262
1296
  * @category Collecting
1263
1297
  */
@@ -1282,7 +1316,8 @@ const reduce = exports.reduce = effect.reduce;
1282
1316
  * if you want to sum values in a list but stop as soon as the sum exceeds a
1283
1317
  * certain threshold, you can use this function.
1284
1318
  *
1285
- * @example
1319
+ * **Example**
1320
+ *
1286
1321
  * ```ts
1287
1322
  * import { Console, Effect } from "effect"
1288
1323
  *
@@ -1301,7 +1336,7 @@ const reduce = exports.reduce = effect.reduce;
1301
1336
  * }
1302
1337
  * )
1303
1338
  *
1304
- * // Effect.runPromise(program).then(console.log)
1339
+ * Effect.runPromise(program).then(console.log)
1305
1340
  * // Output:
1306
1341
  * // Order 1 processed
1307
1342
  * // Order 2 processed
@@ -1332,9 +1367,8 @@ const reduceWhile = exports.reduceWhile = effect.reduceWhile;
1332
1367
  * numbers or combining results from multiple tasks. It ensures that operations
1333
1368
  * are performed one after the other, maintaining the order of the elements.
1334
1369
  *
1335
- * @see {@link reduce} for a similar function that works from left to right.
1370
+ * **Example**
1336
1371
  *
1337
- * @example
1338
1372
  * ```ts
1339
1373
  * import { Console, Effect } from "effect"
1340
1374
  *
@@ -1350,7 +1384,7 @@ const reduceWhile = exports.reduceWhile = effect.reduceWhile;
1350
1384
  * .pipe(Effect.map((order) => acc + order.price))
1351
1385
  * )
1352
1386
  *
1353
- * // Effect.runPromise(program).then(console.log)
1387
+ * Effect.runPromise(program).then(console.log)
1354
1388
  * // Output:
1355
1389
  * // Order 4 processed
1356
1390
  * // Order 3 processed
@@ -1359,6 +1393,8 @@ const reduceWhile = exports.reduceWhile = effect.reduceWhile;
1359
1393
  * // 1000
1360
1394
  * ```
1361
1395
  *
1396
+ * @see {@link reduce} for a similar function that works from left to right.
1397
+ *
1362
1398
  * @since 2.0.0
1363
1399
  * @category Collecting
1364
1400
  */
@@ -1379,7 +1415,8 @@ const reduceRight = exports.reduceRight = effect.reduceRight;
1379
1415
  * These options provide flexibility in running the effects concurrently or
1380
1416
  * adjusting other execution details.
1381
1417
  *
1382
- * @example
1418
+ * **Example**
1419
+ *
1383
1420
  * ```ts
1384
1421
  * import { Console, Effect } from "effect"
1385
1422
  *
@@ -1393,7 +1430,7 @@ const reduceRight = exports.reduceRight = effect.reduceRight;
1393
1430
  * (acc, order, i) => acc + order.price
1394
1431
  * )
1395
1432
  *
1396
- * // Effect.runPromise(program).then(console.log)
1433
+ * Effect.runPromise(program).then(console.log)
1397
1434
  * // Output:
1398
1435
  * // Order 1 processed
1399
1436
  * // Order 2 processed
@@ -1415,7 +1452,8 @@ const reduceEffect = exports.reduceEffect = fiberRuntime.reduceEffect;
1415
1452
  * (`n`). The result is an array of `n` effects, each of which is identical to
1416
1453
  * the original effect.
1417
1454
  *
1418
- * @example
1455
+ * **Example**
1456
+ *
1419
1457
  * ```ts
1420
1458
  * import { Console, Effect } from "effect"
1421
1459
  *
@@ -1432,7 +1470,7 @@ const reduceEffect = exports.reduceEffect = fiberRuntime.reduceEffect;
1432
1470
  * }
1433
1471
  * })
1434
1472
  *
1435
- * // Effect.runFork(program)
1473
+ * Effect.runFork(program)
1436
1474
  * // Output:
1437
1475
  * // Hello, World!
1438
1476
  * // Hello, World!
@@ -1462,7 +1500,8 @@ const replicate = exports.replicate = fiberRuntime.replicate;
1462
1500
  * These options provide flexibility in running the effects concurrently or
1463
1501
  * adjusting other execution details.
1464
1502
  *
1465
- * @example
1503
+ * **Example**
1504
+ *
1466
1505
  * ```ts
1467
1506
  * import { Console, Effect } from "effect"
1468
1507
  *
@@ -1478,7 +1517,7 @@ const replicate = exports.replicate = fiberRuntime.replicate;
1478
1517
  * yield* Console.log(`Results: ${results.join(", ")}`)
1479
1518
  * })
1480
1519
  *
1481
- * // Effect.runFork(program)
1520
+ * Effect.runFork(program)
1482
1521
  * // Output:
1483
1522
  * // Task completed
1484
1523
  * // Task completed
@@ -1512,11 +1551,8 @@ const replicateEffect = exports.replicateEffect = fiberRuntime.replicateEffect;
1512
1551
  * so this function is not suitable when you need to keep the successful results
1513
1552
  * in case of errors.
1514
1553
  *
1515
- * @see {@link forEach} for a similar function that stops at the first error.
1516
- * @see {@link partition} when you need to separate successes and failures
1517
- * instead of losing successes with errors.
1554
+ * **Example**
1518
1555
  *
1519
- * @example
1520
1556
  * ```ts
1521
1557
  * import { Effect, Console } from "effect"
1522
1558
  *
@@ -1530,7 +1566,7 @@ const replicateEffect = exports.replicateEffect = fiberRuntime.replicateEffect;
1530
1566
  * }
1531
1567
  * })
1532
1568
  *
1533
- * // Effect.runPromiseExit(program).then(console.log)
1569
+ * Effect.runPromiseExit(program).then(console.log)
1534
1570
  * // Output:
1535
1571
  * // item 1
1536
1572
  * // item 2
@@ -1546,6 +1582,10 @@ const replicateEffect = exports.replicateEffect = fiberRuntime.replicateEffect;
1546
1582
  * // }
1547
1583
  * ```
1548
1584
  *
1585
+ * @see {@link forEach} for a similar function that stops at the first error.
1586
+ * @see {@link partition} when you need to separate successes and failures
1587
+ * instead of losing successes with errors.
1588
+ *
1549
1589
  * @since 2.0.0
1550
1590
  * @category Error Accumulation
1551
1591
  */
@@ -1564,11 +1604,8 @@ const validateAll = exports.validateAll = fiberRuntime.validateAll;
1564
1604
  * errors. This can be useful when you are interested in the first successful
1565
1605
  * result and want to avoid processing further once a valid result is found.
1566
1606
  *
1567
- * @see {@link validateAll} for a similar function that accumulates all results.
1568
- * @see {@link firstSuccessOf} for a similar function that processes multiple
1569
- * effects and returns the first successful one or the last error.
1607
+ * **Example**
1570
1608
  *
1571
- * @example
1572
1609
  * ```ts
1573
1610
  * import { Effect, Console } from "effect"
1574
1611
  *
@@ -1582,12 +1619,16 @@ const validateAll = exports.validateAll = fiberRuntime.validateAll;
1582
1619
  * }
1583
1620
  * })
1584
1621
  *
1585
- * // Effect.runPromise(program).then(console.log, console.error)
1622
+ * Effect.runPromise(program).then(console.log, console.error)
1586
1623
  * // Output:
1587
1624
  * // item 4
1588
1625
  * // 4
1589
1626
  * ```
1590
1627
  *
1628
+ * @see {@link validateAll} for a similar function that accumulates all results.
1629
+ * @see {@link firstSuccessOf} for a similar function that processes multiple
1630
+ * effects and returns the first successful one or the last error.
1631
+ *
1591
1632
  * @since 2.0.0
1592
1633
  * @category Error Accumulation
1593
1634
  */
@@ -1616,9 +1657,9 @@ const validateFirst = exports.validateFirst = fiberRuntime.validateFirst;
1616
1657
  * Use `Effect.async` when dealing with APIs that use callback-style instead of
1617
1658
  * `async/await` or `Promise`.
1618
1659
  *
1619
- * @example
1660
+ * **Example** (Wrapping a Callback API)
1661
+ *
1620
1662
  * ```ts
1621
- * // Title: Wrapping a Callback API
1622
1663
  * import { Effect } from "effect"
1623
1664
  * import * as NodeFS from "node:fs"
1624
1665
  *
@@ -1640,8 +1681,9 @@ const validateFirst = exports.validateFirst = fiberRuntime.validateFirst;
1640
1681
  * const program = readFile("example.txt")
1641
1682
  * ```
1642
1683
  *
1643
- * @example
1644
- * // Title: Handling Interruption with Cleanup
1684
+ * **Example** (Handling Interruption with Cleanup)
1685
+ *
1686
+ * ```ts
1645
1687
  * import { Effect, Fiber } from "effect"
1646
1688
  * import * as NodeFS from "node:fs"
1647
1689
  *
@@ -1676,12 +1718,14 @@ const validateFirst = exports.validateFirst = fiberRuntime.validateFirst;
1676
1718
  * })
1677
1719
  *
1678
1720
  * // Run the program
1679
- * // Effect.runPromise(program)
1721
+ * Effect.runPromise(program)
1680
1722
  * // Output:
1681
1723
  * // Cleaning up example.txt
1724
+ * ```
1725
+ *
1726
+ * **Example** (Handling Interruption with AbortSignal)
1682
1727
  *
1683
- * @example
1684
- * // Title: Handling Interruption with AbortSignal
1728
+ * ```ts
1685
1729
  * import { Effect, Fiber } from "effect"
1686
1730
  *
1687
1731
  * // A task that supports interruption using AbortSignal
@@ -1707,9 +1751,10 @@ const validateFirst = exports.validateFirst = fiberRuntime.validateFirst;
1707
1751
  * })
1708
1752
  *
1709
1753
  * // Run the program
1710
- * // Effect.runPromise(program)
1754
+ * Effect.runPromise(program)
1711
1755
  * // Output:
1712
1756
  * // Abort signal received
1757
+ * ```
1713
1758
  *
1714
1759
  * @since 2.0.0
1715
1760
  * @category Creating Effects
@@ -1728,7 +1773,8 @@ const asyncEffect = exports.asyncEffect = runtime_.asyncEffect;
1728
1773
  * It is meant to be called with a bag of instructions that become available in
1729
1774
  * the "this" of the effect.
1730
1775
  *
1731
- * @example
1776
+ * **Example**
1777
+ *
1732
1778
  * ```ts
1733
1779
  * import { Effect } from "effect"
1734
1780
  *
@@ -1756,11 +1802,9 @@ const withFiberRuntime = exports.withFiberRuntime = core.withFiberRuntime;
1756
1802
  * will keep propagating unless it is handled. You can handle the error with
1757
1803
  * functions like {@link catchAll} or {@link catchTag}.
1758
1804
  *
1759
- * @see {@link succeed} to create an effect that represents a successful value.
1805
+ * **Example** (Creating a Failed Effect)
1760
1806
  *
1761
- * @example
1762
1807
  * ```ts
1763
- * // Title: Creating a Failed Effect
1764
1808
  * import { Effect } from "effect"
1765
1809
  *
1766
1810
  * // ┌─── Effect<never, Error, never>
@@ -1770,6 +1814,8 @@ const withFiberRuntime = exports.withFiberRuntime = core.withFiberRuntime;
1770
1814
  * )
1771
1815
  * ```
1772
1816
  *
1817
+ * @see {@link succeed} to create an effect that represents a successful value.
1818
+ *
1773
1819
  * @since 2.0.0
1774
1820
  * @category Creating Effects
1775
1821
  */
@@ -1813,14 +1859,9 @@ const failCauseSync = exports.failCauseSync = core.failCauseSync;
1813
1859
  * should not be handled as regular errors but instead represent unrecoverable
1814
1860
  * defects.
1815
1861
  *
1816
- * @see {@link dieSync} for a variant that throws a specified error, evaluated
1817
- * lazily.
1818
- * @see {@link dieMessage} for a variant that throws a `RuntimeException` with a
1819
- * message.
1862
+ * **Example** (Terminating on Division by Zero with a Specified Error)
1820
1863
  *
1821
- * @example
1822
1864
  * ```ts
1823
- * // Title: Terminating on Division by Zero with a Specified Error
1824
1865
  * import { Effect } from "effect"
1825
1866
  *
1826
1867
  * const divide = (a: number, b: number) =>
@@ -1832,12 +1873,17 @@ const failCauseSync = exports.failCauseSync = core.failCauseSync;
1832
1873
  * // ▼
1833
1874
  * const program = divide(1, 0)
1834
1875
  *
1835
- * // Effect.runPromise(program).catch(console.error)
1876
+ * Effect.runPromise(program).catch(console.error)
1836
1877
  * // Output:
1837
1878
  * // (FiberFailure) Error: Cannot divide by zero
1838
1879
  * // ...stack trace...
1839
1880
  * ```
1840
1881
  *
1882
+ * @see {@link dieSync} for a variant that throws a specified error, evaluated
1883
+ * lazily.
1884
+ * @see {@link dieMessage} for a variant that throws a `RuntimeException` with a
1885
+ * message.
1886
+ *
1841
1887
  * @since 2.0.0
1842
1888
  * @category Creating Effects
1843
1889
  */
@@ -1860,13 +1906,9 @@ const die = exports.die = core.die;
1860
1906
  * Use this function when you want to terminate a fiber due to an unrecoverable
1861
1907
  * defect and include a clear explanation in the message.
1862
1908
  *
1863
- * @see {@link die} for a variant that throws a specified error.
1864
- * @see {@link dieSync} for a variant that throws a specified error, evaluated
1865
- * lazily.
1909
+ * **Example** (Terminating on Division by Zero with a Specified Message)
1866
1910
  *
1867
- * @example
1868
1911
  * ```ts
1869
- * // Title: Terminating on Division by Zero with a Specified Message
1870
1912
  * import { Effect } from "effect"
1871
1913
  *
1872
1914
  * const divide = (a: number, b: number) =>
@@ -1878,12 +1920,16 @@ const die = exports.die = core.die;
1878
1920
  * // ▼
1879
1921
  * const program = divide(1, 0)
1880
1922
  *
1881
- * // Effect.runPromise(program).catch(console.error)
1923
+ * Effect.runPromise(program).catch(console.error)
1882
1924
  * // Output:
1883
1925
  * // (FiberFailure) RuntimeException: Cannot divide by zero
1884
1926
  * // ...stack trace...
1885
1927
  * ```
1886
1928
  *
1929
+ * @see {@link die} for a variant that throws a specified error.
1930
+ * @see {@link dieSync} for a variant that throws a specified error, evaluated
1931
+ * lazily.
1932
+ *
1887
1933
  * @since 2.0.0
1888
1934
  * @category Creating Effects
1889
1935
  */
@@ -1917,7 +1963,8 @@ const dieSync = exports.dieSync = core.dieSync;
1917
1963
  * explicit control over the execution of effects. You can `yield*` values from
1918
1964
  * effects and return the final result at the end.
1919
1965
  *
1920
- * @example
1966
+ * **Example**
1967
+ *
1921
1968
  * ```ts
1922
1969
  * import { Effect } from "effect"
1923
1970
  *
@@ -2009,11 +2056,9 @@ const none = exports.none = effect.none;
2009
2056
  *
2010
2057
  * Use this function when you are sure the operation will not reject.
2011
2058
  *
2012
- * @see {@link tryPromise} for a version that can handle failures.
2059
+ * **Example** (Delayed Message)
2013
2060
  *
2014
- * @example
2015
2061
  * ```ts
2016
- * // Title: Delayed Message
2017
2062
  * import { Effect } from "effect"
2018
2063
  *
2019
2064
  * const delay = (message: string) =>
@@ -2031,6 +2076,8 @@ const none = exports.none = effect.none;
2031
2076
  * const program = delay("Async operation completed successfully!")
2032
2077
  * ```
2033
2078
  *
2079
+ * @see {@link tryPromise} for a version that can handle failures.
2080
+ *
2034
2081
  * @since 2.0.0
2035
2082
  * @category Creating Effects
2036
2083
  */
@@ -2043,11 +2090,9 @@ const promise = exports.promise = effect.promise;
2043
2090
  * Use this function when you need an effect that completes successfully with a
2044
2091
  * specific value without any errors or external dependencies.
2045
2092
  *
2046
- * @see {@link fail} to create an effect that represents a failure.
2093
+ * **Example** (Creating a Successful Effect)
2047
2094
  *
2048
- * @example
2049
2095
  * ```ts
2050
- * // Title: Creating a Successful Effect
2051
2096
  * import { Effect } from "effect"
2052
2097
  *
2053
2098
  * // Creating an effect that represents a successful scenario
@@ -2057,6 +2102,8 @@ const promise = exports.promise = effect.promise;
2057
2102
  * const success = Effect.succeed(42)
2058
2103
  * ```
2059
2104
  *
2105
+ * @see {@link fail} to create an effect that represents a failure.
2106
+ *
2060
2107
  * @since 2.0.0
2061
2108
  * @category Creating Effects
2062
2109
  */
@@ -2112,9 +2159,9 @@ const succeedSome = exports.succeedSome = effect.succeedSome;
2112
2159
  * computations, managing circular dependencies, or resolving type inference
2113
2160
  * issues.
2114
2161
  *
2115
- * @example
2162
+ * **Example** (Lazy Evaluation with Side Effects)
2163
+ *
2116
2164
  * ```ts
2117
- * // Title: Lazy Evaluation with Side Effects
2118
2165
  * import { Effect } from "effect"
2119
2166
  *
2120
2167
  * let i = 0
@@ -2130,8 +2177,9 @@ const succeedSome = exports.succeedSome = effect.succeedSome;
2130
2177
  * console.log(Effect.runSync(good)) // Output: 2
2131
2178
  * ```
2132
2179
  *
2133
- * @example
2134
- * // Title: Recursive Fibonacci
2180
+ * **Example** (Recursive Fibonacci)
2181
+ *
2182
+ * ```ts
2135
2183
  * import { Effect } from "effect"
2136
2184
  *
2137
2185
  * const blowsUp = (n: number): Effect.Effect<number> =>
@@ -2139,7 +2187,7 @@ const succeedSome = exports.succeedSome = effect.succeedSome;
2139
2187
  * ? Effect.succeed(1)
2140
2188
  * : Effect.zipWith(blowsUp(n - 1), blowsUp(n - 2), (a, b) => a + b)
2141
2189
  *
2142
- * // console.log(Effect.runSync(blowsUp(32)))
2190
+ * console.log(Effect.runSync(blowsUp(32)))
2143
2191
  * // crash: JavaScript heap out of memory
2144
2192
  *
2145
2193
  * const allGood = (n: number): Effect.Effect<number> =>
@@ -2153,9 +2201,11 @@ const succeedSome = exports.succeedSome = effect.succeedSome;
2153
2201
  *
2154
2202
  * console.log(Effect.runSync(allGood(32)))
2155
2203
  * // Output: 3524578
2204
+ * ```
2205
+ *
2206
+ * **Example** (Using Effect.suspend to Help TypeScript Infer Types)
2156
2207
  *
2157
- * @example
2158
- * // Title: Using Effect.suspend to Help TypeScript Infer Types
2208
+ * ```ts
2159
2209
  * import { Effect } from "effect"
2160
2210
  *
2161
2211
  * // Without suspend, TypeScript may struggle with type inference.
@@ -2176,6 +2226,7 @@ const succeedSome = exports.succeedSome = effect.succeedSome;
2176
2226
  * ? Effect.fail(new Error("Cannot divide by zero"))
2177
2227
  * : Effect.succeed(a / b)
2178
2228
  * )
2229
+ * ```
2179
2230
  *
2180
2231
  * @since 2.0.0
2181
2232
  * @category Creating Effects
@@ -2198,11 +2249,9 @@ const suspend = exports.suspend = core.suspend;
2198
2249
  *
2199
2250
  * Use this function when you are sure the operation will not fail.
2200
2251
  *
2201
- * @see {@link try_ | try} for a version that can handle failures.
2252
+ * **Example** (Logging a Message)
2202
2253
  *
2203
- * @example
2204
2254
  * ```ts
2205
- * // Title: Logging a Message
2206
2255
  * import { Effect } from "effect"
2207
2256
  *
2208
2257
  * const log = (message: string) =>
@@ -2215,6 +2264,8 @@ const suspend = exports.suspend = core.suspend;
2215
2264
  * const program = log("Hello, World!")
2216
2265
  * ```
2217
2266
  *
2267
+ * @see {@link try_ | try} for a version that can handle failures.
2268
+ *
2218
2269
  * @since 2.0.0
2219
2270
  * @category Creating Effects
2220
2271
  */
@@ -2239,12 +2290,9 @@ const _catch = exports.catch = effect._catch;
2239
2290
  * **Note**: This function only handles recoverable errors. It will not recover
2240
2291
  * from unrecoverable defects.
2241
2292
  *
2242
- * @see {@link catchAllCause} for a version that can recover from both
2243
- * recoverable and unrecoverable errors.
2293
+ * **Example** (Providing Recovery Logic for Recoverable Errors)
2244
2294
  *
2245
- * @example
2246
2295
  * ```ts
2247
- * // Title: Providing Recovery Logic for Recoverable Errors
2248
2296
  * import { Effect, Random } from "effect"
2249
2297
  *
2250
2298
  * class HttpError {
@@ -2278,6 +2326,9 @@ const _catch = exports.catch = effect._catch;
2278
2326
  * )
2279
2327
  * ```
2280
2328
  *
2329
+ * @see {@link catchAllCause} for a version that can recover from both
2330
+ * recoverable and unrecoverable errors.
2331
+ *
2281
2332
  * @since 2.0.0
2282
2333
  * @category Error handling
2283
2334
  */
@@ -2299,9 +2350,9 @@ const catchAll = exports.catchAll = core.catchAll;
2299
2350
  * they often indicate serious issues. However, in some cases, such as
2300
2351
  * dynamically loaded plugins, controlled recovery might be needed.
2301
2352
  *
2302
- * @example
2353
+ * **Example** (Recovering from All Errors)
2354
+ *
2303
2355
  * ```ts
2304
- * // Title: Recovering from All Errors
2305
2356
  * import { Cause, Effect } from "effect"
2306
2357
  *
2307
2358
  * // Define an effect that may fail with a recoverable or unrecoverable error
@@ -2316,7 +2367,7 @@ const catchAll = exports.catchAll = core.catchAll;
2316
2367
  * )
2317
2368
  * )
2318
2369
  *
2319
- * // Effect.runPromise(recovered).then(console.log)
2370
+ * Effect.runPromise(recovered).then(console.log)
2320
2371
  * // Output: "Recovered from a regular error"
2321
2372
  * ```
2322
2373
  *
@@ -2347,9 +2398,9 @@ const catchAllCause = exports.catchAllCause = core.catchAllCause;
2347
2398
  * they often indicate serious issues. However, in some cases, such as
2348
2399
  * dynamically loaded plugins, controlled recovery might be needed.
2349
2400
  *
2350
- * @example
2401
+ * **Example** (Handling All Defects)
2402
+ *
2351
2403
  * ```ts
2352
- * // Title: Handling All Defects
2353
2404
  * import { Effect, Cause, Console } from "effect"
2354
2405
  *
2355
2406
  * // Simulating a runtime error
@@ -2365,7 +2416,7 @@ const catchAllCause = exports.catchAllCause = core.catchAllCause;
2365
2416
  * })
2366
2417
  *
2367
2418
  * // We get an Exit.Success because we caught all defects
2368
- * // Effect.runPromiseExit(program).then(console.log)
2419
+ * Effect.runPromiseExit(program).then(console.log)
2369
2420
  * // Output:
2370
2421
  * // RuntimeException defect caught: Boom!
2371
2422
  * // {
@@ -2390,9 +2441,9 @@ const catchAllDefect = exports.catchAllDefect = effect.catchAllDefect;
2390
2441
  * alter the error type, so the resulting effect still carries the original
2391
2442
  * error type unless a user-defined type guard is used to narrow the type.
2392
2443
  *
2393
- * @example
2444
+ * **Example** (Catching Specific Errors with a Predicate)
2445
+ *
2394
2446
  * ```ts
2395
- * // Title: Catching Specific Errors with a Predicate
2396
2447
  * import { Effect, Random } from "effect"
2397
2448
  *
2398
2449
  * class HttpError {
@@ -2444,11 +2495,9 @@ const catchIf = exports.catchIf = core.catchIf;
2444
2495
  * program. This function doesn't alter the error type, meaning the error type
2445
2496
  * remains the same as in the original effect.
2446
2497
  *
2447
- * @see {@link catchIf} for a version that allows you to recover from errors based on a predicate.
2498
+ * **Example** (Handling Specific Errors with Effect.catchSome)
2448
2499
  *
2449
- * @example
2450
2500
  * ```ts
2451
- * // Title: Handling Specific Errors with Effect.catchSome
2452
2501
  * import { Effect, Random, Option } from "effect"
2453
2502
  *
2454
2503
  * class HttpError {
@@ -2487,6 +2536,8 @@ const catchIf = exports.catchIf = core.catchIf;
2487
2536
  * )
2488
2537
  * ```
2489
2538
  *
2539
+ * @see {@link catchIf} for a version that allows you to recover from errors based on a predicate.
2540
+ *
2490
2541
  * @since 2.0.0
2491
2542
  * @category Error handling
2492
2543
  */
@@ -2527,9 +2578,9 @@ const catchSomeCause = exports.catchSomeCause = effect.catchSomeCause;
2527
2578
  * an `Option.some` containing the recovery logic.
2528
2579
  * - If the defect does not match, the function returns `Option.none`, allowing the defect to propagate.
2529
2580
  *
2530
- * @example
2581
+ * **Example** (Handling Specific Defects)
2582
+ *
2531
2583
  * ```ts
2532
- * // Title: Handling Specific Defects
2533
2584
  * import { Effect, Cause, Option, Console } from "effect"
2534
2585
  *
2535
2586
  * // Simulating a runtime error
@@ -2548,7 +2599,7 @@ const catchSomeCause = exports.catchSomeCause = effect.catchSomeCause;
2548
2599
  *
2549
2600
  * // Since we are only catching IllegalArgumentException
2550
2601
  * // we will get an Exit.Failure because we simulated a runtime error.
2551
- * // Effect.runPromiseExit(program).then(console.log)
2602
+ * Effect.runPromiseExit(program).then(console.log)
2552
2603
  * // Output:
2553
2604
  * // {
2554
2605
  * // _id: 'Exit',
@@ -2579,12 +2630,9 @@ const catchSomeDefect = exports.catchSomeDefect = effect.catchSomeDefect;
2579
2630
  * The error type must have a readonly `_tag` field to use `catchTag`. This
2580
2631
  * field is used to identify and match errors.
2581
2632
  *
2582
- * @see {@link catchTags} for a version that allows you to handle multiple error
2583
- * types at once.
2633
+ * **Example** (Handling Errors by Tag)
2584
2634
  *
2585
- * @example
2586
2635
  * ```ts
2587
- * // Title: Handling Errors by Tag
2588
2636
  * import { Effect, Random } from "effect"
2589
2637
  *
2590
2638
  * class HttpError {
@@ -2619,6 +2667,9 @@ const catchSomeDefect = exports.catchSomeDefect = effect.catchSomeDefect;
2619
2667
  * )
2620
2668
  * ```
2621
2669
  *
2670
+ * @see {@link catchTags} for a version that allows you to handle multiple error
2671
+ * types at once.
2672
+ *
2622
2673
  * @since 2.0.0
2623
2674
  * @category Error handling
2624
2675
  */
@@ -2637,9 +2688,9 @@ const catchTag = exports.catchTag = effect.catchTag;
2637
2688
  * The error type must have a readonly `_tag` field to use `catchTag`. This
2638
2689
  * field is used to identify and match errors.
2639
2690
  *
2640
- * @example
2691
+ * **Example** (Handling Multiple Tagged Error Types at Once)
2692
+ *
2641
2693
  * ```ts
2642
- * // Title: Handling Multiple Tagged Error Types at Once
2643
2694
  * import { Effect, Random } from "effect"
2644
2695
  *
2645
2696
  * class HttpError {
@@ -2697,7 +2748,8 @@ const catchTags = exports.catchTags = effect.catchTags;
2697
2748
  * distinguishing between different types of defects (e.g., runtime exceptions,
2698
2749
  * interruptions, etc.).
2699
2750
  *
2700
- * @example
2751
+ * **Example**
2752
+ *
2701
2753
  * ```ts
2702
2754
  * import { Effect, Console } from "effect"
2703
2755
  *
@@ -2736,7 +2788,8 @@ const cause = exports.cause = effect.cause;
2736
2788
  * (e.g., a network request), and you want to keep trying without handling or
2737
2789
  * worrying about the errors.
2738
2790
  *
2739
- * @example
2791
+ * **Example**
2792
+ *
2740
2793
  * ```ts
2741
2794
  * import { Effect } from "effect"
2742
2795
  *
@@ -2755,7 +2808,7 @@ const cause = exports.cause = effect.cause;
2755
2808
  *
2756
2809
  * const program = Effect.eventually(effect)
2757
2810
  *
2758
- * // Effect.runPromise(program).then(console.log)
2811
+ * Effect.runPromise(program).then(console.log)
2759
2812
  * // Output:
2760
2813
  * // running effect
2761
2814
  * // running effect
@@ -2776,11 +2829,9 @@ const eventually = exports.eventually = effect.eventually;
2776
2829
  * it succeeds or fails. This is useful when you only care about the side
2777
2830
  * effects of the effect and do not need to handle or process its outcome.
2778
2831
  *
2779
- * @see {@link ignoreLogged} to log failures while ignoring them.
2832
+ * **Example** (Using Effect.ignore to Discard Values)
2780
2833
  *
2781
- * @example
2782
2834
  * ```ts
2783
- * // Title: Using Effect.ignore to Discard Values
2784
2835
  * import { Effect } from "effect"
2785
2836
  *
2786
2837
  * // ┌─── Effect<number, string, never>
@@ -2792,6 +2843,8 @@ const eventually = exports.eventually = effect.eventually;
2792
2843
  * const program = Effect.ignore(task)
2793
2844
  * ```
2794
2845
  *
2846
+ * @see {@link ignoreLogged} to log failures while ignoring them.
2847
+ *
2795
2848
  * @since 2.0.0
2796
2849
  * @category Error handling
2797
2850
  */
@@ -2833,7 +2886,8 @@ const ignoreLogged = exports.ignoreLogged = effect.ignoreLogged;
2833
2886
  * error handling in cases where you don't need to differentiate between each
2834
2887
  * failure, but simply want to know that multiple failures occurred.
2835
2888
  *
2836
- * @example
2889
+ * **Example**
2890
+ *
2837
2891
  * ```ts
2838
2892
  * import { Effect } from "effect"
2839
2893
  *
@@ -2846,7 +2900,7 @@ const ignoreLogged = exports.ignoreLogged = effect.ignoreLogged;
2846
2900
  * concurrency: "unbounded"
2847
2901
  * }).pipe(Effect.asVoid, Effect.parallelErrors)
2848
2902
  *
2849
- * // Effect.runPromiseExit(program).then(console.log)
2903
+ * Effect.runPromiseExit(program).then(console.log)
2850
2904
  * // Output:
2851
2905
  * // {
2852
2906
  * // _id: 'Exit',
@@ -2876,9 +2930,8 @@ const parallelErrors = exports.parallelErrors = effect.parallelErrors;
2876
2930
  * changes using {@link unsandbox} to return to the original error-handling
2877
2931
  * behavior.
2878
2932
  *
2879
- * @see {@link unsandbox} to restore the original error handling.
2933
+ * **Example**
2880
2934
  *
2881
- * @example
2882
2935
  * ```ts
2883
2936
  * import { Effect, Console } from "effect"
2884
2937
  *
@@ -2910,12 +2963,14 @@ const parallelErrors = exports.parallelErrors = effect.parallelErrors;
2910
2963
  * // Restore the original error handling with unsandbox
2911
2964
  * const main = Effect.unsandbox(program)
2912
2965
  *
2913
- * // Effect.runPromise(main).then(console.log)
2966
+ * Effect.runPromise(main).then(console.log)
2914
2967
  * // Output:
2915
2968
  * // Caught a defect: Oh uh!
2916
2969
  * // fallback result on failure
2917
2970
  * ```
2918
2971
  *
2972
+ * @see {@link unsandbox} to restore the original error handling.
2973
+ *
2919
2974
  * @since 2.0.0
2920
2975
  * @category Error handling
2921
2976
  */
@@ -2941,12 +2996,9 @@ const sandbox = exports.sandbox = effect.sandbox;
2941
2996
  * can control the number of retries, the delay between them, and when to stop
2942
2997
  * retrying.
2943
2998
  *
2944
- * @see {@link retryOrElse} for a version that allows you to run a fallback.
2945
- * @see {@link repeat} if your retry condition is based on successful outcomes rather than errors.
2999
+ * **Example** (Retrying with a Fixed Delay)
2946
3000
  *
2947
- * @example
2948
3001
  * ```ts
2949
- * // Title: Retrying with a Fixed Delay
2950
3002
  * import { Effect, Schedule } from "effect"
2951
3003
  *
2952
3004
  * let count = 0
@@ -2968,7 +3020,7 @@ const sandbox = exports.sandbox = effect.sandbox;
2968
3020
  *
2969
3021
  * const repeated = Effect.retry(task, policy)
2970
3022
  *
2971
- * // Effect.runPromise(repeated).then(console.log)
3023
+ * Effect.runPromise(repeated).then(console.log)
2972
3024
  * // Output:
2973
3025
  * // failure
2974
3026
  * // failure
@@ -2977,9 +3029,9 @@ const sandbox = exports.sandbox = effect.sandbox;
2977
3029
  * // yay!
2978
3030
  * ```
2979
3031
  *
2980
- * @example
3032
+ * **Example** (Retrying a Task up to 5 times)
3033
+ *
2981
3034
  * ```ts
2982
- * // Title: Retrying a Task up to 5 times
2983
3035
  * import { Effect } from "effect"
2984
3036
  *
2985
3037
  * let count = 0
@@ -2997,7 +3049,7 @@ const sandbox = exports.sandbox = effect.sandbox;
2997
3049
  * })
2998
3050
  *
2999
3051
  * // Retry the task up to 5 times
3000
- * // Effect.runPromise(Effect.retry(task, { times: 5 }))
3052
+ * Effect.runPromise(Effect.retry(task, { times: 5 })).then(console.log)
3001
3053
  * // Output:
3002
3054
  * // failure
3003
3055
  * // failure
@@ -3005,9 +3057,9 @@ const sandbox = exports.sandbox = effect.sandbox;
3005
3057
  * // success
3006
3058
  * ```
3007
3059
  *
3008
- * @example
3060
+ * **Example** (Retrying Until a Specific Condition is Met)
3061
+ *
3009
3062
  * ```ts
3010
- * // Title: Retrying Until a Specific Condition is Met
3011
3063
  * import { Effect } from "effect"
3012
3064
  *
3013
3065
  * let count = 0
@@ -3023,7 +3075,7 @@ const sandbox = exports.sandbox = effect.sandbox;
3023
3075
  * until: (err) => err === "Error 3"
3024
3076
  * })
3025
3077
  *
3026
- * // Effect.runPromiseExit(program).then(console.log)
3078
+ * Effect.runPromiseExit(program).then(console.log)
3027
3079
  * // Output:
3028
3080
  * // Action called 1 time(s)
3029
3081
  * // Action called 2 time(s)
@@ -3035,6 +3087,9 @@ const sandbox = exports.sandbox = effect.sandbox;
3035
3087
  * // }
3036
3088
  * ```
3037
3089
  *
3090
+ * @see {@link retryOrElse} for a version that allows you to run a fallback.
3091
+ * @see {@link repeat} if your retry condition is based on successful outcomes rather than errors.
3092
+ *
3038
3093
  * @since 2.0.0
3039
3094
  * @category Error handling
3040
3095
  */
@@ -3055,11 +3110,9 @@ const retry = exports.retry = schedule_.retry_combined;
3055
3110
  * This function is useful when you want to handle failures gracefully by
3056
3111
  * specifying an alternative action after repeated failures.
3057
3112
  *
3058
- * @see {@link retry} for a version that does not run a fallback effect.
3113
+ * **Example** (Retrying with Fallback)
3059
3114
  *
3060
- * @example
3061
3115
  * ```ts
3062
- * // Title: Retrying with Fallback
3063
3116
  * import { Effect, Schedule, Console } from "effect"
3064
3117
  *
3065
3118
  * let count = 0
@@ -3087,7 +3140,7 @@ const retry = exports.retry = schedule_.retry_combined;
3087
3140
  * () => Console.log("orElse").pipe(Effect.as("default value"))
3088
3141
  * )
3089
3142
  *
3090
- * // Effect.runPromise(repeated).then(console.log)
3143
+ * Effect.runPromise(repeated).then(console.log)
3091
3144
  * // Output:
3092
3145
  * // failure
3093
3146
  * // failure
@@ -3096,6 +3149,8 @@ const retry = exports.retry = schedule_.retry_combined;
3096
3149
  * // default value
3097
3150
  * ```
3098
3151
  *
3152
+ * @see {@link retry} for a version that does not run a fallback effect.
3153
+ *
3099
3154
  * @since 2.0.0
3100
3155
  * @category Error handling
3101
3156
  */
@@ -3152,11 +3207,9 @@ const tryMapPromise = exports.tryMapPromise = effect.tryMapPromise;
3152
3207
  * An optional `AbortSignal` can be provided to allow for interruption of the
3153
3208
  * wrapped `Promise` API.
3154
3209
  *
3155
- * @see {@link promise} if the effectful computation is asynchronous and does not throw errors.
3210
+ * **Example** (Fetching a TODO Item)
3156
3211
  *
3157
- * @example
3158
3212
  * ```ts
3159
- * // Title: Fetching a TODO Item
3160
3213
  * import { Effect } from "effect"
3161
3214
  *
3162
3215
  * const getTodo = (id: number) =>
@@ -3170,8 +3223,9 @@ const tryMapPromise = exports.tryMapPromise = effect.tryMapPromise;
3170
3223
  * const program = getTodo(1)
3171
3224
  * ```
3172
3225
  *
3173
- * @example
3174
- * // Title: Custom Error Handling
3226
+ * **Example** (Custom Error Handling)
3227
+ *
3228
+ * ```ts
3175
3229
  * import { Effect } from "effect"
3176
3230
  *
3177
3231
  * const getTodo = (id: number) =>
@@ -3184,6 +3238,9 @@ const tryMapPromise = exports.tryMapPromise = effect.tryMapPromise;
3184
3238
  * // ┌─── Effect<Response, Error, never>
3185
3239
  * // ▼
3186
3240
  * const program = getTodo(1)
3241
+ * ```
3242
+ *
3243
+ * @see {@link promise} if the effectful computation is asynchronous and does not throw errors.
3187
3244
  *
3188
3245
  * @since 2.0.0
3189
3246
  * @category Creating Effects
@@ -3241,7 +3298,8 @@ const allowInterrupt = exports.allowInterrupt = effect.allowInterrupt;
3241
3298
  * operation can be interrupted, such as when performing asynchronous operations
3242
3299
  * or handling cancellation.
3243
3300
  *
3244
- * @example
3301
+ * **Example**
3302
+ *
3245
3303
  * ```ts
3246
3304
  * import { Console, Effect } from "effect"
3247
3305
  *
@@ -3255,10 +3313,10 @@ const allowInterrupt = exports.allowInterrupt = effect.allowInterrupt;
3255
3313
  * })
3256
3314
  * })
3257
3315
  *
3258
- * // Effect.runPromise(program)
3316
+ * Effect.runPromise(program)
3259
3317
  * // Output: You can interrupt this operation.
3260
3318
  *
3261
- * // Effect.runPromise(program.pipe(Effect.uninterruptible))
3319
+ * Effect.runPromise(program.pipe(Effect.uninterruptible))
3262
3320
  * // Output: This operation cannot be interrupted.
3263
3321
  *
3264
3322
  * ```
@@ -3290,10 +3348,8 @@ const checkInterruptible = exports.checkInterruptible = core.checkInterruptible;
3290
3348
  * error or trigger alternative logic. This enables faster timeout handling
3291
3349
  * without waiting for the completion of the long-running task.
3292
3350
  *
3293
- * @see {@link timeout} for a version that interrupts the effect.
3294
- * @see {@link uninterruptible} for creating an uninterruptible effect.
3351
+ * **Example**
3295
3352
  *
3296
- * @example
3297
3353
  * ```ts
3298
3354
  * import { Effect } from "effect"
3299
3355
  *
@@ -3311,7 +3367,7 @@ const checkInterruptible = exports.checkInterruptible = core.checkInterruptible;
3311
3367
  * Effect.timeout("1 second")
3312
3368
  * )
3313
3369
  *
3314
- * // Effect.runPromiseExit(timedEffect).then(console.log)
3370
+ * Effect.runPromiseExit(timedEffect).then(console.log)
3315
3371
  * // Output:
3316
3372
  * // Start heavy processing...
3317
3373
  * // {
@@ -3326,6 +3382,9 @@ const checkInterruptible = exports.checkInterruptible = core.checkInterruptible;
3326
3382
  * // Heavy processing done.
3327
3383
  * ```
3328
3384
  *
3385
+ * @see {@link timeout} for a version that interrupts the effect.
3386
+ * @see {@link uninterruptible} for creating an uninterruptible effect.
3387
+ *
3329
3388
  * @since 2.0.0
3330
3389
  * @category Interruption
3331
3390
  */
@@ -3341,7 +3400,8 @@ const disconnect = exports.disconnect = fiberRuntime.disconnect;
3341
3400
  * The resulting interruption can be observed in the `Exit` type if the effect
3342
3401
  * is run with functions like {@link runPromiseExit}.
3343
3402
  *
3344
- * @example
3403
+ * **Example**
3404
+ *
3345
3405
  * ```ts
3346
3406
  * import { Effect } from "effect"
3347
3407
  *
@@ -3353,7 +3413,7 @@ const disconnect = exports.disconnect = fiberRuntime.disconnect;
3353
3413
  * return "some result"
3354
3414
  * })
3355
3415
  *
3356
- * // Effect.runPromiseExit(program).then(console.log)
3416
+ * Effect.runPromiseExit(program).then(console.log)
3357
3417
  * // Output:
3358
3418
  * // start
3359
3419
  * // {
@@ -3406,9 +3466,9 @@ const interruptibleMask = exports.interruptibleMask = core.interruptibleMask;
3406
3466
  * interrupted. This effect will be executed when the fiber is interrupted,
3407
3467
  * allowing you to perform cleanup or other actions.
3408
3468
  *
3409
- * @example
3469
+ * **Example** (Running a Cleanup Action on Interruption)
3470
+ *
3410
3471
  * ```ts
3411
- * // Title: Running a Cleanup Action on Interruption
3412
3472
  * import { Console, Effect } from "effect"
3413
3473
  *
3414
3474
  * // This handler is executed when the fiber is interrupted
@@ -3416,19 +3476,19 @@ const interruptibleMask = exports.interruptibleMask = core.interruptibleMask;
3416
3476
  *
3417
3477
  * const success = Console.log("Task completed").pipe(Effect.as("some result"), handler)
3418
3478
  *
3419
- * // Effect.runFork(success)
3479
+ * Effect.runFork(success)
3420
3480
  * // Output:
3421
3481
  * // Task completed
3422
3482
  *
3423
3483
  * const failure = Console.log("Task failed").pipe(Effect.andThen(Effect.fail("some error")), handler)
3424
3484
  *
3425
- * // Effect.runFork(failure)
3485
+ * Effect.runFork(failure)
3426
3486
  * // Output:
3427
3487
  * // Task failed
3428
3488
  *
3429
3489
  * const interruption = Console.log("Task interrupted").pipe(Effect.andThen(Effect.interrupt), handler)
3430
3490
  *
3431
- * // Effect.runFork(interruption)
3491
+ * Effect.runFork(interruption)
3432
3492
  * // Output:
3433
3493
  * // Task interrupted
3434
3494
  * // Cleanup completed
@@ -3458,7 +3518,8 @@ const uninterruptibleMask = exports.uninterruptibleMask = core.uninterruptibleMa
3458
3518
  * Transforms a `Predicate` function into an `Effect` returning the input value if the predicate returns `true`
3459
3519
  * or failing with specified error if the predicate fails
3460
3520
  *
3461
- * @example
3521
+ * **Example**
3522
+ *
3462
3523
  * ```ts
3463
3524
  * import { Effect } from "effect"
3464
3525
  *
@@ -3490,15 +3551,15 @@ const liftPredicate = exports.liftPredicate = effect.liftPredicate;
3490
3551
  * result instead. For instance, you can replace the value produced by a
3491
3552
  * computation with a predefined value, ignoring what was calculated before.
3492
3553
  *
3493
- * @example
3554
+ * **Example** (Replacing a Value)
3555
+ *
3494
3556
  * ```ts
3495
- * // Title: Replacing a Value
3496
3557
  * import { pipe, Effect } from "effect"
3497
3558
  *
3498
3559
  * // Replaces the value 5 with the constant "new value"
3499
3560
  * const program = pipe(Effect.succeed(5), Effect.as("new value"))
3500
3561
  *
3501
- * // Effect.runPromise(program).then(console.log)
3562
+ * Effect.runPromise(program).then(console.log)
3502
3563
  * // Output: "new value"
3503
3564
  * ```
3504
3565
  *
@@ -3543,7 +3604,8 @@ const asVoid = exports.asVoid = core.asVoid;
3543
3604
  * error channels. The success value becomes an error, and the error value
3544
3605
  * becomes a success.
3545
3606
  *
3546
- * @example
3607
+ * **Example**
3608
+ *
3547
3609
  * ```ts
3548
3610
  * import { Effect } from "effect"
3549
3611
  *
@@ -3590,13 +3652,9 @@ const flipWith = exports.flipWith = effect.flipWith;
3590
3652
  * effect is not modified. Instead, a new effect is returned with the updated
3591
3653
  * value.
3592
3654
  *
3593
- * @see {@link mapError} for a version that operates on the error channel.
3594
- * @see {@link mapBoth} for a version that operates on both channels.
3595
- * @see {@link flatMap} or {@link andThen} for a version that can return a new effect.
3655
+ * **Example** (Adding a Service Charge)
3596
3656
  *
3597
- * @example
3598
3657
  * ```ts
3599
- * // Title: Adding a Service Charge
3600
3658
  * import { pipe, Effect } from "effect"
3601
3659
  *
3602
3660
  * const addServiceCharge = (amount: number) => amount + 1
@@ -3608,9 +3666,14 @@ const flipWith = exports.flipWith = effect.flipWith;
3608
3666
  * Effect.map(addServiceCharge)
3609
3667
  * )
3610
3668
  *
3611
- * // Effect.runPromise(finalAmount).then(console.log)
3669
+ * Effect.runPromise(finalAmount).then(console.log)
3612
3670
  * // Output: 101
3613
3671
  * ```
3672
+ *
3673
+ * @see {@link mapError} for a version that operates on the error channel.
3674
+ * @see {@link mapBoth} for a version that operates on both channels.
3675
+ * @see {@link flatMap} or {@link andThen} for a version that can return a new effect.
3676
+ *
3614
3677
  * @since 2.0.0
3615
3678
  * @category Mapping
3616
3679
  */
@@ -3634,7 +3697,8 @@ const map = exports.map = core.map;
3634
3697
  * If the input collection is a non-empty array, the return type will match the
3635
3698
  * input collection type.
3636
3699
  *
3637
- * @example
3700
+ * **Example**
3701
+ *
3638
3702
  * ```ts
3639
3703
  * import { Effect } from "effect"
3640
3704
  *
@@ -3647,10 +3711,10 @@ const map = exports.map = core.map;
3647
3711
  * // Apply mapAccum to transform an array of strings
3648
3712
  * const program = Effect.mapAccum(["a", "bb", "ccc"], initialState, transformation)
3649
3713
  *
3650
- * // Effect.runPromise(program).then(([finalState, transformedCollection]) => {
3651
- * // console.log(finalState)
3652
- * // console.log(transformedCollection)
3653
- * // })
3714
+ * Effect.runPromise(program).then(([finalState, transformedCollection]) => {
3715
+ * console.log(finalState)
3716
+ * console.log(transformedCollection)
3717
+ * })
3654
3718
  * // Output:
3655
3719
  * // 6
3656
3720
  * // [ 'A', 'BB', 'CCC' ]
@@ -3670,10 +3734,8 @@ const mapAccum = exports.mapAccum = effect.mapAccum;
3670
3734
  * the error and the success values without altering the overall success or
3671
3735
  * failure status of the effect.
3672
3736
  *
3673
- * @see {@link map} for a version that operates on the success channel.
3674
- * @see {@link mapError} for a version that operates on the error channel.
3737
+ * **Example**
3675
3738
  *
3676
- * @example
3677
3739
  * ```ts
3678
3740
  * import { Effect } from "effect"
3679
3741
  *
@@ -3689,6 +3751,9 @@ const mapAccum = exports.mapAccum = effect.mapAccum;
3689
3751
  * })
3690
3752
  * ```
3691
3753
  *
3754
+ * @see {@link map} for a version that operates on the success channel.
3755
+ * @see {@link mapError} for a version that operates on the error channel.
3756
+ *
3692
3757
  * @since 2.0.0
3693
3758
  * @category Mapping
3694
3759
  */
@@ -3704,11 +3769,8 @@ const mapBoth = exports.mapBoth = core.mapBoth;
3704
3769
  * keeping the original behavior of the effect's success values intact. It only
3705
3770
  * operates on the error channel and leaves the success channel unchanged.
3706
3771
  *
3707
- * @see {@link map} for a version that operates on the success channel.
3708
- * @see {@link mapBoth} for a version that operates on both channels.
3709
- * @see {@link orElseFail} if you want to replace the error with a new one.
3772
+ * **Example**
3710
3773
  *
3711
- * @example
3712
3774
  * ```ts
3713
3775
  * import { Effect } from "effect"
3714
3776
  *
@@ -3724,6 +3786,10 @@ const mapBoth = exports.mapBoth = core.mapBoth;
3724
3786
  * )
3725
3787
  * ```
3726
3788
  *
3789
+ * @see {@link map} for a version that operates on the success channel.
3790
+ * @see {@link mapBoth} for a version that operates on both channels.
3791
+ * @see {@link orElseFail} if you want to replace the error with a new one.
3792
+ *
3727
3793
  * @since 2.0.0
3728
3794
  * @category Mapping
3729
3795
  */
@@ -3753,7 +3819,8 @@ const mapErrorCause = exports.mapErrorCause = effect.mapErrorCause;
3753
3819
  * error type and still capture both successful results and errors as part of
3754
3820
  * the outcome.
3755
3821
  *
3756
- * @example
3822
+ * **Example**
3823
+ *
3757
3824
  * ```ts
3758
3825
  * import { Effect } from "effect"
3759
3826
  *
@@ -3812,11 +3879,9 @@ const negate = exports.negate = effect.negate;
3812
3879
  * etc.) will not be interrupted, and that the resource will always be released
3813
3880
  * when the `Effect` completes execution.
3814
3881
  *
3815
- * @see {@link acquireUseRelease} for a version that automatically handles the scoping of resources.
3882
+ * **Example** (Defining a Simple Resource)
3816
3883
  *
3817
- * @example
3818
3884
  * ```ts
3819
- * // Title: Defining a Simple Resource
3820
3885
  * import { Effect } from "effect"
3821
3886
  *
3822
3887
  * // Define an interface for a resource
@@ -3856,6 +3921,8 @@ const negate = exports.negate = effect.negate;
3856
3921
  * const resource = Effect.acquireRelease(acquire, release)
3857
3922
  * ```
3858
3923
  *
3924
+ * @see {@link acquireUseRelease} for a version that automatically handles the scoping of resources.
3925
+ *
3859
3926
  * @since 2.0.0
3860
3927
  * @category Scoping, Resources & Finalization
3861
3928
  */
@@ -3875,23 +3942,21 @@ const acquireRelease = exports.acquireRelease = fiberRuntime.acquireRelease;
3875
3942
  */
3876
3943
  const acquireReleaseInterruptible = exports.acquireReleaseInterruptible = fiberRuntime.acquireReleaseInterruptible;
3877
3944
  /**
3878
- * Creates a scoped resource and automatically handles the use effect during the
3879
- * scope.
3945
+ * Many real-world operations involve working with resources that must be released when no longer needed, such as:
3880
3946
  *
3881
- * **Details**
3947
+ * - Database connections
3948
+ * - File handles
3949
+ * - Network requests
3950
+ *
3951
+ * This function ensures that a resource is:
3882
3952
  *
3883
- * This function is similar to {@link acquireRelease}, but it introduces an
3884
- * additional `use` effect. This allows you to automatically execute the `use`
3885
- * effect while the resource is acquired, and it also ensures that the `release`
3886
- * effect is performed when the scope is closed.
3953
+ * 1. **Acquired** properly.
3954
+ * 2. **Used** for its intended purpose.
3955
+ * 3. **Released** even if an error occurs.
3887
3956
  *
3888
- * The `acquire` effect is used to obtain the resource, the `use` effect
3889
- * operates while the resource is in use, and the `release` effect cleans up the
3890
- * resource when the scope ends.
3957
+ * **Example** (Automatically Managing Resource Lifetime)
3891
3958
  *
3892
- * @example
3893
3959
  * ```ts
3894
- * // Title: Automatically Managing Resource Lifetime
3895
3960
  * import { Effect, Console } from "effect"
3896
3961
  *
3897
3962
  * // Define an interface for a resource
@@ -3930,7 +3995,7 @@ const acquireReleaseInterruptible = exports.acquireReleaseInterruptible = fiberR
3930
3995
  * // ▼
3931
3996
  * const program = Effect.acquireUseRelease(acquire, use, release)
3932
3997
  *
3933
- * // Effect.runPromise(program)
3998
+ * Effect.runPromise(program)
3934
3999
  * // Output:
3935
4000
  * // Resource acquired
3936
4001
  * // content is lorem ipsum
@@ -3960,11 +4025,9 @@ const acquireUseRelease = exports.acquireUseRelease = core.acquireUseRelease;
3960
4025
  * effect with a finalizer is wrapped in a scope, the finalizer will execute
3961
4026
  * automatically when the scope ends.
3962
4027
  *
3963
- * @see {@link onExit} for attaching a finalizer directly to an effect.
4028
+ * **Example** (Adding a Finalizer on Success)
3964
4029
  *
3965
- * @example
3966
4030
  * ```ts
3967
- * // Title: Adding a Finalizer on Success
3968
4031
  * import { Effect, Console } from "effect"
3969
4032
  *
3970
4033
  * // ┌─── Effect<string, never, Scope>
@@ -3982,15 +4045,15 @@ const acquireUseRelease = exports.acquireUseRelease = core.acquireUseRelease;
3982
4045
  * // ▼
3983
4046
  * const runnable = Effect.scoped(program)
3984
4047
  *
3985
- * // Effect.runPromiseExit(runnable).then(console.log)
4048
+ * Effect.runPromiseExit(runnable).then(console.log)
3986
4049
  * // Output:
3987
4050
  * // Finalizer executed. Exit status: Success
3988
4051
  * // { _id: 'Exit', _tag: 'Success', value: 'some result' }
3989
4052
  * ```
3990
4053
  *
3991
- * @example
4054
+ * **Example** (Adding a Finalizer on Failure)
4055
+ *
3992
4056
  * ```ts
3993
- * // Title: Adding a Finalizer on Failure
3994
4057
  * import { Effect, Console } from "effect"
3995
4058
  *
3996
4059
  * // ┌─── Effect<never, string, Scope>
@@ -4008,7 +4071,7 @@ const acquireUseRelease = exports.acquireUseRelease = core.acquireUseRelease;
4008
4071
  * // ▼
4009
4072
  * const runnable = Effect.scoped(program)
4010
4073
  *
4011
- * // Effect.runPromiseExit(runnable).then(console.log)
4074
+ * Effect.runPromiseExit(runnable).then(console.log)
4012
4075
  * // Output:
4013
4076
  * // Finalizer executed. Exit status: Failure
4014
4077
  * // {
@@ -4018,9 +4081,9 @@ const acquireUseRelease = exports.acquireUseRelease = core.acquireUseRelease;
4018
4081
  * // }
4019
4082
  * ```
4020
4083
  *
4021
- * @example
4084
+ * **Example** (Adding a Finalizer on Interruption)
4085
+ *
4022
4086
  * ```ts
4023
- * // Title: Adding a Finalizer on Interruption
4024
4087
  * import { Effect, Console } from "effect"
4025
4088
  *
4026
4089
  * // ┌─── Effect<never, never, Scope>
@@ -4038,7 +4101,7 @@ const acquireUseRelease = exports.acquireUseRelease = core.acquireUseRelease;
4038
4101
  * // ▼
4039
4102
  * const runnable = Effect.scoped(program)
4040
4103
  *
4041
- * // Effect.runPromiseExit(runnable).then(console.log)
4104
+ * Effect.runPromiseExit(runnable).then(console.log)
4042
4105
  * // Output:
4043
4106
  * // Finalizer executed. Exit status: Failure
4044
4107
  * // {
@@ -4057,6 +4120,8 @@ const acquireUseRelease = exports.acquireUseRelease = core.acquireUseRelease;
4057
4120
  * // }
4058
4121
  * ```
4059
4122
  *
4123
+ * @see {@link onExit} for attaching a finalizer directly to an effect.
4124
+ *
4060
4125
  * @since 2.0.0
4061
4126
  * @category Scoping, Resources & Finalization
4062
4127
  */
@@ -4083,37 +4148,51 @@ const addFinalizer = exports.addFinalizer = fiberRuntime.addFinalizer;
4083
4148
  * For use cases where you need access to the result of an effect, consider
4084
4149
  * using {@link onExit}.
4085
4150
  *
4086
- * @see {@link onExit} for a version that provides access to the result of an
4087
- * effect.
4151
+ * **Example** (Running a Finalizer in All Outcomes)
4088
4152
  *
4089
- * @example
4090
4153
  * ```ts
4091
4154
  * import { Console, Effect } from "effect"
4092
4155
  *
4156
+ * // Define a cleanup effect
4093
4157
  * const handler = Effect.ensuring(Console.log("Cleanup completed"))
4094
4158
  *
4095
- * const success = Console.log("Task completed").pipe(Effect.as("some result"), handler)
4159
+ * // Define a successful effect
4160
+ * const success = Console.log("Task completed").pipe(
4161
+ * Effect.as("some result"),
4162
+ * handler
4163
+ * )
4096
4164
  *
4097
- * // Effect.runFork(success)
4165
+ * Effect.runFork(success)
4098
4166
  * // Output:
4099
4167
  * // Task completed
4100
4168
  * // Cleanup completed
4101
4169
  *
4102
- * const failure = Console.log("Task failed").pipe(Effect.andThen(Effect.fail("some error")), handler)
4170
+ * // Define a failing effect
4171
+ * const failure = Console.log("Task failed").pipe(
4172
+ * Effect.andThen(Effect.fail("some error")),
4173
+ * handler
4174
+ * )
4103
4175
  *
4104
- * // Effect.runFork(failure)
4176
+ * Effect.runFork(failure)
4105
4177
  * // Output:
4106
4178
  * // Task failed
4107
4179
  * // Cleanup completed
4108
4180
  *
4109
- * const interruption = Console.log("Task interrupted").pipe(Effect.andThen(Effect.interrupt), handler)
4181
+ * // Define an interrupted effect
4182
+ * const interruption = Console.log("Task interrupted").pipe(
4183
+ * Effect.andThen(Effect.interrupt),
4184
+ * handler
4185
+ * )
4110
4186
  *
4111
- * // Effect.runFork(interruption)
4187
+ * Effect.runFork(interruption)
4112
4188
  * // Output:
4113
4189
  * // Task interrupted
4114
4190
  * // Cleanup completed
4115
4191
  * ```
4116
4192
  *
4193
+ * @see {@link onExit} for a version that provides access to the result of an
4194
+ * effect.
4195
+ *
4117
4196
  * @since 2.0.0
4118
4197
  * @category Scoping, Resources & Finalization
4119
4198
  */
@@ -4133,37 +4212,63 @@ const ensuring = exports.ensuring = fiberRuntime.ensuring;
4133
4212
  * Importantly, the cleanup effect itself is uninterruptible, ensuring that it
4134
4213
  * completes regardless of external interruptions.
4135
4214
  *
4136
- * @see {@link ensuring} for attaching a cleanup effect that runs on both success and failure.
4137
- * @see {@link onExit} for attaching a cleanup effect that runs on all possible exits.
4215
+ * **Example** (Running Cleanup Only on Failure)
4138
4216
  *
4139
- * @example
4140
4217
  * ```ts
4141
4218
  * import { Console, Effect } from "effect"
4142
4219
  *
4143
4220
  * // This handler logs the failure cause when the effect fails
4144
- * const handler = Effect.onError((cause) => Console.log(`Cleanup completed: ${cause}`))
4221
+ * const handler = Effect.onError((cause) =>
4222
+ * Console.log(`Cleanup completed: ${cause}`)
4223
+ * )
4145
4224
  *
4146
- * const success = Console.log("Task completed").pipe(Effect.as("some result"), handler)
4225
+ * // Define a successful effect
4226
+ * const success = Console.log("Task completed").pipe(
4227
+ * Effect.as("some result"),
4228
+ * handler
4229
+ * )
4147
4230
  *
4148
- * // Effect.runFork(success)
4231
+ * Effect.runFork(success)
4149
4232
  * // Output:
4150
4233
  * // Task completed
4151
4234
  *
4152
- * const failure = Console.log("Task failed").pipe(Effect.andThen(Effect.fail("some error")), handler)
4235
+ * // Define a failing effect
4236
+ * const failure = Console.log("Task failed").pipe(
4237
+ * Effect.andThen(Effect.fail("some error")),
4238
+ * handler
4239
+ * )
4153
4240
  *
4154
- * // Effect.runFork(failure)
4241
+ * Effect.runFork(failure)
4155
4242
  * // Output:
4156
4243
  * // Task failed
4157
4244
  * // Cleanup completed: Error: some error
4158
4245
  *
4159
- * const interruption = Console.log("Task interrupted").pipe(Effect.andThen(Effect.interrupt), handler)
4246
+ * // Define a failing effect
4247
+ * const defect = Console.log("Task failed with defect").pipe(
4248
+ * Effect.andThen(Effect.die("Boom!")),
4249
+ * handler
4250
+ * )
4251
+ *
4252
+ * Effect.runFork(defect)
4253
+ * // Output:
4254
+ * // Task failed with defect
4255
+ * // Cleanup completed: Error: Boom!
4160
4256
  *
4161
- * // Effect.runFork(interruption)
4257
+ * // Define an interrupted effect
4258
+ * const interruption = Console.log("Task interrupted").pipe(
4259
+ * Effect.andThen(Effect.interrupt),
4260
+ * handler
4261
+ * )
4262
+ *
4263
+ * Effect.runFork(interruption)
4162
4264
  * // Output:
4163
4265
  * // Task interrupted
4164
4266
  * // Cleanup completed: All fibers interrupted without errors.
4165
4267
  * ```
4166
4268
  *
4269
+ * @see {@link ensuring} for attaching a cleanup effect that runs on both success and failure.
4270
+ * @see {@link onExit} for attaching a cleanup effect that runs on all possible exits.
4271
+ *
4167
4272
  * @since 2.0.0
4168
4273
  * @category Scoping, Resources & Finalization
4169
4274
  */
@@ -4185,30 +4290,45 @@ const onError = exports.onError = core.onError;
4185
4290
  * The cleanup function is guaranteed to run uninterruptibly, ensuring reliable
4186
4291
  * resource management even in complex or high-concurrency scenarios.
4187
4292
  *
4188
- * @example
4293
+ * **Example** (Running a Cleanup Function with the Effect’s Result)
4294
+ *
4189
4295
  * ```ts
4190
4296
  * import { Console, Effect, Exit } from "effect"
4191
4297
  *
4192
- * // Define a cleanup function that logs the outcome of the effect
4193
- * const handler = Effect.onExit((exit) => Console.log(`Cleanup completed: ${Exit.getOrElse(exit, String)}`))
4298
+ * // Define a cleanup effect that logs the result
4299
+ * const handler = Effect.onExit((exit) =>
4300
+ * Console.log(`Cleanup completed: ${Exit.getOrElse(exit, String)}`)
4301
+ * )
4194
4302
  *
4195
- * const success = Console.log("Task completed").pipe(Effect.as("some result"), handler)
4303
+ * // Define a successful effect
4304
+ * const success = Console.log("Task completed").pipe(
4305
+ * Effect.as("some result"),
4306
+ * handler
4307
+ * )
4196
4308
  *
4197
- * // Effect.runFork(success)
4309
+ * Effect.runFork(success)
4198
4310
  * // Output:
4199
4311
  * // Task completed
4200
4312
  * // Cleanup completed: some result
4201
4313
  *
4202
- * const failure = Console.log("Task failed").pipe(Effect.andThen(Effect.fail("some error")), handler)
4314
+ * // Define a failing effect
4315
+ * const failure = Console.log("Task failed").pipe(
4316
+ * Effect.andThen(Effect.fail("some error")),
4317
+ * handler
4318
+ * )
4203
4319
  *
4204
- * // Effect.runFork(failure)
4320
+ * Effect.runFork(failure)
4205
4321
  * // Output:
4206
4322
  * // Task failed
4207
4323
  * // Cleanup completed: Error: some error
4208
4324
  *
4209
- * const interruption = Console.log("Task interrupted").pipe(Effect.andThen(Effect.interrupt), handler)
4325
+ * // Define an interrupted effect
4326
+ * const interruption = Console.log("Task interrupted").pipe(
4327
+ * Effect.andThen(Effect.interrupt),
4328
+ * handler
4329
+ * )
4210
4330
  *
4211
- * // Effect.runFork(interruption)
4331
+ * Effect.runFork(interruption)
4212
4332
  * // Output:
4213
4333
  * // Task interrupted
4214
4334
  * // Cleanup completed: All fibers interrupted without errors.
@@ -4238,9 +4358,8 @@ const onExit = exports.onExit = core.onExit;
4238
4358
  * these tasks do not depend on the order of execution or introduce race
4239
4359
  * conditions.
4240
4360
  *
4241
- * @see {@link sequentialFinalizers} for a version that ensures finalizers are run sequentially.
4361
+ * **Example**
4242
4362
  *
4243
- * @example
4244
4363
  * ```ts
4245
4364
  * import { Console, Effect } from "effect"
4246
4365
  *
@@ -4257,13 +4376,15 @@ const onExit = exports.onExit = core.onExit;
4257
4376
  *
4258
4377
  * const runnable = Effect.scoped(modified)
4259
4378
  *
4260
- * // Effect.runFork(runnable)
4379
+ * Effect.runFork(runnable)
4261
4380
  * // Output:
4262
4381
  * // Finalizer 2 executed
4263
4382
  * // Finalizer 3 executed
4264
4383
  * // Finalizer 1 executed
4265
4384
  * ```
4266
4385
  *
4386
+ * @see {@link sequentialFinalizers} for a version that ensures finalizers are run sequentially.
4387
+ *
4267
4388
  * @since 2.0.0
4268
4389
  * @category Scoping, Resources & Finalization
4269
4390
  */
@@ -4350,9 +4471,8 @@ const scoped = exports.scoped = fiberRuntime.scopedEffect;
4350
4471
  * resources are cleaned up as soon as the `use` effect completes, regardless of
4351
4472
  * how the `use` effect ends (success, failure, or interruption).
4352
4473
  *
4353
- * @see {@link scopedWith} Manage scoped operations with a temporary scope.
4474
+ * **Example**
4354
4475
  *
4355
- * @example
4356
4476
  * ```ts
4357
4477
  * import { Console, Effect } from "effect"
4358
4478
  *
@@ -4364,13 +4484,15 @@ const scoped = exports.scoped = fiberRuntime.scopedEffect;
4364
4484
  *
4365
4485
  * const program = acquire.pipe(Effect.using(use))
4366
4486
  *
4367
- * // Effect.runFork(program)
4487
+ * Effect.runFork(program)
4368
4488
  * // Output:
4369
4489
  * // Acquiring resource
4370
4490
  * // Using resource: 1
4371
4491
  * // Releasing resource
4372
4492
  * ```
4373
4493
  *
4494
+ * @see {@link scopedWith} Manage scoped operations with a temporary scope.
4495
+ *
4374
4496
  * @since 2.0.0
4375
4497
  * @category Scoping, Resources & Finalization
4376
4498
  */
@@ -4385,7 +4507,8 @@ const using = exports.using = fiberRuntime.using;
4385
4507
  * workflows where you need early access to the result while retaining control
4386
4508
  * over the resource cleanup process.
4387
4509
  *
4388
- * @example
4510
+ * **Example**
4511
+ *
4389
4512
  * ```ts
4390
4513
  * import { Console, Effect } from "effect"
4391
4514
  *
@@ -4503,9 +4626,8 @@ const fiberIdWith = exports.fiberIdWith = core.fiberIdWith;
4503
4626
  * higher-level functions like {@link raceWith}, {@link zip}, or others that can
4504
4627
  * manage concurrency for you.
4505
4628
  *
4506
- * @see {@link forkWithErrorHandler} for a version that allows you to handle errors.
4629
+ * **Example**
4507
4630
  *
4508
- * @example
4509
4631
  * ```ts
4510
4632
  * import { Effect } from "effect"
4511
4633
  *
@@ -4519,6 +4641,8 @@ const fiberIdWith = exports.fiberIdWith = core.fiberIdWith;
4519
4641
  * const fib10Fiber = Effect.fork(fib(10))
4520
4642
  * ```
4521
4643
  *
4644
+ * @see {@link forkWithErrorHandler} for a version that allows you to handle errors.
4645
+ *
4522
4646
  * @since 2.0.0
4523
4647
  * @category Supervision & Fibers
4524
4648
  */
@@ -4535,9 +4659,9 @@ const fork = exports.fork = fiberRuntime.fork;
4535
4659
  * useful for tasks that need to run in the background independently, such as
4536
4660
  * periodic logging, monitoring, or background data processing.
4537
4661
  *
4538
- * @example
4662
+ * **Example** (Creating a Daemon Fibe)
4663
+ *
4539
4664
  * ```ts
4540
- * // Title: Creating a Daemon Fibe
4541
4665
  * import { Effect, Console, Schedule } from "effect"
4542
4666
  *
4543
4667
  * // Daemon fiber that logs a message repeatedly every second
@@ -4554,7 +4678,7 @@ const fork = exports.fork = fiberRuntime.fork;
4554
4678
  * console.log("parent: finished!")
4555
4679
  * })
4556
4680
  *
4557
- * // Effect.runFork(parent)
4681
+ * Effect.runFork(parent)
4558
4682
  * // Output:
4559
4683
  * // parent: started!
4560
4684
  * // daemon: still running!
@@ -4593,15 +4717,13 @@ const forkAll = exports.forkAll = circular.forkAll;
4593
4717
  *
4594
4718
  * The fiber will be interrupted when the scope is closed.
4595
4719
  *
4596
- * @example
4597
- * ```ts
4598
- * // Title: Forking a Fiber in a Specific Scope
4599
- * //
4600
- * // In this example, the child fiber is forked into the outerScope,
4601
- * // allowing it to outlive the inner scope but still be terminated
4602
- * // when the outerScope is closed.
4603
- * //
4720
+ * **Example** (Forking a Fiber in a Specific Scope)
4721
+ *
4722
+ * In this example, the child fiber is forked into the outerScope,
4723
+ * allowing it to outlive the inner scope but still be terminated
4724
+ * when the outerScope is closed.
4604
4725
  *
4726
+ * ```ts
4605
4727
  * import { Console, Effect, Schedule } from "effect"
4606
4728
  *
4607
4729
  * // Child fiber that logs a message repeatedly every second
@@ -4635,7 +4757,7 @@ const forkAll = exports.forkAll = circular.forkAll;
4635
4757
  * })
4636
4758
  * )
4637
4759
  *
4638
- * // Effect.runFork(program)
4760
+ * Effect.runFork(program)
4639
4761
  * // Output:
4640
4762
  * // child: still running!
4641
4763
  * // child: still running!
@@ -4671,14 +4793,12 @@ const forkIn = exports.forkIn = circular.forkIn;
4671
4793
  * terminates. With `forkScoped`, the child fiber will keep running until the
4672
4794
  * local scope ends, regardless of the state of the parent fiber.
4673
4795
  *
4674
- * @example
4675
- * ```ts
4676
- * // Title: Forking a Fiber in a Local Scope
4677
- * //
4678
- * // In this example, the child fiber continues to run beyond the lifetime of the parent fiber.
4679
- * // The child fiber is tied to the local scope and will be terminated only when the scope ends.
4680
- * //
4796
+ * **Example** (Forking a Fiber in a Local Scope)
4797
+ *
4798
+ * In this example, the child fiber continues to run beyond the lifetime of the parent fiber.
4799
+ * The child fiber is tied to the local scope and will be terminated only when the scope ends.
4681
4800
  *
4801
+ * ```ts
4682
4802
  * import { Effect, Console, Schedule } from "effect"
4683
4803
  *
4684
4804
  * // Child fiber that logs a message repeatedly every second
@@ -4708,7 +4828,7 @@ const forkIn = exports.forkIn = circular.forkIn;
4708
4828
  * })
4709
4829
  * )
4710
4830
  *
4711
- * // Effect.runFork(program)
4831
+ * Effect.runFork(program)
4712
4832
  * // Output:
4713
4833
  * // Local scope started!
4714
4834
  * // parent: started!
@@ -4762,9 +4882,9 @@ const fromFiberEffect = exports.fromFiberEffect = circular.fromFiberEffect;
4762
4882
  * This enables you to capture detailed information about these child fibers,
4763
4883
  * such as their status, through the supervisor.
4764
4884
  *
4765
- * @example
4885
+ * **Example** (Monitoring Fiber Count)
4886
+ *
4766
4887
  * ```ts
4767
- * // Title: Monitoring Fiber Count
4768
4888
  * import { Effect, Supervisor, Schedule, Fiber, FiberStatus } from "effect"
4769
4889
  *
4770
4890
  * // Main program that monitors fibers while calculating a Fibonacci number
@@ -4832,7 +4952,7 @@ const fromFiberEffect = exports.fromFiberEffect = circular.fromFiberEffect;
4832
4952
  * return v1 + v2 // Combine the results
4833
4953
  * })
4834
4954
  *
4835
- * // Effect.runPromise(program)
4955
+ * Effect.runPromise(program)
4836
4956
  * // Output:
4837
4957
  * // number of fibers: 0
4838
4958
  * // number of fibers: 2
@@ -4902,7 +5022,8 @@ const withMaxOpsBeforeYield = exports.withMaxOpsBeforeYield = core.withMaxOpsBef
4902
5022
  /**
4903
5023
  * Retrieves the `Clock` service from the context.
4904
5024
  *
4905
- * @example
5025
+ * **Example**
5026
+ *
4906
5027
  * ```ts
4907
5028
  * import { Effect } from "effect"
4908
5029
  *
@@ -4912,7 +5033,7 @@ const withMaxOpsBeforeYield = exports.withMaxOpsBeforeYield = core.withMaxOpsBef
4912
5033
  * console.log(`Current time in milliseconds: ${currentTime}`)
4913
5034
  * })
4914
5035
  *
4915
- * // Effect.runFork(program)
5036
+ * Effect.runFork(program)
4916
5037
  * // Example Output:
4917
5038
  * // Current time in milliseconds: 1735484796134
4918
5039
  * ```
@@ -4925,7 +5046,8 @@ const clock = exports.clock = effect.clock;
4925
5046
  * Retrieves the `Clock` service from the context and provides it to the
4926
5047
  * specified effectful function.
4927
5048
  *
4928
- * @example
5049
+ * **Example**
5050
+ *
4929
5051
  * ```ts
4930
5052
  * import { Console, Effect } from "effect"
4931
5053
  *
@@ -4936,7 +5058,7 @@ const clock = exports.clock = effect.clock;
4936
5058
  * )
4937
5059
  * )
4938
5060
  *
4939
- * // Effect.runFork(program)
5061
+ * Effect.runFork(program)
4940
5062
  * // Example Output:
4941
5063
  * // Current time is: 1735484929744
4942
5064
  * ```
@@ -5004,7 +5126,8 @@ const withConsole = exports.withConsole = console_.withConsole;
5004
5126
  * Internally, this function does not block the thread; instead, it uses an
5005
5127
  * efficient, non-blocking mechanism to introduce the delay.
5006
5128
  *
5007
- * @example
5129
+ * **Example**
5130
+ *
5008
5131
  * ```ts
5009
5132
  * import { Console, Effect } from "effect"
5010
5133
  *
@@ -5017,7 +5140,7 @@ const withConsole = exports.withConsole = console_.withConsole;
5017
5140
  * )
5018
5141
  * )
5019
5142
  *
5020
- * // Effect.runFork(program)
5143
+ * Effect.runFork(program)
5021
5144
  * // Output:
5022
5145
  * // start
5023
5146
  * // Task executed
@@ -5041,7 +5164,8 @@ const delay = exports.delay = effect.delay;
5041
5164
  * `Duration` module, such as a string (`"2 seconds"`) or numeric value
5042
5165
  * representing milliseconds.
5043
5166
  *
5044
- * @example
5167
+ * **Example**
5168
+ *
5045
5169
  * ```ts
5046
5170
  * import { Effect } from "effect"
5047
5171
  *
@@ -5051,7 +5175,7 @@ const delay = exports.delay = effect.delay;
5051
5175
  * console.log("Task completed!")
5052
5176
  * })
5053
5177
  *
5054
- * // Effect.runFork(program)
5178
+ * Effect.runFork(program)
5055
5179
  * // Output:
5056
5180
  * // Starting task...
5057
5181
  * // Task completed!
@@ -5077,7 +5201,8 @@ const sleep = exports.sleep = effect.sleep;
5077
5201
  * unchanged, and the timing information is provided alongside the result in a
5078
5202
  * tuple.
5079
5203
  *
5080
- * @example
5204
+ * **Example**
5205
+ *
5081
5206
  * ```ts
5082
5207
  * import { Duration, Effect } from "effect"
5083
5208
  *
@@ -5093,7 +5218,7 @@ const sleep = exports.sleep = effect.sleep;
5093
5218
  * console.log(`Task completed in ${Duration.toMillis(duration)} ms with result: ${result}`)
5094
5219
  * })
5095
5220
  *
5096
- * // Effect.runFork(program)
5221
+ * Effect.runFork(program)
5097
5222
  * // Output: Task completed in 2003.749125 ms with result: some result
5098
5223
  * ```
5099
5224
  *
@@ -5133,12 +5258,8 @@ const timedWith = exports.timedWith = effect.timedWith;
5133
5258
  * specified duration.
5134
5259
  * - Fail with a `TimeoutException` if the time limit is exceeded.
5135
5260
  *
5136
- * @see {@link timeoutFail} for a version that raises a custom error.
5137
- * @see {@link timeoutFailCause} for a version that raises a custom defect.
5138
- * @see {@link timeoutTo} for a version that allows specifying both success and
5139
- * timeout handlers.
5140
- *
5141
- * @example
5261
+ * **Example**
5262
+ *
5142
5263
  * ```ts
5143
5264
  * import { Effect } from "effect"
5144
5265
  *
@@ -5153,7 +5274,7 @@ const timedWith = exports.timedWith = effect.timedWith;
5153
5274
  * // than the specified timeout duration
5154
5275
  * const timedEffect = task.pipe(Effect.timeout("1 second"))
5155
5276
  *
5156
- * // Effect.runPromiseExit(timedEffect).then(console.log)
5277
+ * Effect.runPromiseExit(timedEffect).then(console.log)
5157
5278
  * // Output:
5158
5279
  * // Start processing...
5159
5280
  * // {
@@ -5167,6 +5288,11 @@ const timedWith = exports.timedWith = effect.timedWith;
5167
5288
  * // }
5168
5289
  * ```
5169
5290
  *
5291
+ * @see {@link timeoutFail} for a version that raises a custom error.
5292
+ * @see {@link timeoutFailCause} for a version that raises a custom defect.
5293
+ * @see {@link timeoutTo} for a version that allows specifying both success and
5294
+ * timeout handlers.
5295
+ *
5170
5296
  * @since 2.0.0
5171
5297
  * @category Delays & Timeouts
5172
5298
  */
@@ -5190,13 +5316,8 @@ const timeout = exports.timeout = circular.timeout;
5190
5316
  * to fail, making it easier to manage situations where you expect tasks might
5191
5317
  * take too long but want to continue executing other tasks.
5192
5318
  *
5193
- * @see {@link timeout} for a version that raises a `TimeoutException`.
5194
- * @see {@link timeoutFail} for a version that raises a custom error.
5195
- * @see {@link timeoutFailCause} for a version that raises a custom defect.
5196
- * @see {@link timeoutTo} for a version that allows specifying both success and
5197
- * timeout handlers.
5319
+ * **Example**
5198
5320
  *
5199
- * @example
5200
5321
  * ```ts
5201
5322
  * import { Effect } from "effect"
5202
5323
  *
@@ -5212,7 +5333,7 @@ const timeout = exports.timeout = circular.timeout;
5212
5333
  * task.pipe(Effect.timeoutOption("1 second"))
5213
5334
  * ])
5214
5335
  *
5215
- * // Effect.runPromise(timedOutEffect).then(console.log)
5336
+ * Effect.runPromise(timedOutEffect).then(console.log)
5216
5337
  * // Output:
5217
5338
  * // Start processing...
5218
5339
  * // Processing complete.
@@ -5223,6 +5344,12 @@ const timeout = exports.timeout = circular.timeout;
5223
5344
  * // ]
5224
5345
  * ```
5225
5346
  *
5347
+ * @see {@link timeout} for a version that raises a `TimeoutException`.
5348
+ * @see {@link timeoutFail} for a version that raises a custom error.
5349
+ * @see {@link timeoutFailCause} for a version that raises a custom defect.
5350
+ * @see {@link timeoutTo} for a version that allows specifying both success and
5351
+ * timeout handlers.
5352
+ *
5226
5353
  * @since 3.1.0
5227
5354
  * @category Delays & Timeouts
5228
5355
  */
@@ -5247,12 +5374,8 @@ const timeoutOption = exports.timeoutOption = circular.timeoutOption;
5247
5374
  * normally. Otherwise, the `onTimeout` function is triggered, and its output is
5248
5375
  * used as the error for the effect.
5249
5376
  *
5250
- * @see {@link timeout} for a version that raises a `TimeoutException`.
5251
- * @see {@link timeoutFailCause} for a version that raises a custom defect.
5252
- * @see {@link timeoutTo} for a version that allows specifying both success and
5253
- * timeout handlers.
5377
+ * **Example**
5254
5378
  *
5255
- * @example
5256
5379
  * ```ts
5257
5380
  * import { Effect } from "effect"
5258
5381
  *
@@ -5274,7 +5397,7 @@ const timeoutOption = exports.timeoutOption = circular.timeoutOption;
5274
5397
  * })
5275
5398
  * )
5276
5399
  *
5277
- * // Effect.runPromiseExit(program).then(console.log)
5400
+ * Effect.runPromiseExit(program).then(console.log)
5278
5401
  * // Output:
5279
5402
  * // Start processing...
5280
5403
  * // {
@@ -5288,6 +5411,11 @@ const timeoutOption = exports.timeoutOption = circular.timeoutOption;
5288
5411
  * // }
5289
5412
  * ```
5290
5413
  *
5414
+ * @see {@link timeout} for a version that raises a `TimeoutException`.
5415
+ * @see {@link timeoutFailCause} for a version that raises a custom defect.
5416
+ * @see {@link timeoutTo} for a version that allows specifying both success and
5417
+ * timeout handlers.
5418
+ *
5291
5419
  * @since 2.0.0
5292
5420
  * @category Delays & Timeouts
5293
5421
  */
@@ -5314,12 +5442,8 @@ const timeoutFail = exports.timeoutFail = circular.timeoutFail;
5314
5442
  * failures in your application and wish to include meaningful information in
5315
5443
  * the defect.
5316
5444
  *
5317
- * @see {@link timeout} for a version that raises a `TimeoutException`.
5318
- * @see {@link timeoutFail} for a version that raises a custom error.
5319
- * @see {@link timeoutTo} for a version that allows specifying both success and
5320
- * timeout handlers.
5445
+ * **Example**
5321
5446
  *
5322
- * @example
5323
5447
  * ```ts
5324
5448
  * import { Effect, Cause } from "effect"
5325
5449
  *
@@ -5337,7 +5461,7 @@ const timeoutFail = exports.timeoutFail = circular.timeoutFail;
5337
5461
  * })
5338
5462
  * )
5339
5463
  *
5340
- * // Effect.runPromiseExit(program).then(console.log)
5464
+ * Effect.runPromiseExit(program).then(console.log)
5341
5465
  * // Output:
5342
5466
  * // Start processing...
5343
5467
  * // {
@@ -5347,6 +5471,11 @@ const timeoutFail = exports.timeoutFail = circular.timeoutFail;
5347
5471
  * // }
5348
5472
  * ```
5349
5473
  *
5474
+ * @see {@link timeout} for a version that raises a `TimeoutException`.
5475
+ * @see {@link timeoutFail} for a version that raises a custom error.
5476
+ * @see {@link timeoutTo} for a version that allows specifying both success and
5477
+ * timeout handlers.
5478
+ *
5350
5479
  * @since 2.0.0
5351
5480
  * @category Delays & Timeouts
5352
5481
  */
@@ -5372,11 +5501,8 @@ const timeoutFailCause = exports.timeoutFailCause = circular.timeoutFailCause;
5372
5501
  * and successes into a specific data structure, like an `Either` type, to
5373
5502
  * represent these outcomes in a meaningful way.
5374
5503
  *
5375
- * @see {@link timeout} for a version that raises a `TimeoutException`.
5376
- * @see {@link timeoutFail} for a version that raises a custom error.
5377
- * @see {@link timeoutFailCause} for a version that raises a custom defect.
5504
+ * **Example**
5378
5505
  *
5379
- * @example
5380
5506
  * ```ts
5381
5507
  * import { Effect, Either } from "effect"
5382
5508
  *
@@ -5397,7 +5523,7 @@ const timeoutFailCause = exports.timeoutFailCause = circular.timeoutFailCause;
5397
5523
  * })
5398
5524
  * )
5399
5525
  *
5400
- * // Effect.runPromise(program).then(console.log)
5526
+ * Effect.runPromise(program).then(console.log)
5401
5527
  * // Output:
5402
5528
  * // Start processing...
5403
5529
  * // {
@@ -5407,6 +5533,10 @@ const timeoutFailCause = exports.timeoutFailCause = circular.timeoutFailCause;
5407
5533
  * // }
5408
5534
  * ```
5409
5535
  *
5536
+ * @see {@link timeout} for a version that raises a `TimeoutException`.
5537
+ * @see {@link timeoutFail} for a version that raises a custom error.
5538
+ * @see {@link timeoutFailCause} for a version that raises a custom defect.
5539
+ *
5410
5540
  * @since 2.0.0
5411
5541
  * @category Delays & Timeouts
5412
5542
  */
@@ -5439,7 +5569,8 @@ const configProviderWith = exports.configProviderWith = defaultServices.configPr
5439
5569
  * This is particularly useful when you need to use a different set of
5440
5570
  * configuration values or sources for specific parts of your application.
5441
5571
  *
5442
- * @example
5572
+ * **Example**
5573
+ *
5443
5574
  * ```ts
5444
5575
  * import { Config, ConfigProvider, Effect } from "effect"
5445
5576
  *
@@ -5454,7 +5585,7 @@ const configProviderWith = exports.configProviderWith = defaultServices.configPr
5454
5585
  * })
5455
5586
  * )
5456
5587
  *
5457
- * // Effect.runPromise(program)
5588
+ * Effect.runPromise(program)
5458
5589
  * // Output:
5459
5590
  * // Config value: custom-value
5460
5591
  * ```
@@ -5527,7 +5658,8 @@ const contextWithEffect = exports.contextWithEffect = core.contextWithEffect;
5527
5658
  * This function allows you to transform the context required by an effect,
5528
5659
  * providing part of the context and leaving the rest to be fulfilled later.
5529
5660
  *
5530
- * @example
5661
+ * **Example**
5662
+ *
5531
5663
  * ```ts
5532
5664
  * import { Context, Effect } from "effect"
5533
5665
  *
@@ -5579,9 +5711,8 @@ const mapInputContext = exports.mapInputContext = core.mapInputContext;
5579
5711
  * environment for effects. For example, layers can be used to configure
5580
5712
  * databases, logging services, or any other required dependencies.
5581
5713
  *
5582
- * @see {@link provideService} for providing a service to an effect.
5714
+ * **Example**
5583
5715
  *
5584
- * @example
5585
5716
  * ```ts
5586
5717
  * import { Context, Effect, Layer } from "effect"
5587
5718
  *
@@ -5610,12 +5741,14 @@ const mapInputContext = exports.mapInputContext = core.mapInputContext;
5610
5741
  * // ▼
5611
5742
  * const runnable = Effect.provide(program, DatabaseLive)
5612
5743
  *
5613
- * // Effect.runPromise(runnable).then(console.log)
5744
+ * Effect.runPromise(runnable).then(console.log)
5614
5745
  * // Output:
5615
5746
  * // timestamp=... level=INFO fiber=#0 message="Executing query: SELECT * FROM users"
5616
5747
  * // []
5617
5748
  * ```
5618
5749
  *
5750
+ * @see {@link provideService} for providing a service to an effect.
5751
+ *
5619
5752
  * @since 2.0.0
5620
5753
  * @category Context
5621
5754
  */
@@ -5636,9 +5769,8 @@ const provide = exports.provide = layer.effect_provide;
5636
5769
  * provided, all parts of the effect that rely on the service will automatically
5637
5770
  * use the implementation you supplied.
5638
5771
  *
5639
- * @see {@link provide} for providing multiple layers to an effect.
5772
+ * **Example**
5640
5773
  *
5641
- * @example
5642
5774
  * ```ts
5643
5775
  * import { Effect, Context } from "effect"
5644
5776
  *
@@ -5664,11 +5796,13 @@ const provide = exports.provide = layer.effect_provide;
5664
5796
  * })
5665
5797
  *
5666
5798
  * // Run successfully
5667
- * // Effect.runPromise(runnable)
5799
+ * Effect.runPromise(runnable)
5668
5800
  * // Example Output:
5669
5801
  * // random number: 0.8241872233134417
5670
5802
  * ```
5671
5803
  *
5804
+ * @see {@link provide} for providing multiple layers to an effect.
5805
+ *
5672
5806
  * @since 2.0.0
5673
5807
  * @category Context
5674
5808
  */
@@ -5795,11 +5929,8 @@ const updateService = exports.updateService = effect.updateService;
5795
5929
  * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
5796
5930
  * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
5797
5931
  *
5798
- * @see {@link bind}
5799
- * @see {@link bindTo}
5800
- * @see {@link let_ let}
5932
+ * **Example**
5801
5933
  *
5802
- * @example
5803
5934
  * ```ts
5804
5935
  * import * as assert from "node:assert"
5805
5936
  * import { Effect, pipe } from "effect"
@@ -5813,6 +5944,10 @@ const updateService = exports.updateService = effect.updateService;
5813
5944
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
5814
5945
  * ```
5815
5946
  *
5947
+ * @see {@link bind}
5948
+ * @see {@link bindTo}
5949
+ * @see {@link let_ let}
5950
+ *
5816
5951
  * @category Do notation
5817
5952
  * @since 2.0.0
5818
5953
  */
@@ -5827,11 +5962,8 @@ const Do = exports.Do = effect.Do;
5827
5962
  * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
5828
5963
  * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
5829
5964
  *
5830
- * @see {@link Do}
5831
- * @see {@link bindTo}
5832
- * @see {@link let_ let}
5965
+ * **Example**
5833
5966
  *
5834
- * @example
5835
5967
  * ```ts
5836
5968
  * import * as assert from "node:assert"
5837
5969
  * import { Effect, pipe } from "effect"
@@ -5845,6 +5977,10 @@ const Do = exports.Do = effect.Do;
5845
5977
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
5846
5978
  * ```
5847
5979
  *
5980
+ * @see {@link Do}
5981
+ * @see {@link bindTo}
5982
+ * @see {@link let_ let}
5983
+ *
5848
5984
  * @category Do notation
5849
5985
  * @since 2.0.0
5850
5986
  */
@@ -5854,7 +5990,8 @@ const bind = exports.bind = effect.bind;
5854
5990
  * when you want to concurrently run multiple effects and then combine their
5855
5991
  * results in a Do notation pipeline.
5856
5992
  *
5857
- * @example
5993
+ * **Example**
5994
+ *
5858
5995
  * ```ts
5859
5996
  * import * as assert from "node:assert"
5860
5997
  * import { Effect, Either, pipe } from "effect"
@@ -5884,11 +6021,8 @@ const bindAll = exports.bindAll = circular.bindAll;
5884
6021
  * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
5885
6022
  * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
5886
6023
  *
5887
- * @see {@link Do}
5888
- * @see {@link bind}
5889
- * @see {@link let_ let}
6024
+ * **Example**
5890
6025
  *
5891
- * @example
5892
6026
  * ```ts
5893
6027
  * import * as assert from "node:assert"
5894
6028
  * import { Effect, pipe } from "effect"
@@ -5902,6 +6036,10 @@ const bindAll = exports.bindAll = circular.bindAll;
5902
6036
  * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
5903
6037
  * ```
5904
6038
  *
6039
+ * @see {@link Do}
6040
+ * @see {@link bind}
6041
+ * @see {@link let_ let}
6042
+ *
5905
6043
  * @category Do notation
5906
6044
  * @since 2.0.0
5907
6045
  */
@@ -5922,17 +6060,14 @@ const let_ = exports.let = effect.let_;
5922
6060
  * directly. However, unrecoverable errors, also referred to as defects, are
5923
6061
  * not captured and will still result in failure.
5924
6062
  *
5925
- * @see {@link either} for a version that uses `Either` instead.
5926
- * @see {@link exit} for a version that encapsulates both recoverable errors and defects in an `Exit`.
6063
+ * **Example** (Using Effect.option to Handle Errors)
5927
6064
  *
5928
- * @example
5929
6065
  * ```ts
5930
- * // Title: Using Effect.option to Handle Errors
5931
6066
  * import { Effect } from "effect"
5932
6067
  *
5933
6068
  * const maybe1 = Effect.option(Effect.succeed(1))
5934
6069
  *
5935
- * // Effect.runPromiseExit(maybe1).then(console.log)
6070
+ * Effect.runPromiseExit(maybe1).then(console.log)
5936
6071
  * // Output:
5937
6072
  * // {
5938
6073
  * // _id: 'Exit',
@@ -5942,7 +6077,7 @@ const let_ = exports.let = effect.let_;
5942
6077
  *
5943
6078
  * const maybe2 = Effect.option(Effect.fail("Uh oh!"))
5944
6079
  *
5945
- * // Effect.runPromiseExit(maybe2).then(console.log)
6080
+ * Effect.runPromiseExit(maybe2).then(console.log)
5946
6081
  * // Output:
5947
6082
  * // {
5948
6083
  * // _id: 'Exit',
@@ -5952,7 +6087,7 @@ const let_ = exports.let = effect.let_;
5952
6087
  *
5953
6088
  * const maybe3 = Effect.option(Effect.die("Boom!"))
5954
6089
  *
5955
- * // Effect.runPromiseExit(maybe3).then(console.log)
6090
+ * Effect.runPromiseExit(maybe3).then(console.log)
5956
6091
  * // Output:
5957
6092
  * // {
5958
6093
  * // _id: 'Exit',
@@ -5961,6 +6096,9 @@ const let_ = exports.let = effect.let_;
5961
6096
  * // }
5962
6097
  * ```
5963
6098
  *
6099
+ * @see {@link either} for a version that uses `Either` instead.
6100
+ * @see {@link exit} for a version that encapsulates both recoverable errors and defects in an `Exit`.
6101
+ *
5964
6102
  * @since 2.0.0
5965
6103
  * @category Outcome Encapsulation
5966
6104
  */
@@ -5988,10 +6126,8 @@ const option = exports.option = effect.option;
5988
6126
  * The resulting effect cannot fail directly because all recoverable failures
5989
6127
  * are represented inside the `Either` type.
5990
6128
  *
5991
- * @see {@link option} for a version that uses `Option` instead.
5992
- * @see {@link exit} for a version that encapsulates both recoverable errors and defects in an `Exit`.
6129
+ * **Example**
5993
6130
  *
5994
- * @example
5995
6131
  * ```ts
5996
6132
  * import { Effect, Either, Random } from "effect"
5997
6133
  *
@@ -6030,6 +6166,9 @@ const option = exports.option = effect.option;
6030
6166
  * })
6031
6167
  * ```
6032
6168
  *
6169
+ * @see {@link option} for a version that uses `Option` instead.
6170
+ * @see {@link exit} for a version that encapsulates both recoverable errors and defects in an `Exit`.
6171
+ *
6033
6172
  * @since 2.0.0
6034
6173
  * @category Outcome Encapsulation
6035
6174
  */
@@ -6053,10 +6192,8 @@ const either = exports.either = core.either;
6053
6192
  * error type is `never`). It is particularly useful for workflows where all
6054
6193
  * outcomes, including unexpected defects, must be managed and analyzed.
6055
6194
  *
6056
- * @see {@link option} for a version that uses `Option` instead.
6057
- * @see {@link either} for a version that uses `Either` instead.
6195
+ * **Example**
6058
6196
  *
6059
- * @example
6060
6197
  * ```ts
6061
6198
  * import { Effect, Cause, Console, Exit } from "effect"
6062
6199
  *
@@ -6081,7 +6218,7 @@ const either = exports.either = core.either;
6081
6218
  * })
6082
6219
  *
6083
6220
  * // We get an Exit.Success because we caught all failures
6084
- * // Effect.runPromiseExit(program).then(console.log)
6221
+ * Effect.runPromiseExit(program).then(console.log)
6085
6222
  * // Output:
6086
6223
  * // RuntimeException defect caught: Boom!
6087
6224
  * // {
@@ -6091,6 +6228,9 @@ const either = exports.either = core.either;
6091
6228
  * // }
6092
6229
  * ```
6093
6230
  *
6231
+ * @see {@link option} for a version that uses `Option` instead.
6232
+ * @see {@link either} for a version that uses `Either` instead.
6233
+ *
6094
6234
  * @since 2.0.0
6095
6235
  * @category Outcome Encapsulation
6096
6236
  */
@@ -6105,7 +6245,8 @@ const exit = exports.exit = core.exit;
6105
6245
  * completed with the success value. If the effect fails, the `Deferred` is completed with the
6106
6246
  * failure. Additionally, if the effect is interrupted, the `Deferred` will also be interrupted.
6107
6247
  *
6108
- * @example
6248
+ * **Example**
6249
+ *
6109
6250
  * ```ts
6110
6251
  * import { Deferred, Effect } from "effect"
6111
6252
  *
@@ -6126,7 +6267,7 @@ const exit = exports.exit = core.exit;
6126
6267
  * return isCompleted
6127
6268
  * })
6128
6269
  *
6129
- * // Effect.runPromise(program).then(console.log)
6270
+ * Effect.runPromise(program).then(console.log)
6130
6271
  * // Output:
6131
6272
  * // 42
6132
6273
  * // true
@@ -6204,7 +6345,8 @@ const filterOrElse = exports.filterOrElse = effect.filterOrElse;
6204
6345
  * guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates).
6205
6346
  * Let's explore this concept through an example:
6206
6347
  *
6207
- * @example
6348
+ * **Example**
6349
+ *
6208
6350
  * ```ts
6209
6351
  * import { Effect, pipe } from "effect"
6210
6352
  *
@@ -6243,7 +6385,8 @@ const filterOrFail = exports.filterOrFail = effect.filterOrFail;
6243
6385
  * effect. The `orElse` effect can produce an alternative value or perform
6244
6386
  * additional computations.
6245
6387
  *
6246
- * @example
6388
+ * **Example**
6389
+ *
6247
6390
  * ```ts
6248
6391
  * import { Effect, pipe } from "effect"
6249
6392
  *
@@ -6283,7 +6426,8 @@ const filterEffectOrElse = exports.filterEffectOrElse = core.filterEffectOrElse;
6283
6426
  * This is useful for enforcing constraints and treating violations as
6284
6427
  * recoverable errors.
6285
6428
  *
6286
- * @example
6429
+ * **Example**
6430
+ *
6287
6431
  * ```ts
6288
6432
  * import { Effect, pipe } from "effect"
6289
6433
  *
@@ -6345,12 +6489,9 @@ const unlessEffect = exports.unlessEffect = effect.unlessEffect;
6345
6489
  * whether to execute an effect based on runtime logic, while also representing
6346
6490
  * the skipped case explicitly.
6347
6491
  *
6348
- * @see {@link whenEffect} for a version that allows the condition to be an effect.
6349
- * @see {@link unless} for a version that executes the effect when the condition is `false`.
6492
+ * **Example** (Conditional Effect Execution)
6350
6493
  *
6351
- * @example
6352
6494
  * ```ts
6353
- * // Title: Conditional Effect Execution
6354
6495
  * import { Effect, Option } from "effect"
6355
6496
  *
6356
6497
  * const validateWeightOption = (
@@ -6360,7 +6501,7 @@ const unlessEffect = exports.unlessEffect = effect.unlessEffect;
6360
6501
  * Effect.succeed(weight).pipe(Effect.when(() => weight >= 0))
6361
6502
  *
6362
6503
  * // Run with a valid weight
6363
- * // Effect.runPromise(validateWeightOption(100)).then(console.log)
6504
+ * Effect.runPromise(validateWeightOption(100)).then(console.log)
6364
6505
  * // Output:
6365
6506
  * // {
6366
6507
  * // _id: "Option",
@@ -6369,7 +6510,7 @@ const unlessEffect = exports.unlessEffect = effect.unlessEffect;
6369
6510
  * // }
6370
6511
  *
6371
6512
  * // Run with an invalid weight
6372
- * // Effect.runPromise(validateWeightOption(-5)).then(console.log)
6513
+ * Effect.runPromise(validateWeightOption(-5)).then(console.log)
6373
6514
  * // Output:
6374
6515
  * // {
6375
6516
  * // _id: "Option",
@@ -6377,6 +6518,9 @@ const unlessEffect = exports.unlessEffect = effect.unlessEffect;
6377
6518
  * // }
6378
6519
  * ```
6379
6520
  *
6521
+ * @see {@link whenEffect} for a version that allows the condition to be an effect.
6522
+ * @see {@link unless} for a version that executes the effect when the condition is `false`.
6523
+ *
6380
6524
  * @since 2.0.0
6381
6525
  * @category Conditional Operators
6382
6526
  */
@@ -6398,12 +6542,9 @@ const when = exports.when = effect.when;
6398
6542
  * depends on the result of another effect, such as a random value, a
6399
6543
  * user-provided input, or a network request result.
6400
6544
  *
6401
- * @see {@link when} for a version that allows the condition to be a boolean.
6402
- * @see {@link unlessEffect} for a version that executes the effect when the condition is `false`.
6545
+ * **Example** (Using an Effect as a Condition)
6403
6546
  *
6404
- * @example
6405
6547
  * ```ts
6406
- * // Title: Using an Effect as a Condition
6407
6548
  * import { Effect, Random } from "effect"
6408
6549
  *
6409
6550
  * const randomIntOption = Random.nextInt.pipe(
@@ -6415,6 +6556,9 @@ const when = exports.when = effect.when;
6415
6556
  * // { _id: 'Option', _tag: 'Some', value: 8609104974198840 }
6416
6557
  * ```
6417
6558
  *
6559
+ * @see {@link when} for a version that allows the condition to be a boolean.
6560
+ * @see {@link unlessEffect} for a version that executes the effect when the condition is `false`.
6561
+ *
6418
6562
  * @since 2.0.0
6419
6563
  * @category Conditional Operators
6420
6564
  */
@@ -6483,9 +6627,8 @@ const whenRef = exports.whenRef = effect.whenRef;
6483
6627
  * step produces a new `Effect` while flattening any nested effects that may
6484
6628
  * occur.
6485
6629
  *
6486
- * @see {@link tap} for a version that ignores the result of the effect.
6630
+ * **Example**
6487
6631
  *
6488
- * @example
6489
6632
  * ```ts
6490
6633
  * import { pipe, Effect } from "effect"
6491
6634
  *
@@ -6507,10 +6650,12 @@ const whenRef = exports.whenRef = effect.whenRef;
6507
6650
  * Effect.flatMap((amount) => applyDiscount(amount, 5))
6508
6651
  * )
6509
6652
  *
6510
- * // Effect.runPromise(finalAmount).then(console.log)
6653
+ * Effect.runPromise(finalAmount).then(console.log)
6511
6654
  * // Output: 95
6512
6655
  * ```
6513
6656
  *
6657
+ * @see {@link tap} for a version that ignores the result of the effect.
6658
+ *
6514
6659
  * @since 2.0.0
6515
6660
  * @category Sequencing
6516
6661
  */
@@ -6549,9 +6694,9 @@ const flatMap = exports.flatMap = core.flatMap;
6549
6694
  * **Note:** `andThen` works well with both `Option` and `Either` types,
6550
6695
  * treating them as effects.
6551
6696
  *
6552
- * @example
6697
+ * **Example** (Applying a Discount Based on Fetched Amount)
6698
+ *
6553
6699
  * ```ts
6554
- * // Title: Applying a Discount Based on Fetched Amount
6555
6700
  * import { pipe, Effect } from "effect"
6556
6701
  *
6557
6702
  * // Function to apply a discount safely to a transaction amount
@@ -6573,7 +6718,7 @@ const flatMap = exports.flatMap = core.flatMap;
6573
6718
  * Effect.flatMap((amount) => applyDiscount(amount, 5))
6574
6719
  * )
6575
6720
  *
6576
- * // Effect.runPromise(result1).then(console.log)
6721
+ * Effect.runPromise(result1).then(console.log)
6577
6722
  * // Output: 190
6578
6723
  *
6579
6724
  * // Using Effect.andThen
@@ -6583,7 +6728,7 @@ const flatMap = exports.flatMap = core.flatMap;
6583
6728
  * Effect.andThen((amount) => applyDiscount(amount, 5))
6584
6729
  * )
6585
6730
  *
6586
- * // Effect.runPromise(result2).then(console.log)
6731
+ * Effect.runPromise(result2).then(console.log)
6587
6732
  * // Output: 190
6588
6733
  * ```
6589
6734
  *
@@ -6622,12 +6767,9 @@ const flatten = exports.flatten = core.flatten;
6622
6767
  * wraps the result in an `Either` type, allowing you to see if the result
6623
6768
  * was a success (`Right`) or a failure (`Left`).
6624
6769
  *
6625
- * @see {@link raceAll} for a version that handles multiple effects.
6626
- * @see {@link raceFirst} for a version that returns the result of the first effect to complete.
6770
+ * **Example** (Both Tasks Succeed)
6627
6771
  *
6628
- * @example
6629
6772
  * ```ts
6630
- * // Title: Both Tasks Succeed
6631
6773
  * import { Effect, Console } from "effect"
6632
6774
  *
6633
6775
  * const task1 = Effect.succeed("task1").pipe(
@@ -6643,15 +6785,15 @@ const flatten = exports.flatten = core.flatten;
6643
6785
  *
6644
6786
  * const program = Effect.race(task1, task2)
6645
6787
  *
6646
- * // Effect.runFork(program)
6788
+ * Effect.runFork(program)
6647
6789
  * // Output:
6648
6790
  * // task1 done
6649
6791
  * // task2 interrupted
6650
6792
  * ```
6651
6793
  *
6652
- * @example
6794
+ * **Example** (One Task Fails, One Succeeds)
6795
+ *
6653
6796
  * ```ts
6654
- * // Title: One Task Fails, One Succeeds
6655
6797
  * import { Effect, Console } from "effect"
6656
6798
  *
6657
6799
  * const task1 = Effect.fail("task1").pipe(
@@ -6667,14 +6809,14 @@ const flatten = exports.flatten = core.flatten;
6667
6809
  *
6668
6810
  * const program = Effect.race(task1, task2)
6669
6811
  *
6670
- * // Effect.runFork(program)
6812
+ * Effect.runFork(program)
6671
6813
  * // Output:
6672
6814
  * // task2 done
6673
6815
  * ```
6674
6816
  *
6675
- * @example
6817
+ * **Example** (Both Tasks Fail)
6818
+ *
6676
6819
  * ```ts
6677
- * // Title: Both Tasks Fail
6678
6820
  * import { Effect, Console } from "effect"
6679
6821
  *
6680
6822
  * const task1 = Effect.fail("task1").pipe(
@@ -6690,7 +6832,7 @@ const flatten = exports.flatten = core.flatten;
6690
6832
  *
6691
6833
  * const program = Effect.race(task1, task2)
6692
6834
  *
6693
- * // Effect.runPromiseExit(program).then(console.log)
6835
+ * Effect.runPromiseExit(program).then(console.log)
6694
6836
  * // Output:
6695
6837
  * // {
6696
6838
  * // _id: 'Exit',
@@ -6704,9 +6846,9 @@ const flatten = exports.flatten = core.flatten;
6704
6846
  * // }
6705
6847
  * ```
6706
6848
  *
6707
- * @example
6849
+ * **Example** (Handling Success or Failure with Either)
6850
+ *
6708
6851
  * ```ts
6709
- * // Title: Handling Success or Failure with Either
6710
6852
  * import { Effect, Console } from "effect"
6711
6853
  *
6712
6854
  * const task1 = Effect.fail("task1").pipe(
@@ -6724,12 +6866,15 @@ const flatten = exports.flatten = core.flatten;
6724
6866
  * // in Either to capture success or failure
6725
6867
  * const program = Effect.race(Effect.either(task1), Effect.either(task2))
6726
6868
  *
6727
- * // Effect.runPromise(program).then(console.log)
6869
+ * Effect.runPromise(program).then(console.log)
6728
6870
  * // Output:
6729
6871
  * // task2 interrupted
6730
6872
  * // { _id: 'Either', _tag: 'Left', left: 'task1' }
6731
6873
  * ```
6732
6874
  *
6875
+ * @see {@link raceAll} for a version that handles multiple effects.
6876
+ * @see {@link raceFirst} for a version that returns the result of the first effect to complete.
6877
+ *
6733
6878
  * @since 2.0.0
6734
6879
  * @category Racing
6735
6880
  */
@@ -6753,11 +6898,9 @@ const race = exports.race = fiberRuntime.race;
6753
6898
  * retries, or when you want to optimize for the faster response without
6754
6899
  * worrying about the other effects.
6755
6900
  *
6756
- * @see {@link race} for a version that handles only two effects.
6901
+ * **Example** (All Tasks Succeed)
6757
6902
  *
6758
- * @example
6759
6903
  * ```ts
6760
- * // Title: All Tasks Succeed
6761
6904
  * import { Effect, Console } from "effect"
6762
6905
  *
6763
6906
  * const task1 = Effect.succeed("task1").pipe(
@@ -6779,16 +6922,16 @@ const race = exports.race = fiberRuntime.race;
6779
6922
  *
6780
6923
  * const program = Effect.raceAll([task1, task2, task3])
6781
6924
  *
6782
- * // Effect.runFork(program)
6925
+ * Effect.runFork(program)
6783
6926
  * // Output:
6784
6927
  * // task1 done
6785
6928
  * // task2 interrupted
6786
6929
  * // task3 interrupted
6787
6930
  * ```
6788
6931
  *
6789
- * @example
6932
+ * **Example** (One Task Fails, Two Tasks Succeed)
6933
+ *
6790
6934
  * ```ts
6791
- * // Title: One Task Fails, Two Tasks Succeed
6792
6935
  * import { Effect, Console } from "effect"
6793
6936
  *
6794
6937
  * const task1 = Effect.fail("task1").pipe(
@@ -6810,15 +6953,15 @@ const race = exports.race = fiberRuntime.race;
6810
6953
  *
6811
6954
  * const program = Effect.raceAll([task1, task2, task3])
6812
6955
  *
6813
- * // Effect.runFork(program)
6956
+ * Effect.runFork(program)
6814
6957
  * // Output:
6815
6958
  * // task3 done
6816
6959
  * // task2 interrupted
6817
6960
  * ```
6818
6961
  *
6819
- * @example
6962
+ * **Example** (All Tasks Fail)
6963
+ *
6820
6964
  * ```ts
6821
- * // Title: All Tasks Fail
6822
6965
  * import { Effect, Console } from "effect"
6823
6966
  *
6824
6967
  * const task1 = Effect.fail("task1").pipe(
@@ -6840,7 +6983,7 @@ const race = exports.race = fiberRuntime.race;
6840
6983
  *
6841
6984
  * const program = Effect.raceAll([task1, task2, task3])
6842
6985
  *
6843
- * // Effect.runPromiseExit(program).then(console.log)
6986
+ * Effect.runPromiseExit(program).then(console.log)
6844
6987
  * // Output:
6845
6988
  * // {
6846
6989
  * // _id: 'Exit',
@@ -6849,6 +6992,8 @@ const race = exports.race = fiberRuntime.race;
6849
6992
  * // }
6850
6993
  * ```
6851
6994
  *
6995
+ * @see {@link race} for a version that handles only two effects.
6996
+ *
6852
6997
  * @since 2.0.0
6853
6998
  * @category Racing
6854
6999
  */
@@ -6886,9 +7031,9 @@ const raceAll = exports.raceAll = fiberRuntime.raceAll;
6886
7031
  *
6887
7032
  * This allows both effects to complete independently while still terminating the losing effect in the background.
6888
7033
  *
6889
- * @example
7034
+ * **Example** (Both Tasks Succeed)
7035
+ *
6890
7036
  * ```ts
6891
- * // Title: Both Tasks Succeed
6892
7037
  * import { Effect, Console } from "effect"
6893
7038
  *
6894
7039
  * const task1 = Effect.succeed("task1").pipe(
@@ -6910,7 +7055,7 @@ const raceAll = exports.raceAll = fiberRuntime.raceAll;
6910
7055
  * Effect.tap(Console.log("more work..."))
6911
7056
  * )
6912
7057
  *
6913
- * // Effect.runPromiseExit(program).then(console.log)
7058
+ * Effect.runPromiseExit(program).then(console.log)
6914
7059
  * // Output:
6915
7060
  * // task1 done
6916
7061
  * // task2 interrupted
@@ -6918,9 +7063,9 @@ const raceAll = exports.raceAll = fiberRuntime.raceAll;
6918
7063
  * // { _id: 'Exit', _tag: 'Success', value: 'task1' }
6919
7064
  * ```
6920
7065
  *
6921
- * @example
7066
+ * **Example** (One Task Fails, One Succeeds)
7067
+ *
6922
7068
  * ```ts
6923
- * // Title: One Task Fails, One Succeeds
6924
7069
  * import { Effect, Console } from "effect"
6925
7070
  *
6926
7071
  * const task1 = Effect.fail("task1").pipe(
@@ -6942,7 +7087,7 @@ const raceAll = exports.raceAll = fiberRuntime.raceAll;
6942
7087
  * Effect.tap(Console.log("more work..."))
6943
7088
  * )
6944
7089
  *
6945
- * // Effect.runPromiseExit(program).then(console.log)
7090
+ * Effect.runPromiseExit(program).then(console.log)
6946
7091
  * // Output:
6947
7092
  * // task2 interrupted
6948
7093
  * // {
@@ -6952,9 +7097,9 @@ const raceAll = exports.raceAll = fiberRuntime.raceAll;
6952
7097
  * // }
6953
7098
  * ```
6954
7099
  *
6955
- * @example
7100
+ * **Example** (Using Effect.disconnect for Quicker Return)
7101
+ *
6956
7102
  * ```ts
6957
- * // Title: Using Effect.disconnect for Quicker Return
6958
7103
  * import { Effect, Console } from "effect"
6959
7104
  *
6960
7105
  * const task1 = Effect.succeed("task1").pipe(
@@ -6978,7 +7123,7 @@ const raceAll = exports.raceAll = fiberRuntime.raceAll;
6978
7123
  * Effect.disconnect(task2)
6979
7124
  * ).pipe(Effect.tap(Console.log("more work...")))
6980
7125
  *
6981
- * // Effect.runPromiseExit(program).then(console.log)
7126
+ * Effect.runPromiseExit(program).then(console.log)
6982
7127
  * // Output:
6983
7128
  * // task1 done
6984
7129
  * // more work...
@@ -7011,9 +7156,9 @@ const raceFirst = exports.raceFirst = circular.raceFirst;
7011
7156
  * effect without waiting for both to finish. It can be used whenever you want
7012
7157
  * to take action based on the first available result.
7013
7158
  *
7014
- * @example
7159
+ * **Example** (Handling Results of Concurrent Tasks)
7160
+ *
7015
7161
  * ```ts
7016
- * // Title: Handling Results of Concurrent Tasks
7017
7162
  * import { Effect, Console } from "effect"
7018
7163
  *
7019
7164
  * const task1 = Effect.succeed("task1").pipe(
@@ -7036,7 +7181,7 @@ const raceFirst = exports.raceFirst = circular.raceFirst;
7036
7181
  * onOtherDone: (exit) => Console.log(`task2 exited with ${exit}`)
7037
7182
  * })
7038
7183
  *
7039
- * // Effect.runFork(program)
7184
+ * Effect.runFork(program)
7040
7185
  * // Output:
7041
7186
  * // task1 done
7042
7187
  * // task1 exited with {
@@ -7078,11 +7223,9 @@ const summarized = exports.summarized = effect.summarized;
7078
7223
  * observe or record an action but want the original value to be passed to the
7079
7224
  * next step.
7080
7225
  *
7081
- * @see {@link flatMap} for a version that allows you to change the value.
7226
+ * **Example** (Logging a step in a pipeline)
7082
7227
  *
7083
- * @example
7084
7228
  * ```ts
7085
- * // Title: Logging a step in a pipeline
7086
7229
  * import { Console, Effect, pipe } from "effect"
7087
7230
  *
7088
7231
  * // Function to apply a discount safely to a transaction amount
@@ -7105,12 +7248,14 @@ const summarized = exports.summarized = effect.summarized;
7105
7248
  * Effect.flatMap((amount) => applyDiscount(amount, 5))
7106
7249
  * )
7107
7250
  *
7108
- * // Effect.runPromise(finalAmount).then(console.log)
7251
+ * Effect.runPromise(finalAmount).then(console.log)
7109
7252
  * // Output:
7110
7253
  * // Apply a discount to: 100
7111
7254
  * // 95
7112
7255
  * ```
7113
7256
  *
7257
+ * @see {@link flatMap} for a version that allows you to change the value.
7258
+ *
7114
7259
  * @since 2.0.0
7115
7260
  * @category Sequencing
7116
7261
  */
@@ -7134,7 +7279,8 @@ const tap = exports.tap = core.tap;
7134
7279
  * If either the success or failure handler fails, the overall effect will also
7135
7280
  * fail.
7136
7281
  *
7137
- * @example
7282
+ * **Example**
7283
+ *
7138
7284
  * ```ts
7139
7285
  * import { Effect, Random, Console } from "effect"
7140
7286
  *
@@ -7152,7 +7298,7 @@ const tap = exports.tap = core.tap;
7152
7298
  * Console.log(`random number: ${randomNumber}`)
7153
7299
  * })
7154
7300
  *
7155
- * // Effect.runFork(tapping)
7301
+ * Effect.runFork(tapping)
7156
7302
  * // Example Output:
7157
7303
  * // failure: random number is negative
7158
7304
  * ```
@@ -7177,7 +7323,8 @@ const tapBoth = exports.tapBoth = effect.tapBoth;
7177
7323
  * way. Importantly, this does not alter the main result of the effect. If no
7178
7324
  * defect occurs, the effect behaves as if this function was not used.
7179
7325
  *
7180
- * @example
7326
+ * **Example**
7327
+ *
7181
7328
  * ```ts
7182
7329
  * import { Effect, Console } from "effect"
7183
7330
  *
@@ -7189,7 +7336,7 @@ const tapBoth = exports.tapBoth = effect.tapBoth;
7189
7336
  * Console.log(`defect: ${cause}`)
7190
7337
  * )
7191
7338
  *
7192
- * // Effect.runFork(tapping1)
7339
+ * Effect.runFork(tapping1)
7193
7340
  * // No Output
7194
7341
  *
7195
7342
  * // Simulate a severe failure in the system
@@ -7202,7 +7349,7 @@ const tapBoth = exports.tapBoth = effect.tapBoth;
7202
7349
  * Console.log(`defect: ${cause}`)
7203
7350
  * )
7204
7351
  *
7205
- * // Effect.runFork(tapping2)
7352
+ * Effect.runFork(tapping2)
7206
7353
  * // Output:
7207
7354
  * // defect: RuntimeException: Something went wrong
7208
7355
  * // ... stack trace ...
@@ -7227,7 +7374,8 @@ const tapDefect = exports.tapDefect = effect.tapDefect;
7227
7374
  * effect succeeds, the function is ignored, and the success value is propagated
7228
7375
  * as usual.
7229
7376
  *
7230
- * @example
7377
+ * **Example**
7378
+ *
7231
7379
  * ```ts
7232
7380
  * import { Effect, Console } from "effect"
7233
7381
  *
@@ -7239,7 +7387,7 @@ const tapDefect = exports.tapDefect = effect.tapDefect;
7239
7387
  * Console.log(`expected error: ${error}`)
7240
7388
  * )
7241
7389
  *
7242
- * // Effect.runFork(tapping)
7390
+ * Effect.runFork(tapping)
7243
7391
  * // Output:
7244
7392
  * // expected error: NetworkError
7245
7393
  * ```
@@ -7262,7 +7410,8 @@ const tapError = exports.tapError = effect.tapError;
7262
7410
  * If the error doesn't match the specified tag, this function does nothing, and
7263
7411
  * the effect proceeds as usual.
7264
7412
  *
7265
- * @example
7413
+ * **Example**
7414
+ *
7266
7415
  * ```ts
7267
7416
  * import { Effect, Console } from "effect"
7268
7417
  *
@@ -7285,7 +7434,7 @@ const tapError = exports.tapError = effect.tapError;
7285
7434
  * Console.log(`expected error: ${error.statusCode}`)
7286
7435
  * )
7287
7436
  *
7288
- * // Effect.runFork(tapping)
7437
+ * Effect.runFork(tapping)
7289
7438
  * // Output:
7290
7439
  * // expected error: 504
7291
7440
  * ```
@@ -7309,7 +7458,8 @@ const tapErrorTag = exports.tapErrorTag = effect.tapErrorTag;
7309
7458
  * The effect itself is not modified, and any errors or defects remain in the
7310
7459
  * error channel of the original effect.
7311
7460
  *
7312
- * @example
7461
+ * **Example**
7462
+ *
7313
7463
  * ```ts
7314
7464
  * import { Effect, Console } from "effect"
7315
7465
  *
@@ -7320,7 +7470,7 @@ const tapErrorTag = exports.tapErrorTag = effect.tapErrorTag;
7320
7470
  * Console.log(`error cause: ${cause}`)
7321
7471
  * )
7322
7472
  *
7323
- * // Effect.runFork(tapping1)
7473
+ * Effect.runFork(tapping1)
7324
7474
  * // Output:
7325
7475
  * // error cause: Error: NetworkError
7326
7476
  *
@@ -7333,7 +7483,7 @@ const tapErrorTag = exports.tapErrorTag = effect.tapErrorTag;
7333
7483
  * Console.log(`error cause: ${cause}`)
7334
7484
  * )
7335
7485
  *
7336
- * // Effect.runFork(tapping2)
7486
+ * Effect.runFork(tapping2)
7337
7487
  * // Output:
7338
7488
  * // error cause: RuntimeException: Something went wrong
7339
7489
  * // ... stack trace ...
@@ -7397,9 +7547,9 @@ const forever = exports.forever = effect.forever;
7397
7547
  * asynchronous or side-effectful operations, such as polling or iterative
7398
7548
  * computations that depend on external factors.
7399
7549
  *
7400
- * @example
7550
+ * **Example** (Effectful Iteration)
7551
+ *
7401
7552
  * ```ts
7402
- * // Title: Effectful Iteration
7403
7553
  * import { Effect } from "effect"
7404
7554
  *
7405
7555
  * const result = Effect.iterate(
@@ -7413,7 +7563,7 @@ const forever = exports.forever = effect.forever;
7413
7563
  * }
7414
7564
  * )
7415
7565
  *
7416
- * // Effect.runPromise(result).then(console.log)
7566
+ * Effect.runPromise(result).then(console.log)
7417
7567
  * // Output: 6
7418
7568
  * ```
7419
7569
  *
@@ -7462,9 +7612,9 @@ const iterate = exports.iterate = effect.iterate;
7462
7612
  * computations repeatedly, such as processing items in a list, generating
7463
7613
  * values, or performing iterative updates.
7464
7614
  *
7465
- * @example
7615
+ * **Example** (Looping with Collected Results)
7616
+ *
7466
7617
  * ```ts
7467
- * // Title: Looping with Collected Results
7468
7618
  * import { Effect } from "effect"
7469
7619
  *
7470
7620
  * // A loop that runs 5 times, collecting each iteration's result
@@ -7481,12 +7631,13 @@ const iterate = exports.iterate = effect.iterate;
7481
7631
  * }
7482
7632
  * )
7483
7633
  *
7484
- * // Effect.runPromise(result).then(console.log)
7634
+ * Effect.runPromise(result).then(console.log)
7485
7635
  * // Output: [1, 2, 3, 4, 5]
7486
7636
  * ```
7487
7637
  *
7488
- * @example
7489
- * // Title: Loop with Discarded Results
7638
+ * **Example** (Loop with Discarded Results)
7639
+ *
7640
+ * ```ts
7490
7641
  * import { Effect, Console } from "effect"
7491
7642
  *
7492
7643
  * const result = Effect.loop(
@@ -7504,7 +7655,7 @@ const iterate = exports.iterate = effect.iterate;
7504
7655
  * }
7505
7656
  * )
7506
7657
  *
7507
- * // Effect.runPromise(result).then(console.log)
7658
+ * Effect.runPromise(result).then(console.log)
7508
7659
  * // Output:
7509
7660
  * // Currently at state 1
7510
7661
  * // Currently at state 2
@@ -7512,6 +7663,7 @@ const iterate = exports.iterate = effect.iterate;
7512
7663
  * // Currently at state 4
7513
7664
  * // Currently at state 5
7514
7665
  * // undefined
7666
+ * ```
7515
7667
  *
7516
7668
  * @since 2.0.0
7517
7669
  * @category Looping
@@ -7539,20 +7691,21 @@ const loop = exports.loop = effect.loop;
7539
7691
  * delays, limiting recursions, or dynamically adjusting based on the outcome of
7540
7692
  * each execution.
7541
7693
  *
7542
- * @example
7694
+ * **Example** (Success Example)
7695
+ *
7543
7696
  * ```ts
7544
- * // Success Example
7545
7697
  * import { Effect, Schedule, Console } from "effect"
7546
7698
  *
7547
7699
  * const action = Console.log("success")
7548
7700
  * const policy = Schedule.addDelay(Schedule.recurs(2), () => "100 millis")
7549
7701
  * const program = Effect.repeat(action, policy)
7550
7702
  *
7551
- * // Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
7703
+ * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
7552
7704
  * ```
7553
7705
  *
7554
- * @example
7555
- * // Failure Example
7706
+ * **Example** (Failure Example)
7707
+ *
7708
+ * ```ts
7556
7709
  * import { Effect, Schedule } from "effect"
7557
7710
  *
7558
7711
  * let count = 0
@@ -7572,7 +7725,8 @@ const loop = exports.loop = effect.loop;
7572
7725
  * const policy = Schedule.addDelay(Schedule.recurs(2), () => "100 millis")
7573
7726
  * const program = Effect.repeat(action, policy)
7574
7727
  *
7575
- * // Effect.runPromiseExit(program).then(console.log)
7728
+ * Effect.runPromiseExit(program).then(console.log)
7729
+ * ```
7576
7730
  *
7577
7731
  * @since 2.0.0
7578
7732
  * @category Repetition / Recursion
@@ -7596,14 +7750,15 @@ const repeat = exports.repeat = schedule_.repeat_combined;
7596
7750
  * This function is useful for tasks that need to be retried a fixed number of
7597
7751
  * times or for performing repeated actions without requiring a schedule.
7598
7752
  *
7599
- * @example
7753
+ * **Example**
7754
+ *
7600
7755
  * ```ts
7601
7756
  * import { Effect, Console } from "effect"
7602
7757
  *
7603
7758
  * const action = Console.log("success")
7604
7759
  * const program = Effect.repeatN(action, 2)
7605
7760
  *
7606
- * // Effect.runPromise(program)
7761
+ * Effect.runPromise(program)
7607
7762
  * ```
7608
7763
  *
7609
7764
  * @since 2.0.0
@@ -7627,7 +7782,8 @@ const repeatN = exports.repeatN = effect.repeatN;
7627
7782
  * failure occurs during any iteration, the failure handler is invoked to handle
7628
7783
  * the situation.
7629
7784
  *
7630
- * @example
7785
+ * **Example**
7786
+ *
7631
7787
  * ```ts
7632
7788
  * import { Effect, Schedule } from "effect"
7633
7789
  *
@@ -7657,7 +7813,7 @@ const repeatN = exports.repeatN = effect.repeatN;
7657
7813
  * })
7658
7814
  * )
7659
7815
  *
7660
- * // Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
7816
+ * Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
7661
7817
  * ```
7662
7818
  *
7663
7819
  * @since 2.0.0
@@ -7806,18 +7962,19 @@ const updateFiberRefs = exports.updateFiberRefs = effect.updateFiberRefs;
7806
7962
  * The resulting effect cannot fail (`never` in the error channel) but retains
7807
7963
  * the context of the original effect.
7808
7964
  *
7809
- * @example
7965
+ * **Example**
7966
+ *
7810
7967
  * ```ts
7811
7968
  * import { Effect } from "effect"
7812
7969
  *
7813
7970
  * const failure = Effect.fail("Uh oh!")
7814
7971
  *
7815
- * // console.log(Effect.runSync(Effect.isFailure(failure)))
7972
+ * console.log(Effect.runSync(Effect.isFailure(failure)))
7816
7973
  * // Output: true
7817
7974
  *
7818
7975
  * const defect = Effect.dieMessage("BOOM!")
7819
7976
  *
7820
- * // Effect.runSync(Effect.isFailure(defect))
7977
+ * Effect.runSync(Effect.isFailure(defect))
7821
7978
  * // throws: BOOM!
7822
7979
  * ```
7823
7980
  *
@@ -7857,11 +8014,9 @@ const isSuccess = exports.isSuccess = effect.isSuccess;
7857
8014
  * This is useful for structuring your code to respond differently to success or
7858
8015
  * failure without triggering side effects.
7859
8016
  *
7860
- * @see {@link matchEffect} if you need to perform side effects in the handlers.
8017
+ * **Example** (Handling Both Success and Failure Cases)
7861
8018
  *
7862
- * @example
7863
8019
  * ```ts
7864
- * // Title: Handling Both Success and Failure Cases
7865
8020
  * import { Effect } from "effect"
7866
8021
  *
7867
8022
  * const success: Effect.Effect<number, Error> = Effect.succeed(42)
@@ -7872,7 +8027,7 @@ const isSuccess = exports.isSuccess = effect.isSuccess;
7872
8027
  * })
7873
8028
  *
7874
8029
  * // Run and log the result of the successful effect
7875
- * // Effect.runPromise(program1).then(console.log)
8030
+ * Effect.runPromise(program1).then(console.log)
7876
8031
  * // Output: "success: 42"
7877
8032
  *
7878
8033
  * const failure: Effect.Effect<number, Error> = Effect.fail(
@@ -7885,10 +8040,12 @@ const isSuccess = exports.isSuccess = effect.isSuccess;
7885
8040
  * })
7886
8041
  *
7887
8042
  * // Run and log the result of the failed effect
7888
- * // Effect.runPromise(program2).then(console.log)
8043
+ * Effect.runPromise(program2).then(console.log)
7889
8044
  * // Output: "failure: Uh oh!"
7890
8045
  * ```
7891
8046
  *
8047
+ * @see {@link matchEffect} if you need to perform side effects in the handlers.
8048
+ *
7892
8049
  * @since 2.0.0
7893
8050
  * @category Matching
7894
8051
  */
@@ -7907,13 +8064,9 @@ const match = exports.match = effect.match;
7907
8064
  * regular failures, defects, or interruptions. You can provide specific
7908
8065
  * handling logic for each failure type based on the cause.
7909
8066
  *
7910
- * @see {@link matchCauseEffect} if you need to perform side effects in the
7911
- * handlers.
7912
- * @see {@link match} if you don't need to handle the cause of the failure.
8067
+ * **Example** (Handling Different Failure Causes)
7913
8068
  *
7914
- * @example
7915
8069
  * ```ts
7916
- * // Title: Handling Different Failure Causes
7917
8070
  * import { Effect } from "effect"
7918
8071
  *
7919
8072
  * const task: Effect.Effect<number, Error> = Effect.die("Uh oh!")
@@ -7939,11 +8092,14 @@ const match = exports.match = effect.match;
7939
8092
  * `succeeded with ${value} value`
7940
8093
  * })
7941
8094
  *
7942
- * // Effect.runPromise(program).then(console.log)
8095
+ * Effect.runPromise(program).then(console.log)
7943
8096
  * // Output: "Die: Uh oh!"
7944
- *
7945
8097
  * ```
7946
8098
  *
8099
+ * @see {@link matchCauseEffect} if you need to perform side effects in the
8100
+ * handlers.
8101
+ * @see {@link match} if you don't need to handle the cause of the failure.
8102
+ *
7947
8103
  * @since 2.0.0
7948
8104
  * @category Matching
7949
8105
  */
@@ -7960,12 +8116,9 @@ const matchCause = exports.matchCause = core.matchCause;
7960
8116
  * you to respond accordingly while performing side effects (like logging or
7961
8117
  * other operations).
7962
8118
  *
7963
- * @see {@link matchCause} if you don't need side effects and only want to handle the result or failure.
7964
- * @see {@link matchEffect} if you don't need to handle the cause of the failure.
8119
+ * **Example** (Handling Different Failure Causes with Side Effects)
7965
8120
  *
7966
- * @example
7967
8121
  * ```ts
7968
- * // Title: Handling Different Failure Causes with Side Effects
7969
8122
  * import { Effect, Console } from "effect"
7970
8123
  *
7971
8124
  * const task: Effect.Effect<number, Error> = Effect.die("Uh oh!")
@@ -7991,10 +8144,13 @@ const matchCause = exports.matchCause = core.matchCause;
7991
8144
  * Console.log(`succeeded with ${value} value`)
7992
8145
  * })
7993
8146
  *
7994
- * // Effect.runPromise(program)
8147
+ * Effect.runPromise(program)
7995
8148
  * // Output: "Die: Uh oh!"
7996
8149
  * ```
7997
8150
  *
8151
+ * @see {@link matchCause} if you don't need side effects and only want to handle the result or failure.
8152
+ * @see {@link matchEffect} if you don't need to handle the cause of the failure.
8153
+ *
7998
8154
  * @since 2.0.0
7999
8155
  * @category Matching
8000
8156
  */
@@ -8013,12 +8169,9 @@ const matchCauseEffect = exports.matchCauseEffect = core.matchCauseEffect;
8013
8169
  * This is useful when you need to execute additional actions, like logging or
8014
8170
  * notifying users, based on whether an effect succeeds or fails.
8015
8171
  *
8016
- * @see {@link match} if you don't need side effects and only want to handle the
8017
- * result or failure.
8172
+ * **Example** (Handling Both Success and Failure Cases with Side Effects)
8018
8173
  *
8019
- * @example
8020
8174
  * ```ts
8021
- * // Title: Handling Both Success and Failure Cases with Side Effects
8022
8175
  * import { Effect } from "effect"
8023
8176
  *
8024
8177
  * const success: Effect.Effect<number, Error> = Effect.succeed(42)
@@ -8055,6 +8208,9 @@ const matchCauseEffect = exports.matchCauseEffect = core.matchCauseEffect;
8055
8208
  * // failure: Uh oh!
8056
8209
  * ```
8057
8210
  *
8211
+ * @see {@link match} if you don't need side effects and only want to handle the
8212
+ * result or failure.
8213
+ *
8058
8214
  * @since 2.0.0
8059
8215
  * @category Matching
8060
8216
  */
@@ -8075,7 +8231,8 @@ const matchEffect = exports.matchEffect = core.matchEffect;
8075
8231
  * level, and fiber ID, making it suitable for debugging and tracking purposes.
8076
8232
  * This function does not interrupt or alter the effect's execution flow.
8077
8233
  *
8078
- * @example
8234
+ * **Example**
8235
+ *
8079
8236
  * ```ts
8080
8237
  * import { Cause, Effect } from "effect"
8081
8238
  *
@@ -8086,7 +8243,7 @@ const matchEffect = exports.matchEffect = core.matchEffect;
8086
8243
  * Cause.die("Oh uh!")
8087
8244
  * )
8088
8245
  *
8089
- * // Effect.runFork(program)
8246
+ * Effect.runFork(program)
8090
8247
  * // Output:
8091
8248
  * // timestamp=... level=INFO fiber=#0 message=message1 message=message2 cause="Error: Oh no!
8092
8249
  * // Error: Oh uh!"
@@ -8106,7 +8263,8 @@ const log = exports.log = effect.log;
8106
8263
  * flexibility in categorizing logs based on their importance or severity,
8107
8264
  * making it easier to filter logs during debugging or production monitoring.
8108
8265
  *
8109
- * @example
8266
+ * **Example**
8267
+ *
8110
8268
  * ```ts
8111
8269
  * import { Cause, Effect, LogLevel } from "effect"
8112
8270
  *
@@ -8116,7 +8274,7 @@ const log = exports.log = effect.log;
8116
8274
  * Cause.die("System failure!")
8117
8275
  * )
8118
8276
  *
8119
- * // Effect.runFork(program)
8277
+ * Effect.runFork(program)
8120
8278
  * // Output:
8121
8279
  * // timestamp=... level=ERROR fiber=#0 message=Critical error encountered cause="Error: System failure!"
8122
8280
  * ```
@@ -8136,13 +8294,14 @@ const logWithLevel = (level, ...message) => effect.logWithLevel(level)(...messag
8136
8294
  * configuration by setting the minimum log level to `LogLevel.Trace` using
8137
8295
  * `Logger.withMinimumLogLevel`.
8138
8296
  *
8139
- * @example
8297
+ * **Example**
8298
+ *
8140
8299
  * ```ts
8141
8300
  * import { Effect, Logger, LogLevel } from "effect"
8142
8301
  *
8143
8302
  * const program = Effect.logTrace("message1").pipe(Logger.withMinimumLogLevel(LogLevel.Trace))
8144
8303
  *
8145
- * // Effect.runFork(program)
8304
+ * Effect.runFork(program)
8146
8305
  * // timestamp=... level=TRACE fiber=#0 message=message1
8147
8306
  * ```
8148
8307
  *
@@ -8161,13 +8320,14 @@ const logTrace = exports.logTrace = effect.logTrace;
8161
8320
  * less detailed information than TRACE logs but are still not shown by default.
8162
8321
  * To view these logs, adjust the log level using `Logger.withMinimumLogLevel`.
8163
8322
  *
8164
- * @example
8323
+ * **Example**
8324
+ *
8165
8325
  * ```ts
8166
8326
  * import { Effect, Logger, LogLevel } from "effect"
8167
8327
  *
8168
8328
  * const program = Effect.logDebug("message1").pipe(Logger.withMinimumLogLevel(LogLevel.Debug))
8169
8329
  *
8170
- * // Effect.runFork(program)
8330
+ * Effect.runFork(program)
8171
8331
  * // timestamp=... level=DEBUG fiber=#0 message=message1
8172
8332
  * ```
8173
8333
  *
@@ -8244,7 +8404,8 @@ const logFatal = exports.logFatal = effect.logFatal;
8244
8404
  * operation. The span information is included in the log metadata, making it
8245
8405
  * easy to trace performance metrics in logs.
8246
8406
  *
8247
- * @example
8407
+ * **Example**
8408
+ *
8248
8409
  * ```ts
8249
8410
  * import { Effect } from "effect"
8250
8411
  *
@@ -8253,7 +8414,7 @@ const logFatal = exports.logFatal = effect.logFatal;
8253
8414
  * yield* Effect.log("The job is finished!")
8254
8415
  * }).pipe(Effect.withLogSpan("myspan"))
8255
8416
  *
8256
- * // Effect.runFork(program)
8417
+ * Effect.runFork(program)
8257
8418
  * // timestamp=... level=INFO fiber=#0 message="The job is finished!" myspan=1011ms
8258
8419
  * ```
8259
8420
  *
@@ -8279,9 +8440,8 @@ const withLogSpan = exports.withLogSpan = effect.withLogSpan;
8279
8440
  * The annotated key-value pairs will appear alongside the log message in the
8280
8441
  * output.
8281
8442
  *
8282
- * @see {@link annotateLogsScoped} to add log annotations with a limited scope.
8443
+ * **Example**
8283
8444
  *
8284
- * @example
8285
8445
  * ```ts
8286
8446
  * import { Effect } from "effect"
8287
8447
  *
@@ -8290,11 +8450,13 @@ const withLogSpan = exports.withLogSpan = effect.withLogSpan;
8290
8450
  * yield* Effect.log("message2")
8291
8451
  * }).pipe(Effect.annotateLogs("taskId", "1234")) // Annotation as key/value pair
8292
8452
  *
8293
- * // Effect.runFork(program)
8453
+ * Effect.runFork(program)
8294
8454
  * // timestamp=... level=INFO fiber=#0 message=message1 taskId=1234
8295
8455
  * // timestamp=... level=INFO fiber=#0 message=message2 taskId=1234
8296
8456
  * ```
8297
8457
  *
8458
+ * @see {@link annotateLogsScoped} to add log annotations with a limited scope.
8459
+ *
8298
8460
  * @since 2.0.0
8299
8461
  * @category Logging
8300
8462
  */
@@ -8315,9 +8477,8 @@ const annotateLogs = exports.annotateLogs = effect.annotateLogs;
8315
8477
  * multiple key-value pairs. This flexibility enables fine-grained control over
8316
8478
  * the additional metadata included in logs for specific tasks or operations.
8317
8479
  *
8318
- * @see {@link annotateLogs} to add custom annotations to log entries generated within an effect.
8480
+ * **Example**
8319
8481
  *
8320
- * @example
8321
8482
  * ```ts
8322
8483
  * import { Effect } from "effect"
8323
8484
  *
@@ -8328,13 +8489,15 @@ const annotateLogs = exports.annotateLogs = effect.annotateLogs;
8328
8489
  * yield* Effect.log("message2") // Annotation is applied to this log
8329
8490
  * }).pipe(Effect.scoped, Effect.andThen(Effect.log("no annotations again")))
8330
8491
  *
8331
- * // Effect.runFork(program)
8492
+ * Effect.runFork(program)
8332
8493
  * // timestamp=... level=INFO fiber=#0 message="no annotations"
8333
8494
  * // timestamp=... level=INFO fiber=#0 message=message1 key=value
8334
8495
  * // timestamp=... level=INFO fiber=#0 message=message2 key=value
8335
8496
  * // timestamp=... level=INFO fiber=#0 message="no annotations again"
8336
8497
  * ```
8337
8498
  *
8499
+ * @see {@link annotateLogs} to add custom annotations to log entries generated within an effect.
8500
+ *
8338
8501
  * @since 3.1.0
8339
8502
  * @category Logging
8340
8503
  */
@@ -8377,7 +8540,8 @@ const logAnnotations = exports.logAnnotations = effect.logAnnotations;
8377
8540
  * It is especially useful when you want to reduce noise in logs or prioritize
8378
8541
  * certain types of errors.
8379
8542
  *
8380
- * @example
8543
+ * **Example**
8544
+ *
8381
8545
  * ```ts
8382
8546
  * import { Effect, Fiber, LogLevel, Option } from "effect"
8383
8547
  *
@@ -8386,7 +8550,7 @@ const logAnnotations = exports.logAnnotations = effect.logAnnotations;
8386
8550
  * yield* Fiber.join(fiber)
8387
8551
  * })
8388
8552
  *
8389
- * // Effect.runFork(program.pipe(Effect.withUnhandledErrorLogLevel(Option.some(LogLevel.Error))))
8553
+ * Effect.runFork(program.pipe(Effect.withUnhandledErrorLogLevel(Option.some(LogLevel.Error))))
8390
8554
  * // Output:
8391
8555
  * // timestamp=... level=ERROR fiber=#1 message="Fiber terminated with an unhandled error" cause="Error: Unhandled error!"
8392
8556
  * ```
@@ -8408,7 +8572,8 @@ const withUnhandledErrorLogLevel = exports.withUnhandledErrorLogLevel = core.wit
8408
8572
  * This function is useful for conditionally executing logging-related effects
8409
8573
  * or other operations that depend on the current log level configuration.
8410
8574
  *
8411
- * @example
8575
+ * **Example**
8576
+ *
8412
8577
  * ```ts
8413
8578
  * import { Effect, Logger, LogLevel } from "effect"
8414
8579
  *
@@ -8417,7 +8582,7 @@ const withUnhandledErrorLogLevel = exports.withUnhandledErrorLogLevel = core.wit
8417
8582
  * yield* Effect.whenLogLevel(Effect.logDebug("message2"), LogLevel.Debug); // returns `Some`
8418
8583
  * }).pipe(Logger.withMinimumLogLevel(LogLevel.Debug));
8419
8584
  *
8420
- * // Effect.runFork(program)
8585
+ * Effect.runFork(program)
8421
8586
  * // timestamp=... level=DEBUG fiber=#0 message=message2
8422
8587
  * ```
8423
8588
  *
@@ -8444,11 +8609,9 @@ const whenLogLevel = exports.whenLogLevel = fiberRuntime.whenLogLevel;
8444
8609
  * Use `orDie` when failures should be treated as unrecoverable defects and no
8445
8610
  * error handling is required.
8446
8611
  *
8447
- * @see {@link orDieWith} if you need to customize the error.
8612
+ * **Example** (Propagating an Error as a Defect)
8448
8613
  *
8449
- * @example
8450
8614
  * ```ts
8451
- * // Title: Propagating an Error as a Defect
8452
8615
  * import { Effect } from "effect"
8453
8616
  *
8454
8617
  * const divide = (a: number, b: number) =>
@@ -8460,12 +8623,14 @@ const whenLogLevel = exports.whenLogLevel = fiberRuntime.whenLogLevel;
8460
8623
  * // ▼
8461
8624
  * const program = Effect.orDie(divide(1, 0))
8462
8625
  *
8463
- * // Effect.runPromise(program).catch(console.error)
8626
+ * Effect.runPromise(program).catch(console.error)
8464
8627
  * // Output:
8465
8628
  * // (FiberFailure) Error: Cannot divide by zero
8466
8629
  * // ...stack trace...
8467
8630
  * ```
8468
8631
  *
8632
+ * @see {@link orDieWith} if you need to customize the error.
8633
+ *
8469
8634
  * @since 2.0.0
8470
8635
  * @category Converting Failures to Defects
8471
8636
  */
@@ -8485,11 +8650,9 @@ const orDie = exports.orDie = core.orDie;
8485
8650
  * Use `orDieWith` when failures should terminate the fiber as defects, and you want to customize
8486
8651
  * the error for clarity or debugging purposes.
8487
8652
  *
8488
- * @see {@link orDie} if you don't need to customize the error.
8653
+ * **Example** (Customizing Defect)
8489
8654
  *
8490
- * @example
8491
8655
  * ```ts
8492
- * // Title: Customizing Defect
8493
8656
  * import { Effect } from "effect"
8494
8657
  *
8495
8658
  * const divide = (a: number, b: number) =>
@@ -8504,12 +8667,14 @@ const orDie = exports.orDie = core.orDie;
8504
8667
  * (error) => new Error(`defect: ${error.message}`)
8505
8668
  * )
8506
8669
  *
8507
- * // Effect.runPromise(program).catch(console.error)
8670
+ * Effect.runPromise(program).catch(console.error)
8508
8671
  * // Output:
8509
8672
  * // (FiberFailure) Error: defect: Cannot divide by zero
8510
8673
  * // ...stack trace...
8511
8674
  * ```
8512
8675
  *
8676
+ * @see {@link orDie} if you don't need to customize the error.
8677
+ *
8513
8678
  * @since 2.0.0
8514
8679
  * @category Converting Failures to Defects
8515
8680
  */
@@ -8528,9 +8693,8 @@ const orDieWith = exports.orDieWith = core.orDieWith;
8528
8693
  * The error type of the resulting effect will be that of the fallback effect,
8529
8694
  * as the first effect's error is replaced when the fallback is executed.
8530
8695
  *
8531
- * @see {@link catchAll} if you need to access the error in the fallback effect.
8696
+ * **Example**
8532
8697
  *
8533
- * @example
8534
8698
  * ```ts
8535
8699
  * import { Effect } from "effect"
8536
8700
  *
@@ -8549,6 +8713,8 @@ const orDieWith = exports.orDieWith = core.orDieWith;
8549
8713
  * // Output: "fallback"
8550
8714
  * ```
8551
8715
  *
8716
+ * @see {@link catchAll} if you need to access the error in the fallback effect.
8717
+ *
8552
8718
  * @since 2.0.0
8553
8719
  * @category Fallback
8554
8720
  */
@@ -8571,9 +8737,8 @@ const orElse = exports.orElse = core.orElse;
8571
8737
  * error management by ensuring that all failures are replaced with a controlled
8572
8738
  * alternative.
8573
8739
  *
8574
- * @see {@link mapError} if you need to access the error to transform it.
8740
+ * **Example**
8575
8741
  *
8576
- * @example
8577
8742
  * ```ts
8578
8743
  * import { Effect } from "effect"
8579
8744
  *
@@ -8598,6 +8763,8 @@ const orElse = exports.orElse = core.orElse;
8598
8763
  * // }
8599
8764
  * ```
8600
8765
  *
8766
+ * @see {@link mapError} if you need to access the error to transform it.
8767
+ *
8601
8768
  * @since 2.0.0
8602
8769
  * @category Fallback
8603
8770
  */
@@ -8621,7 +8788,8 @@ const orElseFail = exports.orElseFail = effect.orElseFail;
8621
8788
  * function, you can avoid the need for complex error handling and guarantee a
8622
8789
  * fallback result.
8623
8790
  *
8624
- * @example
8791
+ * **Example**
8792
+ *
8625
8793
  * ```ts
8626
8794
  * import { Effect } from "effect"
8627
8795
  *
@@ -8671,7 +8839,8 @@ const orElseSucceed = exports.orElseSucceed = effect.orElseSucceed;
8671
8839
  * alternative sources to obtain a result, such as attempting multiple APIs,
8672
8840
  * retrieving configurations, or accessing resources in a prioritized manner.
8673
8841
  *
8674
- * @example
8842
+ * **Example**
8843
+ *
8675
8844
  * ```ts
8676
8845
  * import { Effect, Console } from "effect"
8677
8846
  *
@@ -8881,7 +9050,8 @@ const unsafeMakeSemaphore = exports.unsafeMakeSemaphore = circular.unsafeMakeSem
8881
9050
  * shared resource. The number of permits determines how many tasks can access
8882
9051
  * the resource concurrently.
8883
9052
  *
8884
- * @example
9053
+ * **Example**
9054
+ *
8885
9055
  * ```ts
8886
9056
  * import { Effect } from "effect"
8887
9057
  *
@@ -8906,7 +9076,8 @@ const unsafeMakeLatch = exports.unsafeMakeLatch = circular.unsafeMakeLatch;
8906
9076
  * This function initializes a `Latch` safely, ensuring proper runtime
8907
9077
  * guarantees. By default, the latch starts in the closed state.
8908
9078
  *
8909
- * @example
9079
+ * **Example**
9080
+ *
8910
9081
  * ```ts
8911
9082
  * import { Console, Effect } from "effect"
8912
9083
  *
@@ -8927,7 +9098,7 @@ const unsafeMakeLatch = exports.unsafeMakeLatch = circular.unsafeMakeLatch;
8927
9098
  * yield* fiber.await
8928
9099
  * })
8929
9100
  *
8930
- * // Effect.runFork(program)
9101
+ * Effect.runFork(program)
8931
9102
  * // Output: open sesame (after 1 second)
8932
9103
  * ```
8933
9104
  *
@@ -8965,9 +9136,9 @@ const makeLatch = exports.makeLatch = circular.makeLatch;
8965
9136
  * This function is ideal if you don't need the result immediately or if the
8966
9137
  * effect is part of a larger concurrent workflow.
8967
9138
  *
8968
- * @example
9139
+ * **Example** (Running an Effect in the Background)
9140
+ *
8969
9141
  * ```ts
8970
- * // Title: Running an Effect in the Background
8971
9142
  * import { Effect, Console, Schedule, Fiber } from "effect"
8972
9143
  *
8973
9144
  * // ┌─── Effect<number, never, never>
@@ -9028,25 +9199,27 @@ const runCallback = exports.runCallback = runtime_.unsafeRunEffect;
9028
9199
  * in a promise-based system, such as when integrating with third-party
9029
9200
  * libraries that expect `Promise` results.
9030
9201
  *
9031
- * @see {@link runPromiseExit} for a version that returns an `Exit` type instead
9032
- * of rejecting.
9202
+ * **Example** (Running a Successful Effect as a Promise)
9033
9203
  *
9034
- * @example
9035
9204
  * ```ts
9036
- * // Title: Running a Successful Effect as a Promise
9037
9205
  * import { Effect } from "effect"
9038
9206
  *
9039
- * // Effect.runPromise(Effect.succeed(1)).then(console.log)
9207
+ * Effect.runPromise(Effect.succeed(1)).then(console.log)
9040
9208
  * // Output: 1
9041
9209
  * ```
9042
9210
  *
9043
- * @example
9044
- * //Example: Handling a Failing Effect as a Rejected Promise
9211
+ * **Example** (Handling a Failing Effect as a Rejected Promise)
9212
+ *
9213
+ * ```ts
9045
9214
  * import { Effect } from "effect"
9046
9215
  *
9047
- * // Effect.runPromise(Effect.fail("my error")).catch(console.error)
9216
+ * Effect.runPromise(Effect.fail("my error")).catch(console.error)
9048
9217
  * // Output:
9049
9218
  * // (FiberFailure) Error: my error
9219
+ * ```
9220
+ *
9221
+ * @see {@link runPromiseExit} for a version that returns an `Exit` type instead
9222
+ * of rejecting.
9050
9223
  *
9051
9224
  * @since 2.0.0
9052
9225
  * @category Running Effects
@@ -9077,13 +9250,13 @@ const runPromise = exports.runPromise = runtime_.unsafeRunPromiseEffect;
9077
9250
  * that rely on promises but need more detailed error handling than a simple
9078
9251
  * rejection.
9079
9252
  *
9080
- * @example
9253
+ * **Example** (Handling Results as Exit)
9254
+ *
9081
9255
  * ```ts
9082
- * // Title: Handling Results as Exit
9083
9256
  * import { Effect } from "effect"
9084
9257
  *
9085
9258
  * // Execute a successful effect and get the Exit result as a Promise
9086
- * // Effect.runPromiseExit(Effect.succeed(1)).then(console.log)
9259
+ * Effect.runPromiseExit(Effect.succeed(1)).then(console.log)
9087
9260
  * // Output:
9088
9261
  * // {
9089
9262
  * // _id: "Exit",
@@ -9092,7 +9265,7 @@ const runPromise = exports.runPromise = runtime_.unsafeRunPromiseEffect;
9092
9265
  * // }
9093
9266
  *
9094
9267
  * // Execute a failing effect and get the Exit result as a Promise
9095
- * // Effect.runPromiseExit(Effect.fail("my error")).then(console.log)
9268
+ * Effect.runPromiseExit(Effect.fail("my error")).then(console.log)
9096
9269
  * // Output:
9097
9270
  * // {
9098
9271
  * // _id: "Exit",
@@ -9139,12 +9312,9 @@ const runPromiseExit = exports.runPromiseExit = runtime_.unsafeRunPromiseExitEff
9139
9312
  * handling. For such cases, consider using {@link runPromise} or
9140
9313
  * {@link runSyncExit}.
9141
9314
  *
9142
- * @see {@link runSyncExit} for a version that returns an `Exit` type instead of
9143
- * throwing an error.
9315
+ * **Example** (Synchronous Logging)
9144
9316
  *
9145
- * @example
9146
9317
  * ```ts
9147
- * // Title: Synchronous Logging
9148
9318
  * import { Effect } from "effect"
9149
9319
  *
9150
9320
  * const program = Effect.sync(() => {
@@ -9159,8 +9329,9 @@ const runPromiseExit = exports.runPromiseExit = runtime_.unsafeRunPromiseExitEff
9159
9329
  * // Output: 1
9160
9330
  * ```
9161
9331
  *
9162
- * @example
9163
- * // Title: Incorrect Usage with Failing or Async Effects
9332
+ * **Example** (Incorrect Usage with Failing or Async Effects)
9333
+ *
9334
+ * ```ts
9164
9335
  * import { Effect } from "effect"
9165
9336
  *
9166
9337
  * try {
@@ -9180,6 +9351,10 @@ const runPromiseExit = exports.runPromiseExit = runtime_.unsafeRunPromiseExitEff
9180
9351
  * }
9181
9352
  * // Output:
9182
9353
  * // (FiberFailure) AsyncFiberException: Fiber #0 cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work
9354
+ * ```
9355
+ *
9356
+ * @see {@link runSyncExit} for a version that returns an `Exit` type instead of
9357
+ * throwing an error.
9183
9358
  *
9184
9359
  * @since 2.0.0
9185
9360
  * @category Running Effects
@@ -9210,9 +9385,9 @@ const runSync = exports.runSync = runtime_.unsafeRunSyncEffect;
9210
9385
  *
9211
9386
  * Avoid using this function for effects that involve asynchronous operations, as it will fail with a `Die` cause.
9212
9387
  *
9213
- * @example
9388
+ * **Example** (Handling Results as Exit)
9389
+ *
9214
9390
  * ```ts
9215
- * // Title: Handling Results as Exit
9216
9391
  * import { Effect } from "effect"
9217
9392
  *
9218
9393
  * console.log(Effect.runSyncExit(Effect.succeed(1)))
@@ -9236,8 +9411,9 @@ const runSync = exports.runSync = runtime_.unsafeRunSyncEffect;
9236
9411
  * // }
9237
9412
  * ```
9238
9413
  *
9239
- * @example
9240
- * // Title: Asynchronous Operation Resulting in Die
9414
+ * **Example** (Asynchronous Operation Resulting in Die)
9415
+ *
9416
+ * ```ts
9241
9417
  * import { Effect } from "effect"
9242
9418
  *
9243
9419
  * console.log(Effect.runSyncExit(Effect.promise(() => Promise.resolve(1))))
@@ -9255,6 +9431,7 @@ const runSync = exports.runSync = runtime_.unsafeRunSyncEffect;
9255
9431
  * // }
9256
9432
  * // }
9257
9433
  * // }
9434
+ * ```
9258
9435
  *
9259
9436
  * @since 2.0.0
9260
9437
  * @category Running Effects
@@ -9275,9 +9452,8 @@ const runSyncExit = exports.runSyncExit = runtime_.unsafeRunSyncExitEffect;
9275
9452
  * provides flexibility in scenarios where you want to maximize performance or
9276
9453
  * ensure specific ordering.
9277
9454
  *
9278
- * @see {@link zip} for a version that stops at the first error.
9455
+ * **Example**
9279
9456
  *
9280
- * @example
9281
9457
  * ```ts
9282
9458
  * import { Effect, Console } from "effect"
9283
9459
  *
@@ -9292,7 +9468,7 @@ const runSyncExit = exports.runSyncExit = runtime_.unsafeRunSyncExitEffect;
9292
9468
  * Effect.validate(task4)
9293
9469
  * )
9294
9470
  *
9295
- * // Effect.runPromiseExit(program).then(console.log)
9471
+ * Effect.runPromiseExit(program).then(console.log)
9296
9472
  * // Output:
9297
9473
  * // task1
9298
9474
  * // task2
@@ -9308,6 +9484,8 @@ const runSyncExit = exports.runSyncExit = runtime_.unsafeRunSyncExitEffect;
9308
9484
  * // }
9309
9485
  * ```
9310
9486
  *
9487
+ * @see {@link zip} for a version that stops at the first error.
9488
+ *
9311
9489
  * @since 2.0.0
9312
9490
  * @category Error Accumulation
9313
9491
  */
@@ -9347,13 +9525,9 @@ const validateWith = exports.validateWith = fiberRuntime.validateWith;
9347
9525
  * is set to `true`, the effects will run concurrently, potentially improving
9348
9526
  * performance for independent operations.
9349
9527
  *
9350
- * @see {@link zipWith} for a version that combines the results with a custom
9351
- * function.
9352
- * @see {@link validate} for a version that accumulates errors.
9528
+ * **Example** (Combining Two Effects Sequentially)
9353
9529
  *
9354
- * @example
9355
9530
  * ```ts
9356
- * // Title: Combining Two Effects Sequentially
9357
9531
  * import { Effect } from "effect"
9358
9532
  *
9359
9533
  * const task1 = Effect.succeed(1).pipe(
@@ -9371,15 +9545,16 @@ const validateWith = exports.validateWith = fiberRuntime.validateWith;
9371
9545
  * // ▼
9372
9546
  * const program = Effect.zip(task1, task2)
9373
9547
  *
9374
- * // Effect.runPromise(program).then(console.log)
9548
+ * Effect.runPromise(program).then(console.log)
9375
9549
  * // Output:
9376
9550
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
9377
9551
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
9378
9552
  * // [ 1, 'hello' ]
9379
9553
  * ```
9380
9554
  *
9381
- * @example
9382
- * // Title: Combining Two Effects Concurrently
9555
+ * **Example** (Combining Two Effects Concurrently)
9556
+ *
9557
+ * ```ts
9383
9558
  * import { Effect } from "effect"
9384
9559
  *
9385
9560
  * const task1 = Effect.succeed(1).pipe(
@@ -9394,11 +9569,16 @@ const validateWith = exports.validateWith = fiberRuntime.validateWith;
9394
9569
  * // Run both effects concurrently using the concurrent option
9395
9570
  * const program = Effect.zip(task1, task2, { concurrent: true })
9396
9571
  *
9397
- * // Effect.runPromise(program).then(console.log)
9572
+ * Effect.runPromise(program).then(console.log)
9398
9573
  * // Output:
9399
9574
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
9400
9575
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
9401
9576
  * // [ 1, 'hello' ]
9577
+ * ```
9578
+ *
9579
+ * @see {@link zipWith} for a version that combines the results with a custom
9580
+ * function.
9581
+ * @see {@link validate} for a version that accumulates errors.
9402
9582
  *
9403
9583
  * @since 2.0.0
9404
9584
  * @category Zipping
@@ -9425,10 +9605,8 @@ const zip = exports.zip = fiberRuntime.zipOptions;
9425
9605
  * effect but still need to run the second effect for its side effects, such as
9426
9606
  * logging or performing a cleanup action.
9427
9607
  *
9428
- * @see {@link zipRight} for a version that returns the result of the second
9429
- * effect.
9608
+ * **Example**
9430
9609
  *
9431
- * @example
9432
9610
  * ```ts
9433
9611
  * import { Effect } from "effect"
9434
9612
  *
@@ -9443,13 +9621,16 @@ const zip = exports.zip = fiberRuntime.zipOptions;
9443
9621
  *
9444
9622
  * const program = Effect.zipLeft(task1, task2)
9445
9623
  *
9446
- * // Effect.runPromise(program).then(console.log)
9624
+ * Effect.runPromise(program).then(console.log)
9447
9625
  * // Output:
9448
9626
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
9449
9627
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
9450
9628
  * // 1
9451
9629
  * ```
9452
9630
  *
9631
+ * @see {@link zipRight} for a version that returns the result of the second
9632
+ * effect.
9633
+ *
9453
9634
  * @since 2.0.0
9454
9635
  * @category Zipping
9455
9636
  */
@@ -9475,10 +9656,8 @@ const zipLeft = exports.zipLeft = fiberRuntime.zipLeftOptions;
9475
9656
  * effect but still need to run the first effect for its side effects, such as
9476
9657
  * initialization or setup tasks.
9477
9658
  *
9478
- * @see {@link zipLeft} for a version that returns the result of the first
9479
- * effect.
9659
+ * **Example**
9480
9660
  *
9481
- * @example
9482
9661
  * ```ts
9483
9662
  * import { Effect } from "effect"
9484
9663
  *
@@ -9493,13 +9672,16 @@ const zipLeft = exports.zipLeft = fiberRuntime.zipLeftOptions;
9493
9672
  *
9494
9673
  * const program = Effect.zipRight(task1, task2)
9495
9674
  *
9496
- * // Effect.runPromise(program).then(console.log)
9675
+ * Effect.runPromise(program).then(console.log)
9497
9676
  * // Output:
9498
9677
  * // timestamp=... level=INFO fiber=#0 message="task1 done"
9499
9678
  * // timestamp=... level=INFO fiber=#0 message="task2 done"
9500
9679
  * // hello
9501
9680
  * ```
9502
9681
  *
9682
+ * @see {@link zipLeft} for a version that returns the result of the first
9683
+ * effect.
9684
+ *
9503
9685
  * @since 2.0.0
9504
9686
  * @category Zipping
9505
9687
  */
@@ -9516,9 +9698,9 @@ const zipRight = exports.zipRight = fiberRuntime.zipRightOptions;
9516
9698
  * this function processes the results with a custom function to produce a
9517
9699
  * single output.
9518
9700
  *
9519
- * @example
9701
+ * **Example** (Combining Effects with a Custom Function)
9702
+ *
9520
9703
  * ```ts
9521
- * // Title: Combining Effects with a Custom Function
9522
9704
  * import { Effect } from "effect"
9523
9705
  *
9524
9706
  * const task1 = Effect.succeed(1).pipe(
@@ -9537,7 +9719,7 @@ const zipRight = exports.zipRight = fiberRuntime.zipRightOptions;
9537
9719
  * (number, string) => number + string.length
9538
9720
  * )
9539
9721
  *
9540
- * // Effect.runPromise(task3).then(console.log)
9722
+ * Effect.runPromise(task3).then(console.log)
9541
9723
  * // Output:
9542
9724
  * // timestamp=... level=INFO fiber=#3 message="task1 done"
9543
9725
  * // timestamp=... level=INFO fiber=#2 message="task2 done"
@@ -9625,9 +9807,8 @@ const withTracerScoped = exports.withTracerScoped = fiberRuntime.withTracerScope
9625
9807
  /**
9626
9808
  * Disable the tracer for the given Effect.
9627
9809
  *
9628
- * @since 2.0.0
9629
- * @category Tracing
9630
- * @example
9810
+ * **Example**
9811
+ *
9631
9812
  * ```ts
9632
9813
  * import { Effect } from "effect"
9633
9814
  *
@@ -9637,6 +9818,9 @@ const withTracerScoped = exports.withTracerScoped = fiberRuntime.withTracerScope
9637
9818
  * Effect.withTracerEnabled(false)
9638
9819
  * )
9639
9820
  * ```
9821
+ *
9822
+ * @since 2.0.0
9823
+ * @category Tracing
9640
9824
  */
9641
9825
  const withTracerEnabled = exports.withTracerEnabled = core.withTracerEnabled;
9642
9826
  /**
@@ -9747,9 +9931,8 @@ const withSpan = exports.withSpan = effect.withSpan;
9747
9931
  /**
9748
9932
  * Wraps a function that returns an effect with a new span for tracing.
9749
9933
  *
9750
- * @since 3.2.0
9751
- * @category Tracing
9752
- * @example
9934
+ * **Example**
9935
+ *
9753
9936
  * ```ts
9754
9937
  * import { Effect } from "effect"
9755
9938
  *
@@ -9761,6 +9944,9 @@ const withSpan = exports.withSpan = effect.withSpan;
9761
9944
  * })
9762
9945
  * })
9763
9946
  * ```
9947
+ *
9948
+ * @since 3.2.0
9949
+ * @category Tracing
9764
9950
  */
9765
9951
  const functionWithSpan = exports.functionWithSpan = effect.functionWithSpan;
9766
9952
  /**
@@ -9802,7 +9988,8 @@ const withParentSpan = exports.withParentSpan = effect.withParentSpan;
9802
9988
  * and you want to ensure that only non-null values are processed. It helps
9803
9989
  * enforce null-safety and makes error handling more explicit.
9804
9990
  *
9805
- * @example
9991
+ * **Example**
9992
+ *
9806
9993
  * ```ts
9807
9994
  * import { Effect } from "effect"
9808
9995
  *
@@ -9810,7 +9997,7 @@ const withParentSpan = exports.withParentSpan = effect.withParentSpan;
9810
9997
  * // ▼
9811
9998
  * const maybe1 = Effect.fromNullable(1)
9812
9999
  *
9813
- * // Effect.runPromiseExit(maybe1).then(console.log)
10000
+ * Effect.runPromiseExit(maybe1).then(console.log)
9814
10001
  * // Output:
9815
10002
  * // { _id: 'Exit', _tag: 'Success', value: 1 }
9816
10003
  *
@@ -9818,7 +10005,7 @@ const withParentSpan = exports.withParentSpan = effect.withParentSpan;
9818
10005
  * // ▼
9819
10006
  * const maybe2 = Effect.fromNullable(null as number | null)
9820
10007
  *
9821
- * // Effect.runPromiseExit(maybe2).then(console.log)
10008
+ * Effect.runPromiseExit(maybe2).then(console.log)
9822
10009
  * // Output:
9823
10010
  * // {
9824
10011
  * // _id: 'Exit',
@@ -9858,7 +10045,8 @@ const fromNullable = exports.fromNullable = effect.fromNullable;
9858
10045
  * It’s ideal for scenarios where you want to explicitly represent optionality
9859
10046
  * in a type-safe way while retaining other failure information.
9860
10047
  *
9861
- * @example
10048
+ * **Example**
10049
+ *
9862
10050
  * ```ts
9863
10051
  * import { Effect } from "effect"
9864
10052
  *
@@ -9870,7 +10058,7 @@ const fromNullable = exports.fromNullable = effect.fromNullable;
9870
10058
  * // ▼
9871
10059
  * const option1 = Effect.optionFromOptional(maybe1)
9872
10060
  *
9873
- * // Effect.runPromise(option1).then(console.log)
10061
+ * Effect.runPromise(option1).then(console.log)
9874
10062
  * // Output: { _id: 'Option', _tag: 'Some', value: 1 }
9875
10063
  *
9876
10064
  * // ┌─── Effect<number, NoSuchElementException, never>
@@ -9881,7 +10069,7 @@ const fromNullable = exports.fromNullable = effect.fromNullable;
9881
10069
  * // ▼
9882
10070
  * const option2 = Effect.optionFromOptional(maybe2)
9883
10071
  *
9884
- * // Effect.runPromise(option2).then(console.log)
10072
+ * Effect.runPromise(option2).then(console.log)
9885
10073
  * // Output: { _tag: 'None' }
9886
10074
  * ```
9887
10075
  *
@@ -9899,7 +10087,8 @@ const optionFromOptional = exports.optionFromOptional = effect.optionFromOptiona
9899
10087
  * will immediately succeed with a `None` value. If the `Option` is `Some`, the
9900
10088
  * inner `Effect` will be executed, and its result wrapped in a `Some`.
9901
10089
  *
9902
- * @example
10090
+ * **Example**
10091
+ *
9903
10092
  * ```ts
9904
10093
  * import { Effect, Option } from "effect"
9905
10094
  *
@@ -9964,7 +10153,8 @@ const makeTagProxy = TagClass => {
9964
10153
  * method) are turned into static properties of the Notifications class, making
9965
10154
  * it easier to access them.
9966
10155
  *
9967
- * @example
10156
+ * **Example**
10157
+ *
9968
10158
  * ```ts
9969
10159
  * import { Effect } from "effect"
9970
10160
  *
@@ -10017,7 +10207,8 @@ const Tag = id => () => {
10017
10207
  * provided automatically when the service is used. Accessors can be optionally
10018
10208
  * generated for the service, making it more convenient to use.
10019
10209
  *
10020
- * @example
10210
+ * **Example**
10211
+ *
10021
10212
  * ```ts
10022
10213
  * import { Effect } from 'effect';
10023
10214
  *