effect 3.11.1 → 3.11.3

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 (56) hide show
  1. package/dist/cjs/Arbitrary.js +18 -8
  2. package/dist/cjs/Arbitrary.js.map +1 -1
  3. package/dist/cjs/BigDecimal.js +4 -0
  4. package/dist/cjs/BigDecimal.js.map +1 -1
  5. package/dist/cjs/Context.js +47 -6
  6. package/dist/cjs/Context.js.map +1 -1
  7. package/dist/cjs/Effect.js +25 -5
  8. package/dist/cjs/Effect.js.map +1 -1
  9. package/dist/cjs/JSONSchema.js +1 -0
  10. package/dist/cjs/JSONSchema.js.map +1 -1
  11. package/dist/cjs/Micro.js +108 -90
  12. package/dist/cjs/Micro.js.map +1 -1
  13. package/dist/cjs/Schema.js +75 -42
  14. package/dist/cjs/Schema.js.map +1 -1
  15. package/dist/cjs/SchemaAST.js +91 -22
  16. package/dist/cjs/SchemaAST.js.map +1 -1
  17. package/dist/cjs/internal/version.js +1 -1
  18. package/dist/dts/BigDecimal.d.ts +4 -0
  19. package/dist/dts/BigDecimal.d.ts.map +1 -1
  20. package/dist/dts/Context.d.ts +47 -6
  21. package/dist/dts/Context.d.ts.map +1 -1
  22. package/dist/dts/Effect.d.ts +25 -5
  23. package/dist/dts/Effect.d.ts.map +1 -1
  24. package/dist/dts/Micro.d.ts +164 -131
  25. package/dist/dts/Micro.d.ts.map +1 -1
  26. package/dist/dts/Schema.d.ts +10 -5
  27. package/dist/dts/Schema.d.ts.map +1 -1
  28. package/dist/dts/SchemaAST.d.ts +9 -4
  29. package/dist/dts/SchemaAST.d.ts.map +1 -1
  30. package/dist/esm/Arbitrary.js +18 -8
  31. package/dist/esm/Arbitrary.js.map +1 -1
  32. package/dist/esm/BigDecimal.js +4 -0
  33. package/dist/esm/BigDecimal.js.map +1 -1
  34. package/dist/esm/Context.js +47 -6
  35. package/dist/esm/Context.js.map +1 -1
  36. package/dist/esm/Effect.js +25 -5
  37. package/dist/esm/Effect.js.map +1 -1
  38. package/dist/esm/JSONSchema.js +1 -0
  39. package/dist/esm/JSONSchema.js.map +1 -1
  40. package/dist/esm/Micro.js +108 -90
  41. package/dist/esm/Micro.js.map +1 -1
  42. package/dist/esm/Schema.js +74 -41
  43. package/dist/esm/Schema.js.map +1 -1
  44. package/dist/esm/SchemaAST.js +88 -20
  45. package/dist/esm/SchemaAST.js.map +1 -1
  46. package/dist/esm/internal/version.js +1 -1
  47. package/package.json +1 -1
  48. package/src/Arbitrary.ts +21 -7
  49. package/src/BigDecimal.ts +4 -0
  50. package/src/Context.ts +47 -6
  51. package/src/Effect.ts +25 -5
  52. package/src/JSONSchema.ts +1 -0
  53. package/src/Micro.ts +217 -183
  54. package/src/Schema.ts +105 -83
  55. package/src/SchemaAST.ts +107 -31
  56. package/src/internal/version.ts +1 -1
package/src/Micro.ts CHANGED
@@ -169,7 +169,15 @@ export const MicroCauseTypeId = Symbol.for("effect/Micro/MicroCause")
169
169
  export type MicroCauseTypeId = typeof MicroCauseTypeId
170
170
 
171
171
  /**
172
- * A Micro Cause is a data type that represents the different ways a Micro can fail.
172
+ * A `MicroCause` is a data type that represents the different ways a `Micro` can fail.
173
+ *
174
+ * **Details**
175
+ *
176
+ * `MicroCause` comes in three forms:
177
+ *
178
+ * - `Die`: Indicates an unforeseen defect that wasn't planned for in the system's logic.
179
+ * - `Fail`: Covers anticipated errors that are recognized and typically handled within the application.
180
+ * - `Interrupt`: Signifies an operation that has been purposefully stopped.
173
181
  *
174
182
  * @since 3.4.6
175
183
  * @experimental
@@ -290,7 +298,7 @@ abstract class MicroCauseImpl<Tag extends string, E> extends globalThis.Error im
290
298
  }
291
299
  }
292
300
 
293
- class FailImpl<E> extends MicroCauseImpl<"Fail", E> implements MicroCause.Fail<E> {
301
+ class Fail<E> extends MicroCauseImpl<"Fail", E> implements MicroCause.Fail<E> {
294
302
  constructor(
295
303
  readonly error: E,
296
304
  traces: ReadonlyArray<string> = []
@@ -307,9 +315,9 @@ class FailImpl<E> extends MicroCauseImpl<"Fail", E> implements MicroCause.Fail<E
307
315
  export const causeFail = <E>(
308
316
  error: E,
309
317
  traces: ReadonlyArray<string> = []
310
- ): MicroCause<E> => new FailImpl(error, traces)
318
+ ): MicroCause<E> => new Fail(error, traces)
311
319
 
312
- class DieImpl extends MicroCauseImpl<"Die", never> implements MicroCause.Die {
320
+ class Die extends MicroCauseImpl<"Die", never> implements MicroCause.Die {
313
321
  constructor(
314
322
  readonly defect: unknown,
315
323
  traces: ReadonlyArray<string> = []
@@ -326,9 +334,9 @@ class DieImpl extends MicroCauseImpl<"Die", never> implements MicroCause.Die {
326
334
  export const causeDie = (
327
335
  defect: unknown,
328
336
  traces: ReadonlyArray<string> = []
329
- ): MicroCause<never> => new DieImpl(defect, traces)
337
+ ): MicroCause<never> => new Die(defect, traces)
330
338
 
331
- class InterruptImpl extends MicroCauseImpl<"Interrupt", never> implements MicroCause.Interrupt {
339
+ class Interrupt extends MicroCauseImpl<"Interrupt", never> implements MicroCause.Interrupt {
332
340
  constructor(traces: ReadonlyArray<string> = []) {
333
341
  super("Interrupt", "interrupted", traces)
334
342
  }
@@ -341,7 +349,7 @@ class InterruptImpl extends MicroCauseImpl<"Interrupt", never> implements MicroC
341
349
  */
342
350
  export const causeInterrupt = (
343
351
  traces: ReadonlyArray<string> = []
344
- ): MicroCause<never> => new InterruptImpl(traces)
352
+ ): MicroCause<never> => new Interrupt(traces)
345
353
 
346
354
  /**
347
355
  * @since 3.4.6
@@ -407,30 +415,30 @@ export const causeWithTrace: {
407
415
  })
408
416
 
409
417
  // ----------------------------------------------------------------------------
410
- // Fiber
418
+ // MicroFiber
411
419
  // ----------------------------------------------------------------------------
412
420
 
413
421
  /**
414
422
  * @since 3.11.0
415
423
  * @experimental
416
- * @category Fiber
424
+ * @category MicroFiber
417
425
  */
418
- export const FiberTypeId = Symbol.for("effect/Micro/Fiber")
426
+ export const MicroFiberTypeId = Symbol.for("effect/Micro/MicroFiber")
419
427
 
420
428
  /**
421
429
  * @since 3.11.0
422
430
  * @experimental
423
- * @category Fiber
431
+ * @category MicroFiber
424
432
  */
425
- export type FiberTypeId = typeof FiberTypeId
433
+ export type MicroFiberTypeId = typeof MicroFiberTypeId
426
434
 
427
435
  /**
428
436
  * @since 3.11.0
429
437
  * @experimental
430
- * @category Fiber
438
+ * @category MicroFiber
431
439
  */
432
- export interface Fiber<out A, out E = never> {
433
- readonly [FiberTypeId]: Fiber.Variance<A, E>
440
+ export interface MicroFiber<out A, out E = never> {
441
+ readonly [MicroFiberTypeId]: MicroFiber.Variance<A, E>
434
442
 
435
443
  readonly currentOpCount: number
436
444
  readonly getRef: <I, A>(ref: Context.Reference<I, A>) => A
@@ -443,13 +451,13 @@ export interface Fiber<out A, out E = never> {
443
451
  /**
444
452
  * @since 3.11.0
445
453
  * @experimental
446
- * @category Fiber
454
+ * @category MicroFiber
447
455
  */
448
- export declare namespace Fiber {
456
+ export declare namespace MicroFiber {
449
457
  /**
450
458
  * @since 3.11.0
451
459
  * @experimental
452
- * @category Fiber
460
+ * @category MicroFiber
453
461
  */
454
462
  export interface Variance<out A, out E = never> {
455
463
  readonly _A: Covariant<A>
@@ -462,13 +470,13 @@ const fiberVariance = {
462
470
  _E: identity
463
471
  }
464
472
 
465
- class FiberImpl<in out A = any, in out E = any> implements Fiber<A, E> {
466
- readonly [FiberTypeId]: Fiber.Variance<A, E>
473
+ class MicroFiberImpl<in out A = any, in out E = any> implements MicroFiber<A, E> {
474
+ readonly [MicroFiberTypeId]: MicroFiber.Variance<A, E>
467
475
 
468
476
  readonly _stack: Array<Primitive> = []
469
477
  readonly _observers: Array<(exit: MicroExit<A, E>) => void> = []
470
478
  _exit: MicroExit<A, E> | undefined
471
- public _children: Set<FiberImpl<any, any>> | undefined
479
+ public _children: Set<MicroFiberImpl<any, any>> | undefined
472
480
 
473
481
  public currentOpCount = 0
474
482
 
@@ -476,7 +484,7 @@ class FiberImpl<in out A = any, in out E = any> implements Fiber<A, E> {
476
484
  public context: Context.Context<never>,
477
485
  public interruptible = true
478
486
  ) {
479
- this[FiberTypeId] = fiberVariance
487
+ this[MicroFiberTypeId] = fiberVariance
480
488
  }
481
489
 
482
490
  getRef<I, A>(ref: Context.Reference<I, A>): A {
@@ -563,7 +571,7 @@ class FiberImpl<in out A = any, in out E = any> implements Fiber<A, E> {
563
571
  }
564
572
  } catch (error) {
565
573
  if (!hasProperty(current, evaluate)) {
566
- return exitDie(`Micro/Fiber.runLoop: Not a valid effect: ${String(current)}`)
574
+ return exitDie(`MicroFiber.runLoop: Not a valid effect: ${String(current)}`)
567
575
  }
568
576
  return exitDie(error)
569
577
  }
@@ -571,7 +579,7 @@ class FiberImpl<in out A = any, in out E = any> implements Fiber<A, E> {
571
579
 
572
580
  getCont<S extends successCont | failureCont>(
573
581
  symbol: S
574
- ): Primitive & Record<S, (value: any, fiber: FiberImpl) => Primitive> | undefined {
582
+ ): Primitive & Record<S, (value: any, fiber: MicroFiberImpl) => Primitive> | undefined {
575
583
  while (true) {
576
584
  const op = this._stack.pop()
577
585
  if (!op) return undefined
@@ -588,16 +596,16 @@ class FiberImpl<in out A = any, in out E = any> implements Fiber<A, E> {
588
596
  return Yield
589
597
  }
590
598
 
591
- children(): Set<Fiber<any, any>> {
599
+ children(): Set<MicroFiber<any, any>> {
592
600
  return this._children ??= new Set()
593
601
  }
594
602
  }
595
603
 
596
604
  const fiberMiddleware = globalValue("effect/Micro/fiberMiddleware", () => ({
597
- interruptChildren: undefined as ((fiber: FiberImpl) => Micro<void> | undefined) | undefined
605
+ interruptChildren: undefined as ((fiber: MicroFiberImpl) => Micro<void> | undefined) | undefined
598
606
  }))
599
607
 
600
- const fiberInterruptChildren = (fiber: FiberImpl) => {
608
+ const fiberInterruptChildren = (fiber: MicroFiberImpl) => {
601
609
  if (fiber._children === undefined || fiber._children.size === 0) {
602
610
  return undefined
603
611
  }
@@ -607,17 +615,24 @@ const fiberInterruptChildren = (fiber: FiberImpl) => {
607
615
  /**
608
616
  * @since 3.11.0
609
617
  * @experimental
610
- * @category Fiber
618
+ * @category MicroFiber
611
619
  */
612
- export const fiberAwait = <A, E>(self: Fiber<A, E>): Micro<MicroExit<A, E>> =>
620
+ export const fiberAwait = <A, E>(self: MicroFiber<A, E>): Micro<MicroExit<A, E>> =>
613
621
  async((resume) => sync(self.addObserver((exit) => resume(succeed(exit)))))
614
622
 
623
+ /**
624
+ * @since 3.11.2
625
+ * @experimental
626
+ * @category MicroFiber
627
+ */
628
+ export const fiberJoin = <A, E>(self: MicroFiber<A, E>): Micro<A, E> => flatten(fiberAwait(self))
629
+
615
630
  /**
616
631
  * @since 3.11.0
617
632
  * @experimental
618
- * @category Fiber
633
+ * @category MicroFiber
619
634
  */
620
- export const fiberInterrupt = <A, E>(self: Fiber<A, E>): Micro<void> =>
635
+ export const fiberInterrupt = <A, E>(self: MicroFiber<A, E>): Micro<void> =>
621
636
  suspend(() => {
622
637
  self.unsafeInterrupt()
623
638
  return asVoid(fiberAwait(self))
@@ -626,9 +641,9 @@ export const fiberInterrupt = <A, E>(self: Fiber<A, E>): Micro<void> =>
626
641
  /**
627
642
  * @since 3.11.0
628
643
  * @experimental
629
- * @category Fiber
644
+ * @category MicroFiber
630
645
  */
631
- export const fiberInterruptAll = <A extends Iterable<Fiber<any, any>>>(fibers: A): Micro<void> =>
646
+ export const fiberInterruptAll = <A extends Iterable<MicroFiber<any, any>>>(fibers: A): Micro<void> =>
632
647
  suspend(() => {
633
648
  for (const fiber of fibers) fiber.unsafeInterrupt()
634
649
  const iter = fibers[Symbol.iterator]()
@@ -674,16 +689,16 @@ type Yield = typeof Yield
674
689
 
675
690
  interface Primitive {
676
691
  readonly [identifier]: string
677
- readonly [successCont]: ((value: unknown, fiber: FiberImpl) => Primitive | Yield) | undefined
692
+ readonly [successCont]: ((value: unknown, fiber: MicroFiberImpl) => Primitive | Yield) | undefined
678
693
  readonly [failureCont]:
679
- | ((cause: MicroCause<unknown>, fiber: FiberImpl) => Primitive | Yield)
694
+ | ((cause: MicroCause<unknown>, fiber: MicroFiberImpl) => Primitive | Yield)
680
695
  | undefined
681
696
  readonly [ensureCont]:
682
- | ((fiber: FiberImpl) =>
683
- | ((value: unknown, fiber: FiberImpl) => Primitive | Yield)
697
+ | ((fiber: MicroFiberImpl) =>
698
+ | ((value: unknown, fiber: MicroFiberImpl) => Primitive | Yield)
684
699
  | undefined)
685
700
  | undefined
686
- [evaluate](fiber: FiberImpl): Primitive | Yield
701
+ [evaluate](fiber: MicroFiberImpl): Primitive | Yield
687
702
  }
688
703
 
689
704
  const microVariance = {
@@ -704,7 +719,7 @@ const MicroProto = {
704
719
  },
705
720
  toJSON(this: Primitive) {
706
721
  return {
707
- _id: "effect/Micro",
722
+ _id: "Micro",
708
723
  op: this[identifier],
709
724
  ...(args in this ? { args: this[args] } : undefined)
710
725
  }
@@ -717,20 +732,20 @@ const MicroProto = {
717
732
  }
718
733
  }
719
734
 
720
- function defaultEvaluate(_fiber: FiberImpl): Primitive | Yield {
735
+ function defaultEvaluate(_fiber: MicroFiberImpl): Primitive | Yield {
721
736
  return exitDie(`Micro.evaluate: Not implemented`) as any
722
737
  }
723
738
 
724
739
  const makePrimitiveProto = <Op extends string>(options: {
725
740
  readonly op: Op
726
- readonly eval?: (fiber: FiberImpl) => Primitive | Micro<any, any, any> | Yield
727
- readonly contA?: (this: Primitive, value: any, fiber: FiberImpl) => Primitive | Micro<any, any, any> | Yield
741
+ readonly eval?: (fiber: MicroFiberImpl) => Primitive | Micro<any, any, any> | Yield
742
+ readonly contA?: (this: Primitive, value: any, fiber: MicroFiberImpl) => Primitive | Micro<any, any, any> | Yield
728
743
  readonly contE?: (
729
744
  this: Primitive,
730
745
  cause: MicroCause<any>,
731
- fiber: FiberImpl
746
+ fiber: MicroFiberImpl
732
747
  ) => Primitive | Micro<any, any, any> | Yield
733
- readonly ensure?: (this: Primitive, fiber: FiberImpl) => void | ((value: any, fiber: FiberImpl) => void)
748
+ readonly ensure?: (this: Primitive, fiber: MicroFiberImpl) => void | ((value: any, fiber: MicroFiberImpl) => void)
734
749
  }): Primitive => ({
735
750
  ...MicroProto,
736
751
  [identifier]: options.op,
@@ -745,22 +760,22 @@ const makePrimitive = <Fn extends (...args: Array<any>) => any, Single extends b
745
760
  readonly single?: Single
746
761
  readonly eval?: (
747
762
  this: Primitive & { readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn> },
748
- fiber: FiberImpl
763
+ fiber: MicroFiberImpl
749
764
  ) => Primitive | Micro<any, any, any> | Yield
750
765
  readonly contA?: (
751
766
  this: Primitive & { readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn> },
752
767
  value: any,
753
- fiber: FiberImpl
768
+ fiber: MicroFiberImpl
754
769
  ) => Primitive | Micro<any, any, any> | Yield
755
770
  readonly contE?: (
756
771
  this: Primitive & { readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn> },
757
772
  cause: MicroCause<any>,
758
- fiber: FiberImpl
773
+ fiber: MicroFiberImpl
759
774
  ) => Primitive | Micro<any, any, any> | Yield
760
775
  readonly ensure?: (
761
776
  this: Primitive & { readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn> },
762
- fiber: FiberImpl
763
- ) => void | ((value: any, fiber: FiberImpl) => void)
777
+ fiber: MicroFiberImpl
778
+ ) => void | ((value: any, fiber: MicroFiberImpl) => void)
764
779
  }): Fn => {
765
780
  const Proto = makePrimitiveProto(options as any)
766
781
  return function() {
@@ -777,7 +792,7 @@ const makeExit = <Fn extends (...args: Array<any>) => any, Prop extends string>(
777
792
  this:
778
793
  & MicroExit<unknown, unknown>
779
794
  & { [args]: Parameters<Fn>[0] },
780
- fiber: FiberImpl<unknown, unknown>
795
+ fiber: MicroFiberImpl<unknown, unknown>
781
796
  ) => Primitive | Yield
782
797
  }): Fn => {
783
798
  const Proto = {
@@ -789,7 +804,7 @@ const makeExit = <Fn extends (...args: Array<any>) => any, Prop extends string>(
789
804
  },
790
805
  toJSON(this: any) {
791
806
  return {
792
- _id: "effect/Micro/Exit",
807
+ _id: "MicroExit",
793
808
  _tag: options.op,
794
809
  [options.prop]: this[args]
795
810
  }
@@ -848,10 +863,10 @@ export const failCause: <E>(cause: MicroCause<E>) => Micro<never, E> = makeExit(
848
863
  })
849
864
 
850
865
  /**
851
- * Creates a `Micro` effect that will fail with the specified error.
866
+ * Creates a `Micro` effect that fails with the given error.
852
867
  *
853
- * This will result in a `CauseFail`, where the error is tracked at the
854
- * type level.
868
+ * This results in a `Fail` variant of the `MicroCause` type, where the error is
869
+ * tracked at the type level.
855
870
  *
856
871
  * @since 3.4.0
857
872
  * @experimental
@@ -860,10 +875,10 @@ export const failCause: <E>(cause: MicroCause<E>) => Micro<never, E> = makeExit(
860
875
  export const fail = <E>(error: E): Micro<never, E> => failCause(causeFail(error))
861
876
 
862
877
  /**
863
- * Creates a `Micro` effect that will succeed with the lazily evaluated value.
878
+ * Creates a `Micro` effect that succeeds with a lazily evaluated value.
864
879
  *
865
- * If the evaluation of the value throws an error, the effect will fail with
866
- * `CauseDie`.
880
+ * If the evaluation of the value throws an error, the effect will fail with a
881
+ * `Die` variant of the `MicroCause` type.
867
882
  *
868
883
  * @since 3.4.0
869
884
  * @experimental
@@ -925,7 +940,7 @@ export const yieldNowWith: (priority?: number) => Micro<void> = makePrimitive({
925
940
  export const yieldNow: Micro<void> = yieldNowWith(0)
926
941
 
927
942
  /**
928
- * Creates a `Micro` effect that will succeed with `Option.Some` of the value.
943
+ * Creates a `Micro` effect that will succeed with the value wrapped in `Some`.
929
944
  *
930
945
  * @since 3.4.0
931
946
  * @experimental
@@ -934,7 +949,7 @@ export const yieldNow: Micro<void> = yieldNowWith(0)
934
949
  export const succeedSome = <A>(a: A): Micro<Option.Option<A>> => succeed(Option.some(a))
935
950
 
936
951
  /**
937
- * Creates a `Micro` effect that will succeed with `Option.None`.
952
+ * Creates a `Micro` effect that succeeds with `None`.
938
953
  *
939
954
  * @since 3.4.0
940
955
  * @experimental
@@ -955,8 +970,8 @@ export const failCauseSync = <E>(evaluate: LazyArg<MicroCause<E>>): Micro<never,
955
970
  /**
956
971
  * Creates a `Micro` effect that will die with the specified error.
957
972
  *
958
- * This will result in a `CauseDie`, where the error is not tracked at
959
- * the type level.
973
+ * This results in a `Die` variant of the `MicroCause` type, where the error is
974
+ * not tracked at the type level.
960
975
  *
961
976
  * @since 3.4.0
962
977
  * @experimental
@@ -967,8 +982,8 @@ export const die = (defect: unknown): Micro<never> => exitDie(defect)
967
982
  /**
968
983
  * Creates a `Micro` effect that will fail with the lazily evaluated error.
969
984
  *
970
- * This will result in a `CauseFail`, where the error is tracked at the
971
- * type level.
985
+ * This results in a `Fail` variant of the `MicroCause` type, where the error is
986
+ * tracked at the type level.
972
987
  *
973
988
  * @since 3.4.6
974
989
  * @experimental
@@ -1028,9 +1043,6 @@ export {
1028
1043
  * The `Micro` equivalent of a try / catch block, which allows you to map
1029
1044
  * thrown errors to a specific error type.
1030
1045
  *
1031
- * @since 3.4.0
1032
- * @experimental
1033
- * @category constructors
1034
1046
  * @example
1035
1047
  * ```ts
1036
1048
  * import { Micro } from "effect"
@@ -1040,13 +1052,19 @@ export {
1040
1052
  * catch: (cause) => new Error("caught", { cause })
1041
1053
  * })
1042
1054
  * ```
1055
+ *
1056
+ * @since 3.4.0
1057
+ * @experimental
1058
+ * @category constructors
1043
1059
  */
1044
1060
  try_ as try
1045
1061
  }
1046
1062
 
1047
1063
  /**
1048
- * Wrap a `Promise` into a `Micro` effect. Any errors will result in a
1049
- * `CauseDie`.
1064
+ * Wrap a `Promise` into a `Micro` effect.
1065
+ *
1066
+ * Any errors will result in a `Die` variant of the `MicroCause` type, where the
1067
+ * error is not tracked at the type level.
1050
1068
  *
1051
1069
  * @since 3.4.0
1052
1070
  * @experimental
@@ -1064,9 +1082,6 @@ export const promise = <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>): M
1064
1082
  * Wrap a `Promise` into a `Micro` effect. Any errors will be caught and
1065
1083
  * converted into a specific error type.
1066
1084
  *
1067
- * @since 3.4.0
1068
- * @experimental
1069
- * @category constructors
1070
1085
  * @example
1071
1086
  * ```ts
1072
1087
  * import { Micro } from "effect"
@@ -1076,6 +1091,10 @@ export const promise = <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>): M
1076
1091
  * catch: (cause) => new Error("caught", { cause })
1077
1092
  * })
1078
1093
  * ```
1094
+ *
1095
+ * @since 3.4.0
1096
+ * @experimental
1097
+ * @category constructors
1079
1098
  */
1080
1099
  export const tryPromise = <A, E>(options: {
1081
1100
  readonly try: (signal: AbortSignal) => PromiseLike<A>
@@ -1093,16 +1112,16 @@ export const tryPromise = <A, E>(options: {
1093
1112
  }, options.try.length !== 0)
1094
1113
 
1095
1114
  /**
1096
- * Create a `Micro` effect using the current `Fiber`.
1115
+ * Create a `Micro` effect using the current `MicroFiber`.
1097
1116
  *
1098
1117
  * @since 3.4.0
1099
1118
  * @experimental
1100
1119
  * @category constructors
1101
1120
  */
1102
- export const withFiber: <A, E = never, R = never>(
1103
- evaluate: (fiber: FiberImpl<A, E>) => Micro<A, E, R>
1121
+ export const withMicroFiber: <A, E = never, R = never>(
1122
+ evaluate: (fiber: MicroFiberImpl<A, E>) => Micro<A, E, R>
1104
1123
  ) => Micro<A, E, R> = makePrimitive({
1105
- op: "WithFiber",
1124
+ op: "WithMicroFiber",
1106
1125
  eval(fiber) {
1107
1126
  return this[args](fiber)
1108
1127
  }
@@ -1115,7 +1134,7 @@ export const withFiber: <A, E = never, R = never>(
1115
1134
  * @experimental
1116
1135
  * @category constructors
1117
1136
  */
1118
- export const yieldFlush: Micro<void> = withFiber((fiber) => {
1137
+ export const yieldFlush: Micro<void> = withMicroFiber((fiber) => {
1119
1138
  fiber.getRef(CurrentScheduler).flush()
1120
1139
  return exitVoid
1121
1140
  })
@@ -1230,7 +1249,7 @@ const fromIterator: (
1230
1249
  fiber._stack.push(this)
1231
1250
  return yieldWrapGet(state.value)
1232
1251
  },
1233
- eval(this: any, fiber: FiberImpl) {
1252
+ eval(this: any, fiber: MicroFiberImpl) {
1234
1253
  return this[successCont](undefined, fiber)
1235
1254
  }
1236
1255
  })
@@ -1277,7 +1296,7 @@ export const as: {
1277
1296
  } = dual(2, <A, E, R, B>(self: Micro<A, E, R>, value: B): Micro<B, E, R> => map(self, (_) => value))
1278
1297
 
1279
1298
  /**
1280
- * Wrap the success value of this `Micro` effect in an `Option.Some`.
1299
+ * Wrap the success value of this `Micro` effect in a `Some`.
1281
1300
  *
1282
1301
  * @since 3.4.0
1283
1302
  * @experimental
@@ -1299,11 +1318,11 @@ export const flip = <A, E, R>(self: Micro<A, E, R>): Micro<E, A, R> =>
1299
1318
  })
1300
1319
 
1301
1320
  /**
1302
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1303
- * a single api.
1321
+ * A more flexible version of `flatMap` that combines `map` and `flatMap` into a
1322
+ * single API.
1304
1323
  *
1305
- * It also allows you to pass in a `Micro` effect directly, which will be
1306
- * executed after the current effect.
1324
+ * It also lets you directly pass a `Micro` effect, which will be executed after
1325
+ * the current effect.
1307
1326
  *
1308
1327
  * @since 3.4.0
1309
1328
  * @experimental
@@ -1311,11 +1330,11 @@ export const flip = <A, E, R>(self: Micro<A, E, R>): Micro<E, A, R> =>
1311
1330
  */
1312
1331
  export const andThen: {
1313
1332
  /**
1314
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1315
- * a single api.
1333
+ * A more flexible version of `flatMap` that combines `map` and `flatMap` into a
1334
+ * single API.
1316
1335
  *
1317
- * It also allows you to pass in a `Micro` effect directly, which will be
1318
- * executed after the current effect.
1336
+ * It also lets you directly pass a `Micro` effect, which will be executed after
1337
+ * the current effect.
1319
1338
  *
1320
1339
  * @since 3.4.0
1321
1340
  * @experimental
@@ -1326,11 +1345,11 @@ export const andThen: {
1326
1345
  ) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1>
1327
1346
  : Micro<X, E, R>
1328
1347
  /**
1329
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1330
- * a single api.
1348
+ * A more flexible version of `flatMap` that combines `map` and `flatMap` into a
1349
+ * single API.
1331
1350
  *
1332
- * It also allows you to pass in a `Micro` effect directly, which will be
1333
- * executed after the current effect.
1351
+ * It also lets you directly pass a `Micro` effect, which will be executed after
1352
+ * the current effect.
1334
1353
  *
1335
1354
  * @since 3.4.0
1336
1355
  * @experimental
@@ -1341,11 +1360,11 @@ export const andThen: {
1341
1360
  ) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1>
1342
1361
  : Micro<X, E, R>
1343
1362
  /**
1344
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1345
- * a single api.
1363
+ * A more flexible version of `flatMap` that combines `map` and `flatMap` into a
1364
+ * single API.
1346
1365
  *
1347
- * It also allows you to pass in a `Micro` effect directly, which will be
1348
- * executed after the current effect.
1366
+ * It also lets you directly pass a `Micro` effect, which will be executed after
1367
+ * the current effect.
1349
1368
  *
1350
1369
  * @since 3.4.0
1351
1370
  * @experimental
@@ -1357,11 +1376,11 @@ export const andThen: {
1357
1376
  ): [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1>
1358
1377
  : Micro<X, E, R>
1359
1378
  /**
1360
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1361
- * a single api.
1379
+ * A more flexible version of `flatMap` that combines `map` and `flatMap` into a
1380
+ * single API.
1362
1381
  *
1363
- * It also allows you to pass in a `Micro` effect directly, which will be
1364
- * executed after the current effect.
1382
+ * It also lets you directly pass a `Micro` effect, which will be executed after
1383
+ * the current effect.
1365
1384
  *
1366
1385
  * @since 3.4.0
1367
1386
  * @experimental
@@ -1497,13 +1516,13 @@ export const sandbox = <A, E, R>(self: Micro<A, E, R>): Micro<A, MicroCause<E>,
1497
1516
  export const raceAll = <Eff extends Micro<any, any, any>>(
1498
1517
  all: Iterable<Eff>
1499
1518
  ): Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>> =>
1500
- withFiber((parent) =>
1519
+ withMicroFiber((parent) =>
1501
1520
  async((resume) => {
1502
1521
  const effects = Arr.fromIterable(all)
1503
1522
  const len = effects.length
1504
1523
  let doneCount = 0
1505
1524
  let done = false
1506
- const fibers = new Set<Fiber<any, any>>()
1525
+ const fibers = new Set<MicroFiber<any, any>>()
1507
1526
  const causes: Array<MicroCause<any>> = []
1508
1527
  const onExit = (exit: MicroExit<any, any>) => {
1509
1528
  doneCount++
@@ -1535,7 +1554,7 @@ export const raceAll = <Eff extends Micro<any, any, any>>(
1535
1554
  /**
1536
1555
  * Returns an effect that races all the specified effects,
1537
1556
  * yielding the value of the first effect to succeed or fail. Losers of
1538
- * the race will be interrupted immediately
1557
+ * the race will be interrupted immediately.
1539
1558
  *
1540
1559
  * @since 3.4.0
1541
1560
  * @experimental
@@ -1544,10 +1563,10 @@ export const raceAll = <Eff extends Micro<any, any, any>>(
1544
1563
  export const raceAllFirst = <Eff extends Micro<any, any, any>>(
1545
1564
  all: Iterable<Eff>
1546
1565
  ): Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>> =>
1547
- withFiber((parent) =>
1566
+ withMicroFiber((parent) =>
1548
1567
  async((resume) => {
1549
1568
  let done = false
1550
- const fibers = new Set<Fiber<any, any>>()
1569
+ const fibers = new Set<MicroFiber<any, any>>()
1551
1570
  const onExit = (exit: MicroExit<any, any>) => {
1552
1571
  done = true
1553
1572
  resume(fibers.size === 0 ? exit : flatMap(fiberInterruptAll(fibers), () => exit))
@@ -1569,7 +1588,7 @@ export const raceAllFirst = <Eff extends Micro<any, any, any>>(
1569
1588
 
1570
1589
  /**
1571
1590
  * Returns an effect that races two effects, yielding the value of the first
1572
- * effect to succeed. Losers of the race will be interrupted immediately
1591
+ * effect to succeed. Losers of the race will be interrupted immediately.
1573
1592
  *
1574
1593
  * @since 3.4.0
1575
1594
  * @experimental
@@ -1578,7 +1597,7 @@ export const raceAllFirst = <Eff extends Micro<any, any, any>>(
1578
1597
  export const race: {
1579
1598
  /**
1580
1599
  * Returns an effect that races two effects, yielding the value of the first
1581
- * effect to succeed. Losers of the race will be interrupted immediately
1600
+ * effect to succeed. Losers of the race will be interrupted immediately.
1582
1601
  *
1583
1602
  * @since 3.4.0
1584
1603
  * @experimental
@@ -1587,7 +1606,7 @@ export const race: {
1587
1606
  <A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>
1588
1607
  /**
1589
1608
  * Returns an effect that races two effects, yielding the value of the first
1590
- * effect to succeed. Losers of the race will be interrupted immediately
1609
+ * effect to succeed. Losers of the race will be interrupted immediately.
1591
1610
  *
1592
1611
  * @since 3.4.0
1593
1612
  * @experimental
@@ -1602,7 +1621,7 @@ export const race: {
1602
1621
 
1603
1622
  /**
1604
1623
  * Returns an effect that races two effects, yielding the value of the first
1605
- * effect to succeed *or* fail. Losers of the race will be interrupted immediately
1624
+ * effect to succeed *or* fail. Losers of the race will be interrupted immediately.
1606
1625
  *
1607
1626
  * @since 3.4.0
1608
1627
  * @experimental
@@ -1611,7 +1630,7 @@ export const race: {
1611
1630
  export const raceFirst: {
1612
1631
  /**
1613
1632
  * Returns an effect that races two effects, yielding the value of the first
1614
- * effect to succeed *or* fail. Losers of the race will be interrupted immediately
1633
+ * effect to succeed *or* fail. Losers of the race will be interrupted immediately.
1615
1634
  *
1616
1635
  * @since 3.4.0
1617
1636
  * @experimental
@@ -1620,7 +1639,7 @@ export const raceFirst: {
1620
1639
  <A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>
1621
1640
  /**
1622
1641
  * Returns an effect that races two effects, yielding the value of the first
1623
- * effect to succeed *or* fail. Losers of the race will be interrupted immediately
1642
+ * effect to succeed *or* fail. Losers of the race will be interrupted immediately.
1624
1643
  *
1625
1644
  * @since 3.4.0
1626
1645
  * @experimental
@@ -1674,7 +1693,7 @@ export const flatMap: {
1674
1693
  )
1675
1694
  const OnSuccessProto = makePrimitiveProto({
1676
1695
  op: "OnSuccess",
1677
- eval(this: any, fiber: FiberImpl): Primitive {
1696
+ eval(this: any, fiber: MicroFiberImpl): Primitive {
1678
1697
  fiber._stack.push(this)
1679
1698
  return this[args]
1680
1699
  }
@@ -1732,10 +1751,9 @@ export const map: {
1732
1751
  // ----------------------------------------------------------------------------
1733
1752
 
1734
1753
  /**
1735
- * The MicroExit type is a data type that represents the result of a Micro
1736
- * computation.
1737
- *
1738
- * It uses the `Either` data type to represent the success and failure cases.
1754
+ * The `MicroExit` type is used to represent the result of a `Micro` computation. It
1755
+ * can either be successful, containing a value of type `A`, or it can fail,
1756
+ * containing an error of type `E` wrapped in a `MicroCause`.
1739
1757
  *
1740
1758
  * @since 3.4.6
1741
1759
  * @experimental
@@ -1908,7 +1926,7 @@ export const exitVoidAll = <I extends Iterable<MicroExit<any, any>>>(
1908
1926
  */
1909
1927
  export interface MicroScheduler {
1910
1928
  readonly scheduleTask: (task: () => void, priority: number) => void
1911
- readonly shouldYield: (fiber: Fiber<unknown, unknown>) => boolean
1929
+ readonly shouldYield: (fiber: MicroFiber<unknown, unknown>) => boolean
1912
1930
  readonly flush: () => void
1913
1931
  }
1914
1932
 
@@ -1958,7 +1976,7 @@ export class MicroSchedulerDefault implements MicroScheduler {
1958
1976
  /**
1959
1977
  * @since 3.5.9
1960
1978
  */
1961
- shouldYield(fiber: Fiber<unknown, unknown>) {
1979
+ shouldYield(fiber: MicroFiber<unknown, unknown>) {
1962
1980
  return fiber.currentOpCount >= fiber.getRef(MaxOpsBeforeYield)
1963
1981
  }
1964
1982
 
@@ -1998,7 +2016,7 @@ export const service: {
1998
2016
  <I, S>(tag: Context.Tag<I, S>): Micro<S, never, I>
1999
2017
  } =
2000
2018
  (<I, S>(tag: Context.Tag<I, S>): Micro<S, never, I> =>
2001
- withFiber((fiber) => succeed(Context.unsafeGet(fiber.context, tag)))) as any
2019
+ withMicroFiber((fiber) => succeed(Context.unsafeGet(fiber.context, tag)))) as any
2002
2020
 
2003
2021
  /**
2004
2022
  * Access the given `Context.Tag` from the environment, without tracking the
@@ -2013,7 +2031,7 @@ export const service: {
2013
2031
  */
2014
2032
  export const serviceOption = <I, S>(
2015
2033
  tag: Context.Tag<I, S>
2016
- ): Micro<Option.Option<S>> => withFiber((fiber) => succeed(Context.getOption(fiber.context, tag)))
2034
+ ): Micro<Option.Option<S>> => withMicroFiber((fiber) => succeed(Context.getOption(fiber.context, tag)))
2017
2035
 
2018
2036
  /**
2019
2037
  * Update the Context with the given mapping function.
@@ -2050,7 +2068,7 @@ export const updateContext: {
2050
2068
  self: Micro<A, E, R>,
2051
2069
  f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>
2052
2070
  ): Micro<A, E, R2> =>
2053
- withFiber<
2071
+ withMicroFiber<
2054
2072
  /**
2055
2073
  * Update the Context with the given mapping function.
2056
2074
  *
@@ -2133,7 +2151,7 @@ export const updateService: {
2133
2151
  tag: Context.Reference<I, A>,
2134
2152
  f: (value: A) => A
2135
2153
  ): Micro<XA, E, R> =>
2136
- withFiber((fiber) => {
2154
+ withMicroFiber((fiber) => {
2137
2155
  const prev = Context.unsafeGet(fiber.context, tag)
2138
2156
  fiber.context = Context.add(fiber.context, tag, f(prev))
2139
2157
  return onExit(
@@ -2154,7 +2172,7 @@ export const updateService: {
2154
2172
  * @category environment
2155
2173
  */
2156
2174
  export const context = <R>(): Micro<Context.Context<R>> => getContext as any
2157
- const getContext = withFiber((fiber) => succeed(fiber.context))
2175
+ const getContext = withMicroFiber((fiber) => succeed(fiber.context))
2158
2176
 
2159
2177
  /**
2160
2178
  * Merge the given `Context` with the current context.
@@ -2311,10 +2329,8 @@ export class CurrentScheduler extends Context.Reference<CurrentScheduler>()<
2311
2329
  * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
2312
2330
  * api to control the concurrency of that `Micro` when it is run.
2313
2331
  *
2314
- * @since 3.4.0
2315
- * @experimental
2316
- * @category environment refs
2317
2332
  * @example
2333
+ * ```ts
2318
2334
  * import * as Micro from "effect/Micro"
2319
2335
  *
2320
2336
  * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
@@ -2322,16 +2338,19 @@ export class CurrentScheduler extends Context.Reference<CurrentScheduler>()<
2322
2338
  * }).pipe(
2323
2339
  * Micro.withConcurrency(2) // use a concurrency of 2
2324
2340
  * )
2341
+ * ```
2342
+ *
2343
+ * @since 3.4.0
2344
+ * @experimental
2345
+ * @category environment refs
2325
2346
  */
2326
2347
  export const withConcurrency: {
2327
2348
  /**
2328
2349
  * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
2329
2350
  * api to control the concurrency of that `Micro` when it is run.
2330
2351
  *
2331
- * @since 3.4.0
2332
- * @experimental
2333
- * @category environment refs
2334
2352
  * @example
2353
+ * ```ts
2335
2354
  * import * as Micro from "effect/Micro"
2336
2355
  *
2337
2356
  * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
@@ -2339,16 +2358,19 @@ export const withConcurrency: {
2339
2358
  * }).pipe(
2340
2359
  * Micro.withConcurrency(2) // use a concurrency of 2
2341
2360
  * )
2361
+ * ```
2362
+ *
2363
+ * @since 3.4.0
2364
+ * @experimental
2365
+ * @category environment refs
2342
2366
  */
2343
2367
  (concurrency: "unbounded" | number): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>
2344
2368
  /**
2345
2369
  * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
2346
2370
  * api to control the concurrency of that `Micro` when it is run.
2347
2371
  *
2348
- * @since 3.4.0
2349
- * @experimental
2350
- * @category environment refs
2351
2372
  * @example
2373
+ * ```ts
2352
2374
  * import * as Micro from "effect/Micro"
2353
2375
  *
2354
2376
  * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
@@ -2356,6 +2378,11 @@ export const withConcurrency: {
2356
2378
  * }).pipe(
2357
2379
  * Micro.withConcurrency(2) // use a concurrency of 2
2358
2380
  * )
2381
+ * ```
2382
+ *
2383
+ * @since 3.4.0
2384
+ * @experimental
2385
+ * @category environment refs
2359
2386
  */
2360
2387
  <A, E, R>(self: Micro<A, E, R>, concurrency: "unbounded" | number): Micro<A, E, R>
2361
2388
  } = dual(
@@ -3212,7 +3239,7 @@ export const catchAllCause: {
3212
3239
  )
3213
3240
  const OnFailureProto = makePrimitiveProto({
3214
3241
  op: "OnFailure",
3215
- eval(this: any, fiber: FiberImpl): Primitive {
3242
+ eval(this: any, fiber: MicroFiberImpl): Primitive {
3216
3243
  fiber._stack.push(this as any)
3217
3244
  return this[args]
3218
3245
  }
@@ -3292,7 +3319,7 @@ export const catchCauseIf: {
3292
3319
  /**
3293
3320
  * Catch the error of the given `Micro` effect, allowing you to recover from it.
3294
3321
  *
3295
- * It only catches expected (`MicroCause.Fail`) errors.
3322
+ * It only catches expected errors.
3296
3323
  *
3297
3324
  * @since 3.4.6
3298
3325
  * @experimental
@@ -3302,7 +3329,7 @@ export const catchAll: {
3302
3329
  /**
3303
3330
  * Catch the error of the given `Micro` effect, allowing you to recover from it.
3304
3331
  *
3305
- * It only catches expected (`MicroCause.Fail`) errors.
3332
+ * It only catches expected errors.
3306
3333
  *
3307
3334
  * @since 3.4.6
3308
3335
  * @experimental
@@ -3312,7 +3339,7 @@ export const catchAll: {
3312
3339
  /**
3313
3340
  * Catch the error of the given `Micro` effect, allowing you to recover from it.
3314
3341
  *
3315
- * It only catches expected (`MicroCause.Fail`) errors.
3342
+ * It only catches expected errors.
3316
3343
  *
3317
3344
  * @since 3.4.6
3318
3345
  * @experimental
@@ -3936,7 +3963,7 @@ export const matchCauseEffect: {
3936
3963
  )
3937
3964
  const OnSuccessAndFailureProto = makePrimitiveProto({
3938
3965
  op: "OnSuccessAndFailure",
3939
- eval(this: any, fiber: FiberImpl): Primitive {
3966
+ eval(this: any, fiber: MicroFiberImpl): Primitive {
3940
3967
  fiber._stack.push(this)
3941
3968
  return this[args]
3942
3969
  }
@@ -4738,7 +4765,7 @@ export const interrupt: Micro<never> = failCause(causeInterrupt())
4738
4765
  export const uninterruptible = <A, E, R>(
4739
4766
  self: Micro<A, E, R>
4740
4767
  ): Micro<A, E, R> =>
4741
- withFiber((fiber) => {
4768
+ withMicroFiber((fiber) => {
4742
4769
  if (!fiber.interruptible) return self
4743
4770
  fiber.interruptible = false
4744
4771
  fiber._stack.push(setInterruptible(true))
@@ -4766,7 +4793,7 @@ const setInterruptible: (interruptible: boolean) => Primitive = makePrimitive({
4766
4793
  export const interruptible = <A, E, R>(
4767
4794
  self: Micro<A, E, R>
4768
4795
  ): Micro<A, E, R> =>
4769
- withFiber((fiber) => {
4796
+ withMicroFiber((fiber) => {
4770
4797
  if (fiber.interruptible) return self
4771
4798
  fiber.interruptible = true
4772
4799
  fiber._stack.push(setInterruptible(false))
@@ -4781,9 +4808,6 @@ export const interruptible = <A, E, R>(
4781
4808
  * You can use the `restore` function to restore a `Micro` effect to the
4782
4809
  * interruptibility state before the `uninterruptibleMask` was applied.
4783
4810
  *
4784
- * @since 3.4.0
4785
- * @experimental
4786
- * @category interruption
4787
4811
  * @example
4788
4812
  * ```ts
4789
4813
  * import * as Micro from "effect/Micro"
@@ -4794,13 +4818,17 @@ export const interruptible = <A, E, R>(
4794
4818
  * )
4795
4819
  * )
4796
4820
  * ```
4821
+ *
4822
+ * @since 3.4.0
4823
+ * @experimental
4824
+ * @category interruption
4797
4825
  */
4798
4826
  export const uninterruptibleMask = <A, E, R>(
4799
4827
  f: (
4800
4828
  restore: <A, E, R>(effect: Micro<A, E, R>) => Micro<A, E, R>
4801
4829
  ) => Micro<A, E, R>
4802
4830
  ): Micro<A, E, R> =>
4803
- withFiber((fiber) => {
4831
+ withMicroFiber((fiber) => {
4804
4832
  if (!fiber.interruptible) return f(identity)
4805
4833
  fiber.interruptible = false
4806
4834
  fiber._stack.push(setInterruptible(true))
@@ -4953,13 +4981,14 @@ export const whileLoop: <A, E, R>(options: {
4953
4981
  })
4954
4982
 
4955
4983
  /**
4956
- * For each element of the provided iterable, run the effect and collect the results.
4984
+ * For each element of the provided iterable, run the effect and collect the
4985
+ * results.
4957
4986
  *
4958
4987
  * If the `discard` option is set to `true`, the results will be discarded and
4959
4988
  * the effect will return `void`.
4960
4989
  *
4961
- * The `concurrency` option can be set to control how many effects are run in
4962
- * parallel. By default, the effects are run sequentially.
4990
+ * The `concurrency` option can be set to control how many effects are run
4991
+ * concurrently. By default, the effects are run sequentially.
4963
4992
  *
4964
4993
  * @since 3.4.0
4965
4994
  * @experimental
@@ -4967,13 +4996,14 @@ export const whileLoop: <A, E, R>(options: {
4967
4996
  */
4968
4997
  export const forEach: {
4969
4998
  /**
4970
- * For each element of the provided iterable, run the effect and collect the results.
4999
+ * For each element of the provided iterable, run the effect and collect the
5000
+ * results.
4971
5001
  *
4972
5002
  * If the `discard` option is set to `true`, the results will be discarded and
4973
5003
  * the effect will return `void`.
4974
5004
  *
4975
- * The `concurrency` option can be set to control how many effects are run in
4976
- * parallel. By default, the effects are run sequentially.
5005
+ * The `concurrency` option can be set to control how many effects are run
5006
+ * concurrently. By default, the effects are run sequentially.
4977
5007
  *
4978
5008
  * @since 3.4.0
4979
5009
  * @experimental
@@ -4988,13 +5018,14 @@ export const forEach: {
4988
5018
  }
4989
5019
  ): Micro<Array<B>, E, R>
4990
5020
  /**
4991
- * For each element of the provided iterable, run the effect and collect the results.
5021
+ * For each element of the provided iterable, run the effect and collect the
5022
+ * results.
4992
5023
  *
4993
5024
  * If the `discard` option is set to `true`, the results will be discarded and
4994
5025
  * the effect will return `void`.
4995
5026
  *
4996
- * The `concurrency` option can be set to control how many effects are run in
4997
- * parallel. By default, the effects are run sequentially.
5027
+ * The `concurrency` option can be set to control how many effects are run
5028
+ * concurrently. By default, the effects are run sequentially.
4998
5029
  *
4999
5030
  * @since 3.4.0
5000
5031
  * @experimental
@@ -5017,7 +5048,7 @@ export const forEach: {
5017
5048
  readonly concurrency?: Concurrency | undefined
5018
5049
  readonly discard?: boolean | undefined
5019
5050
  }): Micro<any, E, R> =>
5020
- withFiber((parent) => {
5051
+ withMicroFiber((parent) => {
5021
5052
  const concurrencyOption = options?.concurrency === "inherit"
5022
5053
  ? parent.getRef(CurrentConcurrency)
5023
5054
  : options?.concurrency ?? 1
@@ -5047,7 +5078,7 @@ export const forEach: {
5047
5078
  )
5048
5079
  }
5049
5080
  return async((resume) => {
5050
- const fibers = new Set<Fiber<unknown, unknown>>()
5081
+ const fibers = new Set<MicroFiber<unknown, unknown>>()
5051
5082
  let result: MicroExit<any, any> | undefined = undefined
5052
5083
  let inProgress = 0
5053
5084
  let doneCount = 0
@@ -5105,7 +5136,8 @@ export const forEach: {
5105
5136
  /**
5106
5137
  * Effectfully filter the elements of the provided iterable.
5107
5138
  *
5108
- * Use the `concurrency` option to control how many elements are processed in parallel.
5139
+ * Use the `concurrency` option to control how many elements are processed
5140
+ * concurrently.
5109
5141
  *
5110
5142
  * @since 3.4.0
5111
5143
  * @experimental
@@ -5124,7 +5156,8 @@ export const filter = <A, E, R>(iterable: Iterable<A>, f: (a: NoInfer<A>) => Mic
5124
5156
  /**
5125
5157
  * Effectfully filter the elements of the provided iterable.
5126
5158
  *
5127
- * Use the `concurrency` option to control how many elements are processed in parallel.
5159
+ * Use the `concurrency` option to control how many elements are processed
5160
+ * concurrently.
5128
5161
  *
5129
5162
  * @since 3.4.0
5130
5163
  * @experimental
@@ -5253,30 +5286,30 @@ export {
5253
5286
  // ----------------------------------------------------------------------------
5254
5287
 
5255
5288
  /**
5256
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
5289
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
5257
5290
  * aborted.
5258
5291
  *
5259
5292
  * When the parent `Micro` finishes, this `Micro` will be aborted.
5260
5293
  *
5261
5294
  * @since 3.4.0
5262
5295
  * @experimental
5263
- * @category handle & forking
5296
+ * @category fiber & forking
5264
5297
  */
5265
5298
  export const fork = <A, E, R>(
5266
5299
  self: Micro<A, E, R>
5267
- ): Micro<Fiber<A, E>, never, R> =>
5268
- withFiber((fiber) => {
5300
+ ): Micro<MicroFiber<A, E>, never, R> =>
5301
+ withMicroFiber((fiber) => {
5269
5302
  fiberMiddleware.interruptChildren ??= fiberInterruptChildren
5270
5303
  return succeed(unsafeFork(fiber, self))
5271
5304
  })
5272
5305
 
5273
5306
  const unsafeFork = <FA, FE, A, E, R>(
5274
- parent: FiberImpl<FA, FE>,
5307
+ parent: MicroFiberImpl<FA, FE>,
5275
5308
  effect: Micro<A, E, R>,
5276
5309
  immediate = false,
5277
5310
  daemon = false
5278
- ): Fiber<A, E> => {
5279
- const child = new FiberImpl<A, E>(parent.context, parent.interruptible)
5311
+ ): MicroFiber<A, E> => {
5312
+ const child = new MicroFiberImpl<A, E>(parent.context, parent.interruptible)
5280
5313
  if (!daemon) {
5281
5314
  parent.children().add(child)
5282
5315
  child.addObserver(() => parent.children().delete(child))
@@ -5290,55 +5323,55 @@ const unsafeFork = <FA, FE, A, E, R>(
5290
5323
  }
5291
5324
 
5292
5325
  /**
5293
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
5326
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
5294
5327
  * aborted.
5295
5328
  *
5296
5329
  * It will not be aborted when the parent `Micro` finishes.
5297
5330
  *
5298
5331
  * @since 3.4.0
5299
5332
  * @experimental
5300
- * @category handle & forking
5333
+ * @category fiber & forking
5301
5334
  */
5302
5335
  export const forkDaemon = <A, E, R>(
5303
5336
  self: Micro<A, E, R>
5304
- ): Micro<Fiber<A, E>, never, R> => withFiber((fiber) => succeed(unsafeFork(fiber, self, false, true)))
5337
+ ): Micro<MicroFiber<A, E>, never, R> => withMicroFiber((fiber) => succeed(unsafeFork(fiber, self, false, true)))
5305
5338
 
5306
5339
  /**
5307
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
5340
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
5308
5341
  * aborted.
5309
5342
  *
5310
5343
  * The lifetime of the handle will be attached to the provided `MicroScope`.
5311
5344
  *
5312
5345
  * @since 3.4.0
5313
5346
  * @experimental
5314
- * @category handle & forking
5347
+ * @category fiber & forking
5315
5348
  */
5316
5349
  export const forkIn: {
5317
5350
  /**
5318
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
5351
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
5319
5352
  * aborted.
5320
5353
  *
5321
5354
  * The lifetime of the handle will be attached to the provided `MicroScope`.
5322
5355
  *
5323
5356
  * @since 3.4.0
5324
5357
  * @experimental
5325
- * @category handle & forking
5358
+ * @category fiber & forking
5326
5359
  */
5327
- (scope: MicroScope): <A, E, R>(self: Micro<A, E, R>) => Micro<Fiber<A, E>, never, R>
5360
+ (scope: MicroScope): <A, E, R>(self: Micro<A, E, R>) => Micro<MicroFiber<A, E>, never, R>
5328
5361
  /**
5329
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
5362
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
5330
5363
  * aborted.
5331
5364
  *
5332
5365
  * The lifetime of the handle will be attached to the provided `MicroScope`.
5333
5366
  *
5334
5367
  * @since 3.4.0
5335
5368
  * @experimental
5336
- * @category handle & forking
5369
+ * @category fiber & forking
5337
5370
  */
5338
- <A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<Fiber<A, E>, never, R>
5371
+ <A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<MicroFiber<A, E>, never, R>
5339
5372
  } = dual(
5340
5373
  2,
5341
- <A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<Fiber<A, E>, never, R> =>
5374
+ <A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<MicroFiber<A, E>, never, R> =>
5342
5375
  uninterruptibleMask((restore) =>
5343
5376
  flatMap(scope.fork, (scope) =>
5344
5377
  tap(
@@ -5349,16 +5382,16 @@ export const forkIn: {
5349
5382
  )
5350
5383
 
5351
5384
  /**
5352
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
5385
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
5353
5386
  * aborted.
5354
5387
  *
5355
5388
  * The lifetime of the handle will be attached to the current `MicroScope`.
5356
5389
  *
5357
5390
  * @since 3.4.0
5358
5391
  * @experimental
5359
- * @category handle & forking
5392
+ * @category fiber & forking
5360
5393
  */
5361
- export const forkScoped = <A, E, R>(self: Micro<A, E, R>): Micro<Fiber<A, E>, never, R | MicroScope> =>
5394
+ export const forkScoped = <A, E, R>(self: Micro<A, E, R>): Micro<MicroFiber<A, E>, never, R | MicroScope> =>
5362
5395
  flatMap(scope, (scope) => forkIn(self, scope))
5363
5396
 
5364
5397
  // ----------------------------------------------------------------------------
@@ -5366,15 +5399,12 @@ export const forkScoped = <A, E, R>(self: Micro<A, E, R>): Micro<Fiber<A, E>, ne
5366
5399
  // ----------------------------------------------------------------------------
5367
5400
 
5368
5401
  /**
5369
- * Execute the `Micro` effect and return a `Handle` that can be awaited, joined,
5402
+ * Execute the `Micro` effect and return a `MicroFiber` that can be awaited, joined,
5370
5403
  * or aborted.
5371
5404
  *
5372
5405
  * You can listen for the result by adding an observer using the handle's
5373
5406
  * `addObserver` method.
5374
5407
  *
5375
- * @since 3.4.0
5376
- * @experimental
5377
- * @category execution
5378
5408
  * @example
5379
5409
  * ```ts
5380
5410
  * import * as Micro from "effect/Micro"
@@ -5388,6 +5418,10 @@ export const forkScoped = <A, E, R>(self: Micro<A, E, R>): Micro<Fiber<A, E>, ne
5388
5418
  * console.log(exit)
5389
5419
  * })
5390
5420
  * ```
5421
+ *
5422
+ * @since 3.4.0
5423
+ * @experimental
5424
+ * @category execution
5391
5425
  */
5392
5426
  export const runFork = <A, E>(
5393
5427
  effect: Micro<A, E>,
@@ -5395,8 +5429,8 @@ export const runFork = <A, E>(
5395
5429
  readonly signal?: AbortSignal | undefined
5396
5430
  readonly scheduler?: MicroScheduler | undefined
5397
5431
  } | undefined
5398
- ): FiberImpl<A, E> => {
5399
- const fiber = new FiberImpl<A, E>(CurrentScheduler.context(
5432
+ ): MicroFiberImpl<A, E> => {
5433
+ const fiber = new MicroFiberImpl<A, E>(CurrentScheduler.context(
5400
5434
  options?.scheduler ?? new MicroSchedulerDefault()
5401
5435
  ))
5402
5436
  fiber.evaluate(effect as any)
@@ -5458,7 +5492,7 @@ export const runPromise = <A, E>(
5458
5492
  * Attempt to execute the `Micro` effect synchronously and return the `MicroExit`.
5459
5493
  *
5460
5494
  * If any asynchronous effects are encountered, the function will return a
5461
- * `CauseDie` containing the `Handle`.
5495
+ * `CauseDie` containing the `MicroFiber`.
5462
5496
  *
5463
5497
  * @since 3.4.6
5464
5498
  * @experimental