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/dist/esm/Micro.js CHANGED
@@ -95,7 +95,7 @@ class MicroCauseImpl extends globalThis.Error {
95
95
  return this.stack;
96
96
  }
97
97
  }
98
- class FailImpl extends MicroCauseImpl {
98
+ class Fail extends MicroCauseImpl {
99
99
  error;
100
100
  constructor(error, traces = []) {
101
101
  super("Fail", error, traces);
@@ -107,8 +107,8 @@ class FailImpl extends MicroCauseImpl {
107
107
  * @experimental
108
108
  * @category MicroCause
109
109
  */
110
- export const causeFail = (error, traces = []) => new FailImpl(error, traces);
111
- class DieImpl extends MicroCauseImpl {
110
+ export const causeFail = (error, traces = []) => new Fail(error, traces);
111
+ class Die extends MicroCauseImpl {
112
112
  defect;
113
113
  constructor(defect, traces = []) {
114
114
  super("Die", defect, traces);
@@ -120,8 +120,8 @@ class DieImpl extends MicroCauseImpl {
120
120
  * @experimental
121
121
  * @category MicroCause
122
122
  */
123
- export const causeDie = (defect, traces = []) => new DieImpl(defect, traces);
124
- class InterruptImpl extends MicroCauseImpl {
123
+ export const causeDie = (defect, traces = []) => new Die(defect, traces);
124
+ class Interrupt extends MicroCauseImpl {
125
125
  constructor(traces = []) {
126
126
  super("Interrupt", "interrupted", traces);
127
127
  }
@@ -131,7 +131,7 @@ class InterruptImpl extends MicroCauseImpl {
131
131
  * @experimental
132
132
  * @category MicroCause
133
133
  */
134
- export const causeInterrupt = (traces = []) => new InterruptImpl(traces);
134
+ export const causeInterrupt = (traces = []) => new Interrupt(traces);
135
135
  /**
136
136
  * @since 3.4.6
137
137
  * @experimental
@@ -173,22 +173,22 @@ export const causeWithTrace = /*#__PURE__*/dual(2, (self, trace) => {
173
173
  }
174
174
  });
175
175
  // ----------------------------------------------------------------------------
176
- // Fiber
176
+ // MicroFiber
177
177
  // ----------------------------------------------------------------------------
178
178
  /**
179
179
  * @since 3.11.0
180
180
  * @experimental
181
- * @category Fiber
181
+ * @category MicroFiber
182
182
  */
183
- export const FiberTypeId = /*#__PURE__*/Symbol.for("effect/Micro/Fiber");
183
+ export const MicroFiberTypeId = /*#__PURE__*/Symbol.for("effect/Micro/MicroFiber");
184
184
  const fiberVariance = {
185
185
  _A: identity,
186
186
  _E: identity
187
187
  };
188
- class FiberImpl {
188
+ class MicroFiberImpl {
189
189
  context;
190
190
  interruptible;
191
- [FiberTypeId];
191
+ [MicroFiberTypeId];
192
192
  _stack = [];
193
193
  _observers = [];
194
194
  _exit;
@@ -197,7 +197,7 @@ class FiberImpl {
197
197
  constructor(context, interruptible = true) {
198
198
  this.context = context;
199
199
  this.interruptible = interruptible;
200
- this[FiberTypeId] = fiberVariance;
200
+ this[MicroFiberTypeId] = fiberVariance;
201
201
  }
202
202
  getRef(ref) {
203
203
  return InternalContext.unsafeGetReference(this.context, ref);
@@ -276,7 +276,7 @@ class FiberImpl {
276
276
  }
277
277
  } catch (error) {
278
278
  if (!hasProperty(current, evaluate)) {
279
- return exitDie(`Micro/Fiber.runLoop: Not a valid effect: ${String(current)}`);
279
+ return exitDie(`MicroFiber.runLoop: Not a valid effect: ${String(current)}`);
280
280
  }
281
281
  return exitDie(error);
282
282
  }
@@ -314,13 +314,19 @@ const fiberInterruptChildren = fiber => {
314
314
  /**
315
315
  * @since 3.11.0
316
316
  * @experimental
317
- * @category Fiber
317
+ * @category MicroFiber
318
318
  */
319
319
  export const fiberAwait = self => async(resume => sync(self.addObserver(exit => resume(succeed(exit)))));
320
+ /**
321
+ * @since 3.11.2
322
+ * @experimental
323
+ * @category MicroFiber
324
+ */
325
+ export const fiberJoin = self => flatten(fiberAwait(self));
320
326
  /**
321
327
  * @since 3.11.0
322
328
  * @experimental
323
- * @category Fiber
329
+ * @category MicroFiber
324
330
  */
325
331
  export const fiberInterrupt = self => suspend(() => {
326
332
  self.unsafeInterrupt();
@@ -329,7 +335,7 @@ export const fiberInterrupt = self => suspend(() => {
329
335
  /**
330
336
  * @since 3.11.0
331
337
  * @experimental
332
- * @category Fiber
338
+ * @category MicroFiber
333
339
  */
334
340
  export const fiberInterruptAll = fibers => suspend(() => {
335
341
  for (const fiber of fibers) fiber.unsafeInterrupt();
@@ -376,7 +382,7 @@ const MicroProto = {
376
382
  },
377
383
  toJSON() {
378
384
  return {
379
- _id: "effect/Micro",
385
+ _id: "Micro",
380
386
  op: this[identifier],
381
387
  ...(args in this ? {
382
388
  args: this[args]
@@ -419,7 +425,7 @@ const makeExit = options => {
419
425
  },
420
426
  toJSON() {
421
427
  return {
422
- _id: "effect/Micro/Exit",
428
+ _id: "MicroExit",
423
429
  _tag: options.op,
424
430
  [options.prop]: this[args]
425
431
  };
@@ -474,10 +480,10 @@ export const failCause = /*#__PURE__*/makeExit({
474
480
  }
475
481
  });
476
482
  /**
477
- * Creates a `Micro` effect that will fail with the specified error.
483
+ * Creates a `Micro` effect that fails with the given error.
478
484
  *
479
- * This will result in a `CauseFail`, where the error is tracked at the
480
- * type level.
485
+ * This results in a `Fail` variant of the `MicroCause` type, where the error is
486
+ * tracked at the type level.
481
487
  *
482
488
  * @since 3.4.0
483
489
  * @experimental
@@ -485,10 +491,10 @@ export const failCause = /*#__PURE__*/makeExit({
485
491
  */
486
492
  export const fail = error => failCause(causeFail(error));
487
493
  /**
488
- * Creates a `Micro` effect that will succeed with the lazily evaluated value.
494
+ * Creates a `Micro` effect that succeeds with a lazily evaluated value.
489
495
  *
490
- * If the evaluation of the value throws an error, the effect will fail with
491
- * `CauseDie`.
496
+ * If the evaluation of the value throws an error, the effect will fail with a
497
+ * `Die` variant of the `MicroCause` type.
492
498
  *
493
499
  * @since 3.4.0
494
500
  * @experimental
@@ -546,7 +552,7 @@ export const yieldNowWith = /*#__PURE__*/makePrimitive({
546
552
  */
547
553
  export const yieldNow = /*#__PURE__*/yieldNowWith(0);
548
554
  /**
549
- * Creates a `Micro` effect that will succeed with `Option.Some` of the value.
555
+ * Creates a `Micro` effect that will succeed with the value wrapped in `Some`.
550
556
  *
551
557
  * @since 3.4.0
552
558
  * @experimental
@@ -554,7 +560,7 @@ export const yieldNow = /*#__PURE__*/yieldNowWith(0);
554
560
  */
555
561
  export const succeedSome = a => succeed(Option.some(a));
556
562
  /**
557
- * Creates a `Micro` effect that will succeed with `Option.None`.
563
+ * Creates a `Micro` effect that succeeds with `None`.
558
564
  *
559
565
  * @since 3.4.0
560
566
  * @experimental
@@ -572,8 +578,8 @@ export const failCauseSync = evaluate => suspend(() => failCause(evaluate()));
572
578
  /**
573
579
  * Creates a `Micro` effect that will die with the specified error.
574
580
  *
575
- * This will result in a `CauseDie`, where the error is not tracked at
576
- * the type level.
581
+ * This results in a `Die` variant of the `MicroCause` type, where the error is
582
+ * not tracked at the type level.
577
583
  *
578
584
  * @since 3.4.0
579
585
  * @experimental
@@ -583,8 +589,8 @@ export const die = defect => exitDie(defect);
583
589
  /**
584
590
  * Creates a `Micro` effect that will fail with the lazily evaluated error.
585
591
  *
586
- * This will result in a `CauseFail`, where the error is tracked at the
587
- * type level.
592
+ * This results in a `Fail` variant of the `MicroCause` type, where the error is
593
+ * tracked at the type level.
588
594
  *
589
595
  * @since 3.4.6
590
596
  * @experimental
@@ -633,9 +639,6 @@ export {
633
639
  * The `Micro` equivalent of a try / catch block, which allows you to map
634
640
  * thrown errors to a specific error type.
635
641
  *
636
- * @since 3.4.0
637
- * @experimental
638
- * @category constructors
639
642
  * @example
640
643
  * ```ts
641
644
  * import { Micro } from "effect"
@@ -645,11 +648,17 @@ export {
645
648
  * catch: (cause) => new Error("caught", { cause })
646
649
  * })
647
650
  * ```
651
+ *
652
+ * @since 3.4.0
653
+ * @experimental
654
+ * @category constructors
648
655
  */
649
656
  try_ as try };
650
657
  /**
651
- * Wrap a `Promise` into a `Micro` effect. Any errors will result in a
652
- * `CauseDie`.
658
+ * Wrap a `Promise` into a `Micro` effect.
659
+ *
660
+ * Any errors will result in a `Die` variant of the `MicroCause` type, where the
661
+ * error is not tracked at the type level.
653
662
  *
654
663
  * @since 3.4.0
655
664
  * @experimental
@@ -662,9 +671,6 @@ export const promise = evaluate => asyncOptions(function (resume, signal) {
662
671
  * Wrap a `Promise` into a `Micro` effect. Any errors will be caught and
663
672
  * converted into a specific error type.
664
673
  *
665
- * @since 3.4.0
666
- * @experimental
667
- * @category constructors
668
674
  * @example
669
675
  * ```ts
670
676
  * import { Micro } from "effect"
@@ -674,6 +680,10 @@ export const promise = evaluate => asyncOptions(function (resume, signal) {
674
680
  * catch: (cause) => new Error("caught", { cause })
675
681
  * })
676
682
  * ```
683
+ *
684
+ * @since 3.4.0
685
+ * @experimental
686
+ * @category constructors
677
687
  */
678
688
  export const tryPromise = options => asyncOptions(function (resume, signal) {
679
689
  try {
@@ -683,14 +693,14 @@ export const tryPromise = options => asyncOptions(function (resume, signal) {
683
693
  }
684
694
  }, options.try.length !== 0);
685
695
  /**
686
- * Create a `Micro` effect using the current `Fiber`.
696
+ * Create a `Micro` effect using the current `MicroFiber`.
687
697
  *
688
698
  * @since 3.4.0
689
699
  * @experimental
690
700
  * @category constructors
691
701
  */
692
- export const withFiber = /*#__PURE__*/makePrimitive({
693
- op: "WithFiber",
702
+ export const withMicroFiber = /*#__PURE__*/makePrimitive({
703
+ op: "WithMicroFiber",
694
704
  eval(fiber) {
695
705
  return this[args](fiber);
696
706
  }
@@ -702,7 +712,7 @@ export const withFiber = /*#__PURE__*/makePrimitive({
702
712
  * @experimental
703
713
  * @category constructors
704
714
  */
705
- export const yieldFlush = /*#__PURE__*/withFiber(fiber => {
715
+ export const yieldFlush = /*#__PURE__*/withMicroFiber(fiber => {
706
716
  fiber.getRef(CurrentScheduler).flush();
707
717
  return exitVoid;
708
718
  });
@@ -806,7 +816,7 @@ const fromIterator = /*#__PURE__*/makePrimitive({
806
816
  */
807
817
  export const as = /*#__PURE__*/dual(2, (self, value) => map(self, _ => value));
808
818
  /**
809
- * Wrap the success value of this `Micro` effect in an `Option.Some`.
819
+ * Wrap the success value of this `Micro` effect in a `Some`.
810
820
  *
811
821
  * @since 3.4.0
812
822
  * @experimental
@@ -825,11 +835,11 @@ export const flip = self => matchEffect(self, {
825
835
  onSuccess: fail
826
836
  });
827
837
  /**
828
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
829
- * a single api.
838
+ * A more flexible version of `flatMap` that combines `map` and `flatMap` into a
839
+ * single API.
830
840
  *
831
- * It also allows you to pass in a `Micro` effect directly, which will be
832
- * executed after the current effect.
841
+ * It also lets you directly pass a `Micro` effect, which will be executed after
842
+ * the current effect.
833
843
  *
834
844
  * @since 3.4.0
835
845
  * @experimental
@@ -888,7 +898,7 @@ export const sandbox = self => catchAllCause(self, fail);
888
898
  * @experimental
889
899
  * @category sequencing
890
900
  */
891
- export const raceAll = all => withFiber(parent => async(resume => {
901
+ export const raceAll = all => withMicroFiber(parent => async(resume => {
892
902
  const effects = Arr.fromIterable(all);
893
903
  const len = effects.length;
894
904
  let doneCount = 0;
@@ -921,13 +931,13 @@ export const raceAll = all => withFiber(parent => async(resume => {
921
931
  /**
922
932
  * Returns an effect that races all the specified effects,
923
933
  * yielding the value of the first effect to succeed or fail. Losers of
924
- * the race will be interrupted immediately
934
+ * the race will be interrupted immediately.
925
935
  *
926
936
  * @since 3.4.0
927
937
  * @experimental
928
938
  * @category sequencing
929
939
  */
930
- export const raceAllFirst = all => withFiber(parent => async(resume => {
940
+ export const raceAllFirst = all => withMicroFiber(parent => async(resume => {
931
941
  let done = false;
932
942
  const fibers = new Set();
933
943
  const onExit = exit => {
@@ -947,7 +957,7 @@ export const raceAllFirst = all => withFiber(parent => async(resume => {
947
957
  }));
948
958
  /**
949
959
  * Returns an effect that races two effects, yielding the value of the first
950
- * effect to succeed. Losers of the race will be interrupted immediately
960
+ * effect to succeed. Losers of the race will be interrupted immediately.
951
961
  *
952
962
  * @since 3.4.0
953
963
  * @experimental
@@ -956,7 +966,7 @@ export const raceAllFirst = all => withFiber(parent => async(resume => {
956
966
  export const race = /*#__PURE__*/dual(2, (self, that) => raceAll([self, that]));
957
967
  /**
958
968
  * Returns an effect that races two effects, yielding the value of the first
959
- * effect to succeed *or* fail. Losers of the race will be interrupted immediately
969
+ * effect to succeed *or* fail. Losers of the race will be interrupted immediately.
960
970
  *
961
971
  * @since 3.4.0
962
972
  * @experimental
@@ -1147,7 +1157,7 @@ export class MicroSchedulerDefault {
1147
1157
  * @experimental
1148
1158
  * @category environment
1149
1159
  */
1150
- export const service = tag => withFiber(fiber => succeed(Context.unsafeGet(fiber.context, tag)));
1160
+ export const service = tag => withMicroFiber(fiber => succeed(Context.unsafeGet(fiber.context, tag)));
1151
1161
  /**
1152
1162
  * Access the given `Context.Tag` from the environment, without tracking the
1153
1163
  * dependency at the type level.
@@ -1159,7 +1169,7 @@ export const service = tag => withFiber(fiber => succeed(Context.unsafeGet(fiber
1159
1169
  * @experimental
1160
1170
  * @category environment
1161
1171
  */
1162
- export const serviceOption = tag => withFiber(fiber => succeed(Context.getOption(fiber.context, tag)));
1172
+ export const serviceOption = tag => withMicroFiber(fiber => succeed(Context.getOption(fiber.context, tag)));
1163
1173
  /**
1164
1174
  * Update the Context with the given mapping function.
1165
1175
  *
@@ -1167,7 +1177,7 @@ export const serviceOption = tag => withFiber(fiber => succeed(Context.getOption
1167
1177
  * @experimental
1168
1178
  * @category environment
1169
1179
  */
1170
- export const updateContext = /*#__PURE__*/dual(2, (self, f) => withFiber(fiber => {
1180
+ export const updateContext = /*#__PURE__*/dual(2, (self, f) => withMicroFiber(fiber => {
1171
1181
  const prev = fiber.context;
1172
1182
  fiber.context = f(prev);
1173
1183
  return onExit(self, () => {
@@ -1182,7 +1192,7 @@ export const updateContext = /*#__PURE__*/dual(2, (self, f) => withFiber(fiber =
1182
1192
  * @experimental
1183
1193
  * @category environment
1184
1194
  */
1185
- export const updateService = /*#__PURE__*/dual(3, (self, tag, f) => withFiber(fiber => {
1195
+ export const updateService = /*#__PURE__*/dual(3, (self, tag, f) => withMicroFiber(fiber => {
1186
1196
  const prev = Context.unsafeGet(fiber.context, tag);
1187
1197
  fiber.context = Context.add(fiber.context, tag, f(prev));
1188
1198
  return onExit(self, () => {
@@ -1198,7 +1208,7 @@ export const updateService = /*#__PURE__*/dual(3, (self, tag, f) => withFiber(fi
1198
1208
  * @category environment
1199
1209
  */
1200
1210
  export const context = () => getContext;
1201
- const getContext = /*#__PURE__*/withFiber(fiber => succeed(fiber.context));
1211
+ const getContext = /*#__PURE__*/withMicroFiber(fiber => succeed(fiber.context));
1202
1212
  /**
1203
1213
  * Merge the given `Context` with the current context.
1204
1214
  *
@@ -1255,10 +1265,8 @@ export class CurrentScheduler extends /*#__PURE__*/Context.Reference()("effect/M
1255
1265
  * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
1256
1266
  * api to control the concurrency of that `Micro` when it is run.
1257
1267
  *
1258
- * @since 3.4.0
1259
- * @experimental
1260
- * @category environment refs
1261
1268
  * @example
1269
+ * ```ts
1262
1270
  * import * as Micro from "effect/Micro"
1263
1271
  *
1264
1272
  * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
@@ -1266,6 +1274,11 @@ export class CurrentScheduler extends /*#__PURE__*/Context.Reference()("effect/M
1266
1274
  * }).pipe(
1267
1275
  * Micro.withConcurrency(2) // use a concurrency of 2
1268
1276
  * )
1277
+ * ```
1278
+ *
1279
+ * @since 3.4.0
1280
+ * @experimental
1281
+ * @category environment refs
1269
1282
  */
1270
1283
  export const withConcurrency = /*#__PURE__*/dual(2, (self, concurrency) => provideService(self, CurrentConcurrency, concurrency));
1271
1284
  // ----------------------------------------------------------------------------
@@ -1509,7 +1522,7 @@ export const catchCauseIf = /*#__PURE__*/dual(3, (self, predicate, f) => catchAl
1509
1522
  /**
1510
1523
  * Catch the error of the given `Micro` effect, allowing you to recover from it.
1511
1524
  *
1512
- * It only catches expected (`MicroCause.Fail`) errors.
1525
+ * It only catches expected errors.
1513
1526
  *
1514
1527
  * @since 3.4.6
1515
1528
  * @experimental
@@ -2014,7 +2027,7 @@ export const interrupt = /*#__PURE__*/failCause( /*#__PURE__*/causeInterrupt());
2014
2027
  * @experimental
2015
2028
  * @category flags
2016
2029
  */
2017
- export const uninterruptible = self => withFiber(fiber => {
2030
+ export const uninterruptible = self => withMicroFiber(fiber => {
2018
2031
  if (!fiber.interruptible) return self;
2019
2032
  fiber.interruptible = false;
2020
2033
  fiber._stack.push(setInterruptible(true));
@@ -2037,7 +2050,7 @@ const setInterruptible = /*#__PURE__*/makePrimitive({
2037
2050
  * @experimental
2038
2051
  * @category flags
2039
2052
  */
2040
- export const interruptible = self => withFiber(fiber => {
2053
+ export const interruptible = self => withMicroFiber(fiber => {
2041
2054
  if (fiber.interruptible) return self;
2042
2055
  fiber.interruptible = true;
2043
2056
  fiber._stack.push(setInterruptible(false));
@@ -2051,9 +2064,6 @@ export const interruptible = self => withFiber(fiber => {
2051
2064
  * You can use the `restore` function to restore a `Micro` effect to the
2052
2065
  * interruptibility state before the `uninterruptibleMask` was applied.
2053
2066
  *
2054
- * @since 3.4.0
2055
- * @experimental
2056
- * @category interruption
2057
2067
  * @example
2058
2068
  * ```ts
2059
2069
  * import * as Micro from "effect/Micro"
@@ -2064,8 +2074,12 @@ export const interruptible = self => withFiber(fiber => {
2064
2074
  * )
2065
2075
  * )
2066
2076
  * ```
2077
+ *
2078
+ * @since 3.4.0
2079
+ * @experimental
2080
+ * @category interruption
2067
2081
  */
2068
- export const uninterruptibleMask = f => withFiber(fiber => {
2082
+ export const uninterruptibleMask = f => withMicroFiber(fiber => {
2069
2083
  if (!fiber.interruptible) return f(identity);
2070
2084
  fiber.interruptible = false;
2071
2085
  fiber._stack.push(setInterruptible(true));
@@ -2120,19 +2134,20 @@ export const whileLoop = /*#__PURE__*/makePrimitive({
2120
2134
  }
2121
2135
  });
2122
2136
  /**
2123
- * For each element of the provided iterable, run the effect and collect the results.
2137
+ * For each element of the provided iterable, run the effect and collect the
2138
+ * results.
2124
2139
  *
2125
2140
  * If the `discard` option is set to `true`, the results will be discarded and
2126
2141
  * the effect will return `void`.
2127
2142
  *
2128
- * The `concurrency` option can be set to control how many effects are run in
2129
- * parallel. By default, the effects are run sequentially.
2143
+ * The `concurrency` option can be set to control how many effects are run
2144
+ * concurrently. By default, the effects are run sequentially.
2130
2145
  *
2131
2146
  * @since 3.4.0
2132
2147
  * @experimental
2133
2148
  * @category collecting & elements
2134
2149
  */
2135
- export const forEach = (iterable, f, options) => withFiber(parent => {
2150
+ export const forEach = (iterable, f, options) => withMicroFiber(parent => {
2136
2151
  const concurrencyOption = options?.concurrency === "inherit" ? parent.getRef(CurrentConcurrency) : options?.concurrency ?? 1;
2137
2152
  const concurrency = concurrencyOption === "unbounded" ? Number.POSITIVE_INFINITY : Math.max(1, concurrencyOption);
2138
2153
  const items = Arr.fromIterable(iterable);
@@ -2206,7 +2221,8 @@ export const forEach = (iterable, f, options) => withFiber(parent => {
2206
2221
  /**
2207
2222
  * Effectfully filter the elements of the provided iterable.
2208
2223
  *
2209
- * Use the `concurrency` option to control how many elements are processed in parallel.
2224
+ * Use the `concurrency` option to control how many elements are processed
2225
+ * concurrently.
2210
2226
  *
2211
2227
  * @since 3.4.0
2212
2228
  * @experimental
@@ -2219,7 +2235,8 @@ export const filter = (iterable, f, options) => filterMap(iterable, a => map(f(a
2219
2235
  /**
2220
2236
  * Effectfully filter the elements of the provided iterable.
2221
2237
  *
2222
- * Use the `concurrency` option to control how many elements are processed in parallel.
2238
+ * Use the `concurrency` option to control how many elements are processed
2239
+ * concurrently.
2223
2240
  *
2224
2241
  * @since 3.4.0
2225
2242
  * @experimental
@@ -2277,21 +2294,21 @@ let_ as let };
2277
2294
  // fibers & forking
2278
2295
  // ----------------------------------------------------------------------------
2279
2296
  /**
2280
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
2297
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
2281
2298
  * aborted.
2282
2299
  *
2283
2300
  * When the parent `Micro` finishes, this `Micro` will be aborted.
2284
2301
  *
2285
2302
  * @since 3.4.0
2286
2303
  * @experimental
2287
- * @category handle & forking
2304
+ * @category fiber & forking
2288
2305
  */
2289
- export const fork = self => withFiber(fiber => {
2306
+ export const fork = self => withMicroFiber(fiber => {
2290
2307
  fiberMiddleware.interruptChildren ??= fiberInterruptChildren;
2291
2308
  return succeed(unsafeFork(fiber, self));
2292
2309
  });
2293
2310
  const unsafeFork = (parent, effect, immediate = false, daemon = false) => {
2294
- const child = new FiberImpl(parent.context, parent.interruptible);
2311
+ const child = new MicroFiberImpl(parent.context, parent.interruptible);
2295
2312
  if (!daemon) {
2296
2313
  parent.children().add(child);
2297
2314
  child.addObserver(() => parent.children().delete(child));
@@ -2304,51 +2321,48 @@ const unsafeFork = (parent, effect, immediate = false, daemon = false) => {
2304
2321
  return child;
2305
2322
  };
2306
2323
  /**
2307
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
2324
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
2308
2325
  * aborted.
2309
2326
  *
2310
2327
  * It will not be aborted when the parent `Micro` finishes.
2311
2328
  *
2312
2329
  * @since 3.4.0
2313
2330
  * @experimental
2314
- * @category handle & forking
2331
+ * @category fiber & forking
2315
2332
  */
2316
- export const forkDaemon = self => withFiber(fiber => succeed(unsafeFork(fiber, self, false, true)));
2333
+ export const forkDaemon = self => withMicroFiber(fiber => succeed(unsafeFork(fiber, self, false, true)));
2317
2334
  /**
2318
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
2335
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
2319
2336
  * aborted.
2320
2337
  *
2321
2338
  * The lifetime of the handle will be attached to the provided `MicroScope`.
2322
2339
  *
2323
2340
  * @since 3.4.0
2324
2341
  * @experimental
2325
- * @category handle & forking
2342
+ * @category fiber & forking
2326
2343
  */
2327
2344
  export const forkIn = /*#__PURE__*/dual(2, (self, scope) => uninterruptibleMask(restore => flatMap(scope.fork, scope => tap(restore(forkDaemon(onExit(self, exit => scope.close(exit)))), fiber => scope.addFinalizer(_ => fiberInterrupt(fiber))))));
2328
2345
  /**
2329
- * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
2346
+ * Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
2330
2347
  * aborted.
2331
2348
  *
2332
2349
  * The lifetime of the handle will be attached to the current `MicroScope`.
2333
2350
  *
2334
2351
  * @since 3.4.0
2335
2352
  * @experimental
2336
- * @category handle & forking
2353
+ * @category fiber & forking
2337
2354
  */
2338
2355
  export const forkScoped = self => flatMap(scope, scope => forkIn(self, scope));
2339
2356
  // ----------------------------------------------------------------------------
2340
2357
  // execution
2341
2358
  // ----------------------------------------------------------------------------
2342
2359
  /**
2343
- * Execute the `Micro` effect and return a `Handle` that can be awaited, joined,
2360
+ * Execute the `Micro` effect and return a `MicroFiber` that can be awaited, joined,
2344
2361
  * or aborted.
2345
2362
  *
2346
2363
  * You can listen for the result by adding an observer using the handle's
2347
2364
  * `addObserver` method.
2348
2365
  *
2349
- * @since 3.4.0
2350
- * @experimental
2351
- * @category execution
2352
2366
  * @example
2353
2367
  * ```ts
2354
2368
  * import * as Micro from "effect/Micro"
@@ -2362,9 +2376,13 @@ export const forkScoped = self => flatMap(scope, scope => forkIn(self, scope));
2362
2376
  * console.log(exit)
2363
2377
  * })
2364
2378
  * ```
2379
+ *
2380
+ * @since 3.4.0
2381
+ * @experimental
2382
+ * @category execution
2365
2383
  */
2366
2384
  export const runFork = (effect, options) => {
2367
- const fiber = new FiberImpl(CurrentScheduler.context(options?.scheduler ?? new MicroSchedulerDefault()));
2385
+ const fiber = new MicroFiberImpl(CurrentScheduler.context(options?.scheduler ?? new MicroSchedulerDefault()));
2368
2386
  fiber.evaluate(effect);
2369
2387
  if (options?.signal) {
2370
2388
  if (options.signal.aborted) {
@@ -2409,7 +2427,7 @@ export const runPromise = (effect, options) => runPromiseExit(effect, options).t
2409
2427
  * Attempt to execute the `Micro` effect synchronously and return the `MicroExit`.
2410
2428
  *
2411
2429
  * If any asynchronous effects are encountered, the function will return a
2412
- * `CauseDie` containing the `Handle`.
2430
+ * `CauseDie` containing the `MicroFiber`.
2413
2431
  *
2414
2432
  * @since 3.4.6
2415
2433
  * @experimental