effect 3.10.19 → 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/cjs/BigDecimal.js +125 -24
  2. package/dist/cjs/BigDecimal.js.map +1 -1
  3. package/dist/cjs/Channel.js +44 -4
  4. package/dist/cjs/Channel.js.map +1 -1
  5. package/dist/cjs/Config.js +8 -1
  6. package/dist/cjs/Config.js.map +1 -1
  7. package/dist/cjs/Context.js +26 -1
  8. package/dist/cjs/Context.js.map +1 -1
  9. package/dist/cjs/Cron.js +75 -67
  10. package/dist/cjs/Cron.js.map +1 -1
  11. package/dist/cjs/DateTime.js +114 -664
  12. package/dist/cjs/DateTime.js.map +1 -1
  13. package/dist/cjs/Effect.js +82 -4
  14. package/dist/cjs/Effect.js.map +1 -1
  15. package/dist/cjs/Inspectable.js +8 -4
  16. package/dist/cjs/Inspectable.js.map +1 -1
  17. package/dist/cjs/JSONSchema.js.map +1 -1
  18. package/dist/cjs/Micro.js +1099 -1072
  19. package/dist/cjs/Micro.js.map +1 -1
  20. package/dist/cjs/STM.js.map +1 -1
  21. package/dist/cjs/Schema.js +57 -8
  22. package/dist/cjs/Schema.js.map +1 -1
  23. package/dist/cjs/Sink.js +9 -1
  24. package/dist/cjs/Sink.js.map +1 -1
  25. package/dist/cjs/Stream.js +25 -7
  26. package/dist/cjs/Stream.js.map +1 -1
  27. package/dist/cjs/Utils.js +7 -1
  28. package/dist/cjs/Utils.js.map +1 -1
  29. package/dist/cjs/internal/channel/channelExecutor.js +5 -9
  30. package/dist/cjs/internal/channel/channelExecutor.js.map +1 -1
  31. package/dist/cjs/internal/channel.js +156 -130
  32. package/dist/cjs/internal/channel.js.map +1 -1
  33. package/dist/cjs/internal/config.js +13 -4
  34. package/dist/cjs/internal/config.js.map +1 -1
  35. package/dist/cjs/internal/context.js +46 -3
  36. package/dist/cjs/internal/context.js.map +1 -1
  37. package/dist/cjs/internal/dateTime.js +747 -0
  38. package/dist/cjs/internal/dateTime.js.map +1 -0
  39. package/dist/cjs/internal/fiberRuntime.js +34 -11
  40. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  41. package/dist/cjs/internal/groupBy.js +9 -3
  42. package/dist/cjs/internal/groupBy.js.map +1 -1
  43. package/dist/cjs/internal/layer.js +1 -1
  44. package/dist/cjs/internal/layer.js.map +1 -1
  45. package/dist/cjs/internal/mailbox.js +1 -1
  46. package/dist/cjs/internal/mailbox.js.map +1 -1
  47. package/dist/cjs/internal/sink.js +25 -21
  48. package/dist/cjs/internal/sink.js.map +1 -1
  49. package/dist/cjs/internal/stream.js +70 -71
  50. package/dist/cjs/internal/stream.js.map +1 -1
  51. package/dist/cjs/internal/version.js +1 -1
  52. package/dist/cjs/internal/version.js.map +1 -1
  53. package/dist/dts/BigDecimal.d.ts +56 -1
  54. package/dist/dts/BigDecimal.d.ts.map +1 -1
  55. package/dist/dts/Channel.d.ts +66 -5
  56. package/dist/dts/Channel.d.ts.map +1 -1
  57. package/dist/dts/Config.d.ts +23 -1
  58. package/dist/dts/Config.d.ts.map +1 -1
  59. package/dist/dts/Context.d.ts +111 -0
  60. package/dist/dts/Context.d.ts.map +1 -1
  61. package/dist/dts/Cron.d.ts +15 -6
  62. package/dist/dts/Cron.d.ts.map +1 -1
  63. package/dist/dts/DateTime.d.ts +40 -49
  64. package/dist/dts/DateTime.d.ts.map +1 -1
  65. package/dist/dts/Effect.d.ts +88 -1
  66. package/dist/dts/Effect.d.ts.map +1 -1
  67. package/dist/dts/Inspectable.d.ts.map +1 -1
  68. package/dist/dts/JSONSchema.d.ts +1 -0
  69. package/dist/dts/JSONSchema.d.ts.map +1 -1
  70. package/dist/dts/Micro.d.ts +875 -872
  71. package/dist/dts/Micro.d.ts.map +1 -1
  72. package/dist/dts/STM.d.ts +2 -0
  73. package/dist/dts/STM.d.ts.map +1 -1
  74. package/dist/dts/Schema.d.ts +32 -0
  75. package/dist/dts/Schema.d.ts.map +1 -1
  76. package/dist/dts/Sink.d.ts +8 -0
  77. package/dist/dts/Sink.d.ts.map +1 -1
  78. package/dist/dts/Stream.d.ts +50 -32
  79. package/dist/dts/Stream.d.ts.map +1 -1
  80. package/dist/dts/Utils.d.ts +4 -0
  81. package/dist/dts/Utils.d.ts.map +1 -1
  82. package/dist/dts/internal/context.d.ts +1 -1
  83. package/dist/dts/internal/context.d.ts.map +1 -1
  84. package/dist/dts/internal/dateTime.d.ts +2 -0
  85. package/dist/dts/internal/dateTime.d.ts.map +1 -0
  86. package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
  87. package/dist/dts/internal/stream.d.ts.map +1 -1
  88. package/dist/esm/BigDecimal.js +119 -20
  89. package/dist/esm/BigDecimal.js.map +1 -1
  90. package/dist/esm/Channel.js +42 -2
  91. package/dist/esm/Channel.js.map +1 -1
  92. package/dist/esm/Config.js +7 -0
  93. package/dist/esm/Config.js.map +1 -1
  94. package/dist/esm/Context.js +25 -0
  95. package/dist/esm/Context.js.map +1 -1
  96. package/dist/esm/Cron.js +75 -67
  97. package/dist/esm/Cron.js.map +1 -1
  98. package/dist/esm/DateTime.js +112 -627
  99. package/dist/esm/DateTime.js.map +1 -1
  100. package/dist/esm/Effect.js +77 -0
  101. package/dist/esm/Effect.js.map +1 -1
  102. package/dist/esm/Inspectable.js +8 -4
  103. package/dist/esm/Inspectable.js.map +1 -1
  104. package/dist/esm/JSONSchema.js.map +1 -1
  105. package/dist/esm/Micro.js +1077 -1047
  106. package/dist/esm/Micro.js.map +1 -1
  107. package/dist/esm/STM.js.map +1 -1
  108. package/dist/esm/Schema.js +54 -0
  109. package/dist/esm/Schema.js.map +1 -1
  110. package/dist/esm/Sink.js +8 -0
  111. package/dist/esm/Sink.js.map +1 -1
  112. package/dist/esm/Stream.js +23 -5
  113. package/dist/esm/Stream.js.map +1 -1
  114. package/dist/esm/Utils.js +5 -0
  115. package/dist/esm/Utils.js.map +1 -1
  116. package/dist/esm/internal/channel/channelExecutor.js +5 -7
  117. package/dist/esm/internal/channel/channelExecutor.js.map +1 -1
  118. package/dist/esm/internal/channel.js +152 -129
  119. package/dist/esm/internal/channel.js.map +1 -1
  120. package/dist/esm/internal/config.js +11 -3
  121. package/dist/esm/internal/config.js.map +1 -1
  122. package/dist/esm/internal/context.js +42 -2
  123. package/dist/esm/internal/context.js.map +1 -1
  124. package/dist/esm/internal/dateTime.js +704 -0
  125. package/dist/esm/internal/dateTime.js.map +1 -0
  126. package/dist/esm/internal/fiberRuntime.js +31 -9
  127. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  128. package/dist/esm/internal/groupBy.js +9 -3
  129. package/dist/esm/internal/groupBy.js.map +1 -1
  130. package/dist/esm/internal/layer.js +1 -1
  131. package/dist/esm/internal/layer.js.map +1 -1
  132. package/dist/esm/internal/mailbox.js +1 -1
  133. package/dist/esm/internal/mailbox.js.map +1 -1
  134. package/dist/esm/internal/sink.js +23 -20
  135. package/dist/esm/internal/sink.js.map +1 -1
  136. package/dist/esm/internal/stream.js +66 -69
  137. package/dist/esm/internal/stream.js.map +1 -1
  138. package/dist/esm/internal/version.js +1 -1
  139. package/dist/esm/internal/version.js.map +1 -1
  140. package/package.json +1 -1
  141. package/src/BigDecimal.ts +131 -21
  142. package/src/Channel.ts +81 -5
  143. package/src/Config.ts +24 -1
  144. package/src/Context.ts +119 -0
  145. package/src/Cron.ts +85 -68
  146. package/src/DateTime.ts +155 -757
  147. package/src/Effect.ts +340 -1
  148. package/src/Inspectable.ts +11 -7
  149. package/src/JSONSchema.ts +1 -0
  150. package/src/Micro.ts +2005 -1757
  151. package/src/STM.ts +2 -0
  152. package/src/Schema.ts +60 -0
  153. package/src/Sink.ts +11 -0
  154. package/src/Stream.ts +55 -44
  155. package/src/Utils.ts +8 -0
  156. package/src/internal/channel/channelExecutor.ts +37 -33
  157. package/src/internal/channel.ts +504 -467
  158. package/src/internal/config.ts +18 -6
  159. package/src/internal/context.ts +56 -4
  160. package/src/internal/dateTime.ts +1126 -0
  161. package/src/internal/fiberRuntime.ts +35 -16
  162. package/src/internal/groupBy.ts +13 -22
  163. package/src/internal/layer.ts +5 -8
  164. package/src/internal/mailbox.ts +6 -4
  165. package/src/internal/sink.ts +55 -35
  166. package/src/internal/stream.ts +299 -299
  167. package/src/internal/version.ts +1 -1
@@ -1,23 +1,17 @@
1
- /**
2
- * A lightweight alternative to the `Effect` data type, with a subset of the functionality.
3
- *
4
- * @since 3.4.0
5
- * @experimental
6
- */
7
- import type { Channel, ChannelTypeId } from "./Channel.js";
1
+ import type { Channel } from "./Channel.js";
8
2
  import * as Context from "./Context.js";
9
- import type { Effect, EffectTypeId, EffectUnify, EffectUnifyIgnore } from "./Effect.js";
3
+ import type { Effect, EffectUnify, EffectUnifyIgnore } from "./Effect.js";
4
+ import * as Effectable from "./Effectable.js";
10
5
  import * as Either from "./Either.js";
11
- import { type LazyArg } from "./Function.js";
6
+ import type { LazyArg } from "./Function.js";
12
7
  import type { TypeLambda } from "./HKT.js";
13
8
  import type { Inspectable } from "./Inspectable.js";
14
9
  import * as Option from "./Option.js";
15
- import { type Pipeable } from "./Pipeable.js";
16
- import { type Predicate, type Refinement } from "./Predicate.js";
17
- import type { ReadonlyRecord } from "./Record.js";
18
- import type { Sink, SinkTypeId } from "./Sink.js";
19
- import type { Stream, StreamTypeId } from "./Stream.js";
20
- import type { Concurrency, Covariant, Equals, NoInfer, NotFunction, Simplify } from "./Types.js";
10
+ import type { Pipeable } from "./Pipeable.js";
11
+ import type { Predicate, Refinement } from "./Predicate.js";
12
+ import type { Sink } from "./Sink.js";
13
+ import type { Stream } from "./Stream.js";
14
+ import type { Concurrency, Covariant, Equals, NotFunction, Simplify } from "./Types.js";
21
15
  import type * as Unify from "./Unify.js";
22
16
  import { YieldWrap } from "./Utils.js";
23
17
  /**
@@ -35,15 +29,15 @@ export type TypeId = typeof TypeId;
35
29
  /**
36
30
  * @since 3.4.0
37
31
  * @experimental
38
- * @category symbols
32
+ * @category MicroExit
39
33
  */
40
- export declare const runSymbol: unique symbol;
34
+ export declare const MicroExitTypeId: unique symbol;
41
35
  /**
42
36
  * @since 3.4.0
43
37
  * @experimental
44
- * @category symbols
38
+ * @category MicroExit
45
39
  */
46
- export type runSymbol = typeof runSymbol;
40
+ export type MicroExitTypeId = typeof TypeId;
47
41
  /**
48
42
  * A lightweight alternative to the `Effect` data type, with a subset of the functionality.
49
43
  *
@@ -53,7 +47,6 @@ export type runSymbol = typeof runSymbol;
53
47
  */
54
48
  export interface Micro<out A, out E = never, out R = never> extends Effect<A, E, R> {
55
49
  readonly [TypeId]: Micro.Variance<A, E, R>;
56
- [runSymbol](env: Env<any>, onExit: (exit: MicroExit<A, E>) => void): void;
57
50
  [Symbol.iterator](): MicroIterator<Micro<A, E, R>>;
58
51
  [Unify.typeSymbol]?: unknown;
59
52
  [Unify.unifySymbol]?: MicroUnify<this>;
@@ -126,32 +119,6 @@ export declare const isMicro: (u: unknown) => u is Micro<any, any, any>;
126
119
  export interface MicroIterator<T extends Micro<any, any, any>> {
127
120
  next(...args: ReadonlyArray<any>): IteratorResult<YieldWrap<T>, Micro.Success<T>>;
128
121
  }
129
- /**
130
- * @since 3.8.4
131
- * @experimental
132
- * @category models
133
- */
134
- export interface MicroClass {
135
- new <A, E = never, R = never>(): Micro<A, E, R>;
136
- }
137
- declare const MicroBase: MicroClass;
138
- /**
139
- * @since 3.8.4
140
- * @experimental
141
- * @category constructors
142
- */
143
- export declare abstract class Class<out A, out E = never, out R = never> extends MicroBase<A, E, R> {
144
- /**
145
- * @since 3.8.4
146
- * @experimental
147
- */
148
- abstract asMicro(): Micro<A, E, R>;
149
- /**
150
- * @since 3.8.4
151
- * @experimental
152
- */
153
- [runSymbol](env: Env<any>, onExit: (exit: MicroExit<A, E>) => void): void;
154
- }
155
122
  /**
156
123
  * @since 3.4.6
157
124
  * @experimental
@@ -286,1090 +253,1093 @@ export declare const causeWithTrace: {
286
253
  <E>(self: MicroCause<E>, trace: string): MicroCause<E>;
287
254
  };
288
255
  /**
289
- * @since 3.4.6
290
- * @experimental
291
- * @category MicroExit
292
- */
293
- export declare namespace MicroExit {
294
- /**
295
- * @since 3.4.6
296
- * @experimental
297
- * @category MicroExit
298
- */
299
- type Success<A, E = never> = Either.Right<MicroCause<E>, A>;
300
- /**
301
- * @since 3.4.6
302
- * @experimental
303
- * @category MicroExit
304
- */
305
- type Failure<A, E = never> = Either.Left<MicroCause<E>, A>;
306
- }
307
- /**
308
- * The MicroExit type is a data type that represents the result of a Micro
309
- * computation.
310
- *
311
- * It uses the `Either` data type to represent the success and failure cases.
312
- *
313
- * @since 3.4.6
256
+ * @since 3.11.0
314
257
  * @experimental
315
- * @category MicroExit
258
+ * @category Fiber
316
259
  */
317
- export type MicroExit<A, E = never> = MicroExit.Success<A, E> | MicroExit.Failure<A, E>;
260
+ export declare const FiberTypeId: unique symbol;
318
261
  /**
319
- * @since 3.4.6
262
+ * @since 3.11.0
320
263
  * @experimental
321
- * @category MicroExit
264
+ * @category Fiber
322
265
  */
323
- export declare const exitInterrupt: MicroExit<never>;
266
+ export type FiberTypeId = typeof FiberTypeId;
324
267
  /**
325
- * @since 3.4.6
268
+ * @since 3.11.0
326
269
  * @experimental
327
- * @category MicroExit
270
+ * @category Fiber
328
271
  */
329
- export declare const exitSucceed: <A>(a: A) => MicroExit<A, never>;
272
+ export interface Fiber<out A, out E = never> {
273
+ readonly [FiberTypeId]: Fiber.Variance<A, E>;
274
+ readonly currentOpCount: number;
275
+ readonly getRef: <I, A>(ref: Context.Reference<I, A>) => A;
276
+ readonly context: Context.Context<never>;
277
+ readonly addObserver: (cb: (exit: MicroExit<A, E>) => void) => () => void;
278
+ readonly unsafeInterrupt: () => void;
279
+ readonly unsafePoll: () => MicroExit<A, E> | undefined;
280
+ }
330
281
  /**
331
- * @since 3.4.6
282
+ * @since 3.11.0
332
283
  * @experimental
333
- * @category MicroExit
284
+ * @category Fiber
334
285
  */
335
- export declare const exitFail: <E>(e: E) => MicroExit<never, E>;
286
+ export declare namespace Fiber {
287
+ /**
288
+ * @since 3.11.0
289
+ * @experimental
290
+ * @category Fiber
291
+ */
292
+ interface Variance<out A, out E = never> {
293
+ readonly _A: Covariant<A>;
294
+ readonly _E: Covariant<E>;
295
+ }
296
+ }
297
+ declare class FiberImpl<in out A = any, in out E = any> implements Fiber<A, E> {
298
+ context: Context.Context<never>;
299
+ interruptible: boolean;
300
+ readonly [FiberTypeId]: Fiber.Variance<A, E>;
301
+ readonly _stack: Array<Primitive>;
302
+ readonly _observers: Array<(exit: MicroExit<A, E>) => void>;
303
+ _exit: MicroExit<A, E> | undefined;
304
+ _children: Set<FiberImpl<any, any>> | undefined;
305
+ currentOpCount: number;
306
+ constructor(context: Context.Context<never>, interruptible?: boolean);
307
+ getRef<I, A>(ref: Context.Reference<I, A>): A;
308
+ addObserver(cb: (exit: MicroExit<A, E>) => void): () => void;
309
+ _interrupted: boolean;
310
+ unsafeInterrupt(): void;
311
+ unsafePoll(): MicroExit<A, E> | undefined;
312
+ evaluate(effect: Primitive): void;
313
+ runLoop(effect: Primitive): MicroExit<A, E> | Yield;
314
+ getCont<S extends successCont | failureCont>(symbol: S): (Primitive & Record<S, (value: any, fiber: FiberImpl) => Primitive>) | undefined;
315
+ _yielded: MicroExit<any, any> | (() => void) | undefined;
316
+ yieldWith(value: MicroExit<any, any> | (() => void)): Yield;
317
+ children(): Set<Fiber<any, any>>;
318
+ }
336
319
  /**
337
- * @since 3.4.6
320
+ * @since 3.11.0
338
321
  * @experimental
339
- * @category MicroExit
322
+ * @category Fiber
340
323
  */
341
- export declare const exitDie: (defect: unknown) => MicroExit<never>;
324
+ export declare const fiberAwait: <A, E>(self: Fiber<A, E>) => Micro<MicroExit<A, E>>;
342
325
  /**
343
- * @since 3.4.6
326
+ * @since 3.11.0
344
327
  * @experimental
345
- * @category MicroExit
328
+ * @category Fiber
346
329
  */
347
- export declare const exitFailCause: <E>(cause: MicroCause<E>) => MicroExit<never, E>;
330
+ export declare const fiberInterrupt: <A, E>(self: Fiber<A, E>) => Micro<void>;
348
331
  /**
349
- * @since 3.4.6
332
+ * @since 3.11.0
350
333
  * @experimental
351
- * @category MicroExit
334
+ * @category Fiber
352
335
  */
353
- export declare const exitIsSuccess: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Success<A, E>;
336
+ export declare const fiberInterruptAll: <A extends Iterable<Fiber<any, any>>>(fibers: A) => Micro<void>;
337
+ declare const identifier: unique symbol;
338
+ type identifier = typeof identifier;
339
+ declare const evaluate: unique symbol;
340
+ type evaluate = typeof evaluate;
341
+ declare const successCont: unique symbol;
342
+ type successCont = typeof successCont;
343
+ declare const failureCont: unique symbol;
344
+ type failureCont = typeof failureCont;
345
+ declare const ensureCont: unique symbol;
346
+ type ensureCont = typeof ensureCont;
347
+ declare const Yield: unique symbol;
348
+ type Yield = typeof Yield;
349
+ interface Primitive {
350
+ readonly [identifier]: string;
351
+ readonly [successCont]: ((value: unknown, fiber: FiberImpl) => Primitive | Yield) | undefined;
352
+ readonly [failureCont]: ((cause: MicroCause<unknown>, fiber: FiberImpl) => Primitive | Yield) | undefined;
353
+ readonly [ensureCont]: ((fiber: FiberImpl) => ((value: unknown, fiber: FiberImpl) => Primitive | Yield) | undefined) | undefined;
354
+ [evaluate](fiber: FiberImpl): Primitive | Yield;
355
+ }
354
356
  /**
355
- * @since 3.4.6
357
+ * Creates a `Micro` effect that will succeed with the specified constant value.
358
+ *
359
+ * @since 3.4.0
356
360
  * @experimental
357
- * @category MicroExit
361
+ * @category constructors
358
362
  */
359
- export declare const exitIsFailure: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Failure<A, E>;
363
+ export declare const succeed: <A>(value: A) => Micro<A>;
360
364
  /**
365
+ * Creates a `Micro` effect that will fail with the specified `MicroCause`.
366
+ *
361
367
  * @since 3.4.6
362
368
  * @experimental
363
- * @category MicroExit
369
+ * @category constructors
364
370
  */
365
- export declare const exitIsInterrupt: <A, E>(self: MicroExit<A, E>) => self is Either.Left<MicroCause.Interrupt, A>;
371
+ export declare const failCause: <E>(cause: MicroCause<E>) => Micro<never, E>;
366
372
  /**
367
- * @since 3.4.6
373
+ * Creates a `Micro` effect that will fail with the specified error.
374
+ *
375
+ * This will result in a `CauseFail`, where the error is tracked at the
376
+ * type level.
377
+ *
378
+ * @since 3.4.0
368
379
  * @experimental
369
- * @category MicroExit
380
+ * @category constructors
370
381
  */
371
- export declare const exitIsFail: <A, E>(self: MicroExit<A, E>) => self is Either.Left<MicroCause.Fail<E>, A>;
382
+ export declare const fail: <E>(error: E) => Micro<never, E>;
372
383
  /**
373
- * @since 3.4.6
384
+ * Creates a `Micro` effect that will succeed with the lazily evaluated value.
385
+ *
386
+ * If the evaluation of the value throws an error, the effect will fail with
387
+ * `CauseDie`.
388
+ *
389
+ * @since 3.4.0
374
390
  * @experimental
375
- * @category MicroExit
391
+ * @category constructors
376
392
  */
377
- export declare const exitIsDie: <A, E>(self: MicroExit<A, E>) => self is Either.Left<MicroCause.Die, A>;
393
+ export declare const sync: <A>(evaluate: LazyArg<A>) => Micro<A>;
378
394
  /**
379
- * @since 3.4.6
395
+ * Lazily creates a `Micro` effect from the given side-effect.
396
+ *
397
+ * @since 3.4.0
380
398
  * @experimental
381
- * @category MicroExit
399
+ * @category constructors
382
400
  */
383
- export declare const exitVoid: MicroExit<void>;
401
+ export declare const suspend: <A, E, R>(evaluate: LazyArg<Micro<A, E, R>>) => Micro<A, E, R>;
384
402
  /**
403
+ * Pause the execution of the current `Micro` effect, and resume it on the next
404
+ * scheduler tick.
405
+ *
385
406
  * @since 3.4.0
386
407
  * @experimental
387
- * @category environment
408
+ * @category constructors
388
409
  */
389
- export declare const EnvTypeId: unique symbol;
410
+ export declare const yieldNowWith: (priority?: number) => Micro<void>;
390
411
  /**
412
+ * Pause the execution of the current `Micro` effect, and resume it on the next
413
+ * scheduler tick.
414
+ *
391
415
  * @since 3.4.0
392
416
  * @experimental
393
- * @category environment
417
+ * @category constructors
394
418
  */
395
- export type EnvTypeId = typeof EnvTypeId;
419
+ export declare const yieldNow: Micro<void>;
396
420
  /**
421
+ * Creates a `Micro` effect that will succeed with `Option.Some` of the value.
422
+ *
397
423
  * @since 3.4.0
398
424
  * @experimental
399
- * @category environment
425
+ * @category constructors
400
426
  */
401
- export interface Env<R> extends Pipeable {
402
- readonly [EnvTypeId]: {
403
- _R: Covariant<R>;
404
- };
405
- readonly refs: ReadonlyRecord<string, unknown>;
406
- }
427
+ export declare const succeedSome: <A>(a: A) => Micro<Option.Option<A>>;
407
428
  /**
429
+ * Creates a `Micro` effect that will succeed with `Option.None`.
430
+ *
408
431
  * @since 3.4.0
409
432
  * @experimental
410
- * @category environment
433
+ * @category constructors
411
434
  */
412
- export declare const envMake: <R = never>(refs: Record<string, unknown>) => Env<R>;
435
+ export declare const succeedNone: Micro<Option.Option<never>>;
413
436
  /**
437
+ * Creates a `Micro` effect that will fail with the lazily evaluated `MicroCause`.
438
+ *
414
439
  * @since 3.4.0
415
440
  * @experimental
416
- * @category environment
441
+ * @category constructors
417
442
  */
418
- export declare const envUnsafeMakeEmpty: () => Env<never>;
443
+ export declare const failCauseSync: <E>(evaluate: LazyArg<MicroCause<E>>) => Micro<never, E>;
419
444
  /**
445
+ * Creates a `Micro` effect that will die with the specified error.
446
+ *
447
+ * This will result in a `CauseDie`, where the error is not tracked at
448
+ * the type level.
449
+ *
420
450
  * @since 3.4.0
421
451
  * @experimental
422
- * @category environment
452
+ * @category constructors
423
453
  */
424
- export declare const envGet: {
425
- /**
426
- * @since 3.4.0
427
- * @experimental
428
- * @category environment
429
- */
430
- <A>(ref: EnvRef<A>): <R>(self: Env<R>) => A;
431
- /**
432
- * @since 3.4.0
433
- * @experimental
434
- * @category environment
435
- */
436
- <A, R>(self: Env<R>, ref: EnvRef<A>): A;
437
- };
454
+ export declare const die: (defect: unknown) => Micro<never>;
438
455
  /**
439
- * @since 3.4.0
456
+ * Creates a `Micro` effect that will fail with the lazily evaluated error.
457
+ *
458
+ * This will result in a `CauseFail`, where the error is tracked at the
459
+ * type level.
460
+ *
461
+ * @since 3.4.6
440
462
  * @experimental
441
- * @category environment
463
+ * @category constructors
442
464
  */
443
- export declare const envSet: {
444
- /**
445
- * @since 3.4.0
446
- * @experimental
447
- * @category environment
448
- */
449
- <A>(ref: EnvRef<A>, value: A): <R>(self: Env<R>) => Env<R>;
450
- /**
451
- * @since 3.4.0
452
- * @experimental
453
- * @category environment
454
- */
455
- <A, R>(self: Env<R>, ref: EnvRef<A>, value: A): Env<R>;
456
- };
465
+ export declare const failSync: <E>(error: LazyArg<E>) => Micro<never, E>;
457
466
  /**
467
+ * Converts an `Option` into a `Micro` effect, that will fail with
468
+ * `NoSuchElementException` if the option is `None`. Otherwise, it will succeed with the
469
+ * value of the option.
470
+ *
458
471
  * @since 3.4.0
459
472
  * @experimental
460
- * @category environment
473
+ * @category constructors
461
474
  */
462
- export declare const envMutate: {
463
- /**
464
- * @since 3.4.0
465
- * @experimental
466
- * @category environment
467
- */
468
- (f: (map: Record<string, unknown>) => void): <R>(self: Env<R>) => Env<R>;
469
- /**
470
- * @since 3.4.0
471
- * @experimental
472
- * @category environment
473
- */
474
- <R>(self: Env<R>, f: (map: Record<string, unknown>) => void): Env<R>;
475
- };
475
+ export declare const fromOption: <A>(option: Option.Option<A>) => Micro<A, NoSuchElementException>;
476
476
  /**
477
- * Access the given `Context.Tag` from the environment.
477
+ * Converts an `Either` into a `Micro` effect, that will fail with the left side
478
+ * of the either if it is a `Left`. Otherwise, it will succeed with the right
479
+ * side of the either.
478
480
  *
479
481
  * @since 3.4.0
480
482
  * @experimental
481
- * @category environment
483
+ * @category constructors
482
484
  */
483
- export declare const service: <I, S>(tag: Context.Tag<I, S>) => Micro<S, never, I>;
485
+ export declare const fromEither: <R, L>(either: Either.Either<R, L>) => Micro<R, L>;
486
+ declare const void_: Micro<void>;
487
+ export {
484
488
  /**
485
- * Access the given `Context.Tag` from the environment, without tracking the
486
- * dependency at the type level.
487
- *
488
- * It will return an `Option` of the service, depending on whether it is
489
- * available in the environment or not.
489
+ * A `Micro` effect that will succeed with `void` (`undefined`).
490
490
  *
491
491
  * @since 3.4.0
492
492
  * @experimental
493
- * @category environment
493
+ * @category constructors
494
494
  */
495
- export declare const serviceOption: <I, S>(tag: Context.Tag<I, S>) => Micro<Option.Option<S>>;
495
+ void_ as void };
496
+ declare const try_: <A, E>(options: {
497
+ try: LazyArg<A>;
498
+ catch: (error: unknown) => E;
499
+ }) => Micro<A, E>;
500
+ export {
496
501
  /**
497
- * Retrieve the current value of the given `EnvRef`.
502
+ * The `Micro` equivalent of a try / catch block, which allows you to map
503
+ * thrown errors to a specific error type.
498
504
  *
499
505
  * @since 3.4.0
500
506
  * @experimental
501
- * @category environment
507
+ * @category constructors
508
+ * @example
509
+ * ```ts
510
+ * import { Micro } from "effect"
511
+ *
512
+ * Micro.try({
513
+ * try: () => throw new Error("boom"),
514
+ * catch: (cause) => new Error("caught", { cause })
515
+ * })
516
+ * ```
502
517
  */
503
- export declare const getEnvRef: <A>(envRef: EnvRef<A>) => Micro<A>;
518
+ try_ as try };
504
519
  /**
505
- * Set the value of the given `EnvRef` for the duration of the effect.
520
+ * Wrap a `Promise` into a `Micro` effect. Any errors will result in a
521
+ * `CauseDie`.
506
522
  *
507
523
  * @since 3.4.0
508
524
  * @experimental
509
- * @category environment
525
+ * @category constructors
510
526
  */
511
- export declare const locally: {
512
- /**
513
- * Set the value of the given `EnvRef` for the duration of the effect.
514
- *
515
- * @since 3.4.0
516
- * @experimental
517
- * @category environment
518
- */
519
- <A>(fiberRef: EnvRef<A>, value: A): <XA, E, R>(self: Micro<XA, E, R>) => Micro<XA, E, R>;
520
- /**
521
- * Set the value of the given `EnvRef` for the duration of the effect.
522
- *
523
- * @since 3.4.0
524
- * @experimental
525
- * @category environment
526
- */
527
- <XA, E, R, A>(self: Micro<XA, E, R>, fiberRef: EnvRef<A>, value: A): Micro<XA, E, R>;
528
- };
527
+ export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Micro<A>;
529
528
  /**
530
- * Access the current `Context` from the environment.
529
+ * Wrap a `Promise` into a `Micro` effect. Any errors will be caught and
530
+ * converted into a specific error type.
531
531
  *
532
532
  * @since 3.4.0
533
533
  * @experimental
534
- * @category environment
534
+ * @category constructors
535
+ * @example
536
+ * ```ts
537
+ * import { Micro } from "effect"
538
+ *
539
+ * Micro.tryPromise({
540
+ * try: () => Promise.resolve("success"),
541
+ * catch: (cause) => new Error("caught", { cause })
542
+ * })
543
+ * ```
535
544
  */
536
- export declare const context: <R>() => Micro<Context.Context<R>>;
545
+ export declare const tryPromise: <A, E>(options: {
546
+ readonly try: (signal: AbortSignal) => PromiseLike<A>;
547
+ readonly catch: (error: unknown) => E;
548
+ }) => Micro<A, E>;
537
549
  /**
538
- * Merge the given `Context` with the current context.
550
+ * Create a `Micro` effect using the current `Fiber`.
539
551
  *
540
552
  * @since 3.4.0
541
553
  * @experimental
542
- * @category environment
554
+ * @category constructors
543
555
  */
544
- export declare const provideContext: {
556
+ export declare const withFiber: <A, E = never, R = never>(evaluate: (fiber: FiberImpl<A, E>) => Micro<A, E, R>) => Micro<A, E, R>;
557
+ /**
558
+ * Flush any yielded effects that are waiting to be executed.
559
+ *
560
+ * @since 3.4.0
561
+ * @experimental
562
+ * @category constructors
563
+ */
564
+ export declare const yieldFlush: Micro<void>;
565
+ /**
566
+ * Create a `Micro` effect from an asynchronous computation.
567
+ *
568
+ * You can return a cleanup effect that will be run when the effect is aborted.
569
+ * It is also passed an `AbortSignal` that is triggered when the effect is
570
+ * aborted.
571
+ *
572
+ * @since 3.4.0
573
+ * @experimental
574
+ * @category constructors
575
+ */
576
+ export declare const async: <A, E = never, R = never>(register: (resume: (effect: Micro<A, E, R>) => void, signal: AbortSignal) => void | Micro<void, never, R>) => Micro<A, E, R>;
577
+ /**
578
+ * A `Micro` that will never succeed or fail. It wraps `setInterval` to prevent
579
+ * the Javascript runtime from exiting.
580
+ *
581
+ * @since 3.4.0
582
+ * @experimental
583
+ * @category constructors
584
+ */
585
+ export declare const never: Micro<never>;
586
+ /**
587
+ * @since 3.4.0
588
+ * @experimental
589
+ * @category constructors
590
+ */
591
+ export declare const gen: <Self, Eff extends YieldWrap<Micro<any, any, any>>, AEff>(...args: [self: Self, body: (this: Self) => Generator<Eff, AEff, never>] | [body: () => Generator<Eff, AEff, never>]) => Micro<AEff, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Micro<infer _A, infer E, infer _R>>] ? E : never, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Micro<infer _A, infer _E, infer R>>] ? R : never>;
592
+ /**
593
+ * Create a `Micro` effect that will replace the success value of the given
594
+ * effect.
595
+ *
596
+ * @since 3.4.0
597
+ * @experimental
598
+ * @category mapping & sequencing
599
+ */
600
+ export declare const as: {
545
601
  /**
546
- * Merge the given `Context` with the current context.
602
+ * Create a `Micro` effect that will replace the success value of the given
603
+ * effect.
547
604
  *
548
605
  * @since 3.4.0
549
606
  * @experimental
550
- * @category environment
607
+ * @category mapping & sequencing
551
608
  */
552
- <XR>(context: Context.Context<XR>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Exclude<R, XR>>;
609
+ <A, B>(value: B): <E, R>(self: Micro<A, E, R>) => Micro<B, E, R>;
553
610
  /**
554
- * Merge the given `Context` with the current context.
611
+ * Create a `Micro` effect that will replace the success value of the given
612
+ * effect.
555
613
  *
556
614
  * @since 3.4.0
557
615
  * @experimental
558
- * @category environment
616
+ * @category mapping & sequencing
559
617
  */
560
- <A, E, R, XR>(self: Micro<A, E, R>, context: Context.Context<XR>): Micro<A, E, Exclude<R, XR>>;
618
+ <A, E, R, B>(self: Micro<A, E, R>, value: B): Micro<B, E, R>;
561
619
  };
562
620
  /**
563
- * Add the provided service to the current context.
621
+ * Wrap the success value of this `Micro` effect in an `Option.Some`.
564
622
  *
565
623
  * @since 3.4.0
566
624
  * @experimental
567
- * @category environment
625
+ * @category mapping & sequencing
568
626
  */
569
- export declare const provideService: {
627
+ export declare const asSome: <A, E, R>(self: Micro<A, E, R>) => Micro<Option.Option<A>, E, R>;
628
+ /**
629
+ * Swap the error and success types of the `Micro` effect.
630
+ *
631
+ * @since 3.4.0
632
+ * @experimental
633
+ * @category mapping & sequencing
634
+ */
635
+ export declare const flip: <A, E, R>(self: Micro<A, E, R>) => Micro<E, A, R>;
636
+ /**
637
+ * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
638
+ * a single api.
639
+ *
640
+ * It also allows you to pass in a `Micro` effect directly, which will be
641
+ * executed after the current effect.
642
+ *
643
+ * @since 3.4.0
644
+ * @experimental
645
+ * @category mapping & sequencing
646
+ */
647
+ export declare const andThen: {
570
648
  /**
571
- * Add the provided service to the current context.
649
+ * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
650
+ * a single api.
651
+ *
652
+ * It also allows you to pass in a `Micro` effect directly, which will be
653
+ * executed after the current effect.
572
654
  *
573
655
  * @since 3.4.0
574
656
  * @experimental
575
- * @category environment
657
+ * @category mapping & sequencing
576
658
  */
577
- <I, S>(tag: Context.Tag<I, S>, service: S): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Exclude<R, I>>;
659
+ <A, X>(f: (a: A) => X): <E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
578
660
  /**
579
- * Add the provided service to the current context.
661
+ * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
662
+ * a single api.
663
+ *
664
+ * It also allows you to pass in a `Micro` effect directly, which will be
665
+ * executed after the current effect.
580
666
  *
581
667
  * @since 3.4.0
582
668
  * @experimental
583
- * @category environment
669
+ * @category mapping & sequencing
584
670
  */
585
- <A, E, R, I, S>(self: Micro<A, E, R>, tag: Context.Tag<I, S>, service: S): Micro<A, E, Exclude<R, I>>;
586
- };
587
- /**
588
- * Create a service using the provided `Micro` effect, and add it to the
589
- * current context.
590
- *
591
- * @since 3.4.6
592
- * @experimental
593
- * @category environment
594
- */
595
- export declare const provideServiceEffect: {
671
+ <X>(f: NotFunction<X>): <A, E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
596
672
  /**
597
- * Create a service using the provided `Micro` effect, and add it to the
598
- * current context.
673
+ * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
674
+ * a single api.
599
675
  *
600
- * @since 3.4.6
676
+ * It also allows you to pass in a `Micro` effect directly, which will be
677
+ * executed after the current effect.
678
+ *
679
+ * @since 3.4.0
601
680
  * @experimental
602
- * @category environment
681
+ * @category mapping & sequencing
603
682
  */
604
- <I, S, E2, R2>(tag: Context.Tag<I, S>, acquire: Micro<S, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | E2, Exclude<R, I> | R2>;
683
+ <A, E, R, X>(self: Micro<A, E, R>, f: (a: A) => X): [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
605
684
  /**
606
- * Create a service using the provided `Micro` effect, and add it to the
607
- * current context.
685
+ * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
686
+ * a single api.
608
687
  *
609
- * @since 3.4.6
688
+ * It also allows you to pass in a `Micro` effect directly, which will be
689
+ * executed after the current effect.
690
+ *
691
+ * @since 3.4.0
610
692
  * @experimental
611
- * @category environment
693
+ * @category mapping & sequencing
612
694
  */
613
- <A, E, R, I, S, E2, R2>(self: Micro<A, E, R>, tag: Context.Tag<I, S>, acquire: Micro<S, E2, R2>): Micro<A, E | E2, Exclude<R, I> | R2>;
695
+ <A, E, R, X>(self: Micro<A, E, R>, f: NotFunction<X>): [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
614
696
  };
615
697
  /**
616
- * @since 3.5.9
617
- * @experimental
618
- * @category scheduler
619
- */
620
- export interface MicroScheduler {
621
- readonly scheduleTask: (task: () => void, priority: number) => void;
622
- readonly shouldYield: (env: Env<unknown>) => boolean;
623
- readonly flush: () => void;
624
- }
625
- /**
626
- * @since 3.5.9
698
+ * Execute a side effect from the success value of the `Micro` effect.
699
+ *
700
+ * It is similar to the `andThen` api, but the success value is ignored.
701
+ *
702
+ * @since 3.4.0
627
703
  * @experimental
628
- * @category scheduler
704
+ * @category mapping & sequencing
629
705
  */
630
- export declare class MicroSchedulerDefault implements MicroScheduler {
631
- private tasks;
632
- private running;
633
- /**
634
- * @since 3.5.9
635
- */
636
- scheduleTask(task: () => void, _priority: number): void;
706
+ export declare const tap: {
637
707
  /**
638
- * @since 3.5.9
708
+ * Execute a side effect from the success value of the `Micro` effect.
709
+ *
710
+ * It is similar to the `andThen` api, but the success value is ignored.
711
+ *
712
+ * @since 3.4.0
713
+ * @experimental
714
+ * @category mapping & sequencing
639
715
  */
640
- afterScheduled: () => void;
716
+ <A, X>(f: (a: NoInfer<A>) => X): <E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
641
717
  /**
642
- * @since 3.5.9
718
+ * Execute a side effect from the success value of the `Micro` effect.
719
+ *
720
+ * It is similar to the `andThen` api, but the success value is ignored.
721
+ *
722
+ * @since 3.4.0
723
+ * @experimental
724
+ * @category mapping & sequencing
643
725
  */
644
- runTasks(): void;
726
+ <X>(f: NotFunction<X>): <A, E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
645
727
  /**
646
- * @since 3.5.9
728
+ * Execute a side effect from the success value of the `Micro` effect.
729
+ *
730
+ * It is similar to the `andThen` api, but the success value is ignored.
731
+ *
732
+ * @since 3.4.0
733
+ * @experimental
734
+ * @category mapping & sequencing
647
735
  */
648
- shouldYield(_env: Env<unknown>): boolean;
736
+ <A, E, R, X>(self: Micro<A, E, R>, f: (a: NoInfer<A>) => X): [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
649
737
  /**
650
- * @since 3.5.9
738
+ * Execute a side effect from the success value of the `Micro` effect.
739
+ *
740
+ * It is similar to the `andThen` api, but the success value is ignored.
741
+ *
742
+ * @since 3.4.0
743
+ * @experimental
744
+ * @category mapping & sequencing
651
745
  */
652
- flush(): void;
653
- }
746
+ <A, E, R, X>(self: Micro<A, E, R>, f: NotFunction<X>): [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
747
+ };
654
748
  /**
749
+ * Replace the success value of the `Micro` effect with `void`.
750
+ *
655
751
  * @since 3.4.0
656
752
  * @experimental
657
- * @category environment
753
+ * @category mapping & sequencing
658
754
  */
659
- export declare const EnvRefTypeId: unique symbol;
755
+ export declare const asVoid: <A, E, R>(self: Micro<A, E, R>) => Micro<void, E, R>;
660
756
  /**
661
- * @since 3.4.0
757
+ * Access the `MicroExit` of the given `Micro` effect.
758
+ *
759
+ * @since 3.4.6
662
760
  * @experimental
663
- * @category environment
761
+ * @category mapping & sequencing
664
762
  */
665
- export type EnvRefTypeId = typeof EnvRefTypeId;
763
+ export declare const exit: <A, E, R>(self: Micro<A, E, R>) => Micro<MicroExit<A, E>, never, R>;
666
764
  /**
765
+ * Replace the error type of the given `Micro` with the full `MicroCause` object.
766
+ *
667
767
  * @since 3.4.0
668
768
  * @experimental
669
- * @category environment
769
+ * @category mapping & sequencing
670
770
  */
671
- export interface EnvRef<A> extends Micro<A> {
672
- readonly [EnvRefTypeId]: EnvRefTypeId;
673
- readonly key: string;
674
- readonly initial: A;
675
- [Unify.typeSymbol]?: unknown;
676
- [Unify.unifySymbol]?: EnvRefUnify<this>;
677
- [Unify.ignoreSymbol]?: EnvRefUnifyIgnore;
678
- }
771
+ export declare const sandbox: <A, E, R>(self: Micro<A, E, R>) => Micro<A, MicroCause<E>, R>;
679
772
  /**
680
- * @category models
681
- * @since 3.8.4
773
+ * Returns an effect that races all the specified effects,
774
+ * yielding the value of the first effect to succeed with a value. Losers of
775
+ * the race will be interrupted immediately
776
+ *
777
+ * @since 3.4.0
682
778
  * @experimental
779
+ * @category sequencing
683
780
  */
684
- export interface EnvRefUnify<A extends {
685
- [Unify.typeSymbol]?: any;
686
- }> extends MicroUnify<A> {
687
- EnvRef?: () => A[Unify.typeSymbol] extends EnvRef<infer A0> | infer _ ? EnvRef<A0> : never;
688
- }
689
- /**
690
- * @category models
691
- * @since 3.8.4
692
- * @experimental
693
- */
694
- export interface EnvRefUnifyIgnore extends MicroUnifyIgnore {
695
- Micro?: true;
696
- }
697
- /**
698
- * @since 3.4.0
699
- * @experimental
700
- * @category environment refs
701
- */
702
- export declare const envRefMake: <A>(key: string, initial: LazyArg<A>) => EnvRef<A>;
703
- /**
704
- * @since 3.4.0
705
- * @experimental
706
- * @category environment refs
707
- */
708
- export declare const currentAbortController: EnvRef<AbortController>;
709
- /**
710
- * @since 3.4.0
711
- * @experimental
712
- * @category environment refs
713
- */
714
- export declare const currentAbortSignal: EnvRef<AbortSignal>;
715
- /**
716
- * @since 3.4.0
717
- * @experimental
718
- * @category environment refs
719
- */
720
- export declare const currentContext: EnvRef<Context.Context<never>>;
721
- /**
722
- * @since 3.4.0
723
- * @experimental
724
- * @category environment refs
725
- */
726
- export declare const currentConcurrency: EnvRef<"unbounded" | number>;
727
- /**
728
- * @since 3.4.0
729
- * @experimental
730
- * @category environment refs
731
- */
732
- export declare const currentMaxDepthBeforeYield: EnvRef<number>;
781
+ export declare const raceAll: <Eff extends Micro<any, any, any>>(all: Iterable<Eff>) => Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>>;
733
782
  /**
783
+ * Returns an effect that races all the specified effects,
784
+ * yielding the value of the first effect to succeed or fail. Losers of
785
+ * the race will be interrupted immediately
786
+ *
734
787
  * @since 3.4.0
735
788
  * @experimental
736
- * @category environment refs
789
+ * @category sequencing
737
790
  */
738
- export declare const currentScheduler: EnvRef<MicroScheduler>;
791
+ export declare const raceAllFirst: <Eff extends Micro<any, any, any>>(all: Iterable<Eff>) => Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>>;
739
792
  /**
740
- * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
741
- * api to control the concurrency of that `Micro` when it is run.
793
+ * Returns an effect that races two effects, yielding the value of the first
794
+ * effect to succeed. Losers of the race will be interrupted immediately
742
795
  *
743
796
  * @since 3.4.0
744
797
  * @experimental
745
- * @category environment refs
746
- * @example
747
- * ```ts
748
- * import * as Micro from "effect/Micro"
749
- *
750
- * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
751
- * concurrency: "inherit"
752
- * }).pipe(
753
- * Micro.withConcurrency(2) // use a concurrency of 2
754
- * )
755
- * ```
798
+ * @category sequencing
756
799
  */
757
- export declare const withConcurrency: {
800
+ export declare const race: {
758
801
  /**
759
- * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
760
- * api to control the concurrency of that `Micro` when it is run.
802
+ * Returns an effect that races two effects, yielding the value of the first
803
+ * effect to succeed. Losers of the race will be interrupted immediately
761
804
  *
762
805
  * @since 3.4.0
763
806
  * @experimental
764
- * @category environment refs
765
- * @example
766
- * ```ts
767
- * import * as Micro from "effect/Micro"
768
- *
769
- * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
770
- * concurrency: "inherit"
771
- * }).pipe(
772
- * Micro.withConcurrency(2) // use a concurrency of 2
773
- * )
774
- * ```
807
+ * @category sequencing
775
808
  */
776
- (concurrency: "unbounded" | number): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
809
+ <A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
777
810
  /**
778
- * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
779
- * api to control the concurrency of that `Micro` when it is run.
811
+ * Returns an effect that races two effects, yielding the value of the first
812
+ * effect to succeed. Losers of the race will be interrupted immediately
780
813
  *
781
814
  * @since 3.4.0
782
815
  * @experimental
783
- * @category environment refs
784
- * @example
785
- * ```ts
786
- * import * as Micro from "effect/Micro"
787
- *
788
- * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
789
- * concurrency: "inherit"
790
- * }).pipe(
791
- * Micro.withConcurrency(2) // use a concurrency of 2
792
- * )
793
- * ```
816
+ * @category sequencing
794
817
  */
795
- <A, E, R>(self: Micro<A, E, R>, concurrency: "unbounded" | number): Micro<A, E, R>;
818
+ <A, E, R, A2, E2, R2>(self: Micro<A, E, R>, that: Micro<A2, E2, R2>): Micro<A | A2, E | E2, R | R2>;
796
819
  };
797
820
  /**
798
- * A low-level constructor for creating a `Micro` effect. It takes a function
799
- * that receives an environment and a callback which should be called with the
800
- * result of the effect.
801
- *
802
- * @since 3.4.0
803
- * @experimental
804
- * @category constructors
805
- */
806
- export declare const make: <R, A, E>(run: (env: Env<R>, onExit: (exit: MicroExit<A, E>) => void) => void) => Micro<A, E, R>;
807
- /**
808
- * Converts a `MicroExit` into a `Micro` effect.
809
- *
810
- * @since 3.4.6
811
- * @experimental
812
- * @category constructors
813
- */
814
- export declare const fromExit: <A, E>(self: MicroExit<A, E>) => Micro<A, E>;
815
- /**
816
- * Converts a lazy `MicroExit` into a `Micro` effect.
817
- *
818
- * @since 3.4.6
819
- * @experimental
820
- * @category constructors
821
- */
822
- export declare const fromExitSync: <A, E>(self: LazyArg<MicroExit<A, E>>) => Micro<A, E>;
823
- /**
824
- * Creates a `Micro` effect that will succeed with the specified constant value.
825
- *
826
- * @since 3.4.0
827
- * @experimental
828
- * @category constructors
829
- */
830
- export declare const succeed: <A>(a: A) => Micro<A>;
831
- /**
832
- * Creates a `Micro` effect that will succeed with `Option.Some` of the value.
821
+ * Returns an effect that races two effects, yielding the value of the first
822
+ * effect to succeed *or* fail. Losers of the race will be interrupted immediately
833
823
  *
834
824
  * @since 3.4.0
835
825
  * @experimental
836
- * @category constructors
826
+ * @category sequencing
837
827
  */
838
- export declare const succeedSome: <A>(a: A) => Micro<Option.Option<A>>;
828
+ export declare const raceFirst: {
829
+ /**
830
+ * Returns an effect that races two effects, yielding the value of the first
831
+ * effect to succeed *or* fail. Losers of the race will be interrupted immediately
832
+ *
833
+ * @since 3.4.0
834
+ * @experimental
835
+ * @category sequencing
836
+ */
837
+ <A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
838
+ /**
839
+ * Returns an effect that races two effects, yielding the value of the first
840
+ * effect to succeed *or* fail. Losers of the race will be interrupted immediately
841
+ *
842
+ * @since 3.4.0
843
+ * @experimental
844
+ * @category sequencing
845
+ */
846
+ <A, E, R, A2, E2, R2>(self: Micro<A, E, R>, that: Micro<A2, E2, R2>): Micro<A | A2, E | E2, R | R2>;
847
+ };
839
848
  /**
840
- * Creates a `Micro` effect that will succeed with `Option.None`.
849
+ * Map the success value of this `Micro` effect to another `Micro` effect, then
850
+ * flatten the result.
841
851
  *
842
852
  * @since 3.4.0
843
853
  * @experimental
844
- * @category constructors
854
+ * @category mapping & sequencing
845
855
  */
846
- export declare const succeedNone: Micro<Option.Option<never>>;
856
+ export declare const flatMap: {
857
+ /**
858
+ * Map the success value of this `Micro` effect to another `Micro` effect, then
859
+ * flatten the result.
860
+ *
861
+ * @since 3.4.0
862
+ * @experimental
863
+ * @category mapping & sequencing
864
+ */
865
+ <A, B, E2, R2>(f: (a: A) => Micro<B, E2, R2>): <E, R>(self: Micro<A, E, R>) => Micro<B, E | E2, R | R2>;
866
+ /**
867
+ * Map the success value of this `Micro` effect to another `Micro` effect, then
868
+ * flatten the result.
869
+ *
870
+ * @since 3.4.0
871
+ * @experimental
872
+ * @category mapping & sequencing
873
+ */
874
+ <A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (a: A) => Micro<B, E2, R2>): Micro<B, E | E2, R | R2>;
875
+ };
847
876
  /**
848
- * Creates a `Micro` effect that will fail with the specified error.
849
- *
850
- * This will result in a `CauseFail`, where the error is tracked at the
851
- * type level.
877
+ * Flattens any nested `Micro` effects, merging the error and requirement types.
852
878
  *
853
879
  * @since 3.4.0
854
880
  * @experimental
855
- * @category constructors
881
+ * @category mapping & sequencing
856
882
  */
857
- export declare const fail: <E>(e: E) => Micro<never, E>;
883
+ export declare const flatten: <A, E, R, E2, R2>(self: Micro<Micro<A, E, R>, E2, R2>) => Micro<A, E | E2, R | R2>;
858
884
  /**
859
- * Creates a `Micro` effect that will fail with the lazily evaluated error.
860
- *
861
- * This will result in a `CauseFail`, where the error is tracked at the
862
- * type level.
885
+ * Transforms the success value of the `Micro` effect with the specified
886
+ * function.
863
887
  *
864
888
  * @since 3.4.0
865
889
  * @experimental
866
- * @category constructors
890
+ * @category mapping & sequencing
867
891
  */
868
- export declare const failSync: <E>(e: LazyArg<E>) => Micro<never, E>;
892
+ export declare const map: {
893
+ /**
894
+ * Transforms the success value of the `Micro` effect with the specified
895
+ * function.
896
+ *
897
+ * @since 3.4.0
898
+ * @experimental
899
+ * @category mapping & sequencing
900
+ */
901
+ <A, B>(f: (a: A) => B): <E, R>(self: Micro<A, E, R>) => Micro<B, E, R>;
902
+ /**
903
+ * Transforms the success value of the `Micro` effect with the specified
904
+ * function.
905
+ *
906
+ * @since 3.4.0
907
+ * @experimental
908
+ * @category mapping & sequencing
909
+ */
910
+ <A, E, R, B>(self: Micro<A, E, R>, f: (a: A) => B): Micro<B, E, R>;
911
+ };
869
912
  /**
870
- * Creates a `Micro` effect that will die with the specified error.
871
- *
872
- * This will result in a `CauseDie`, where the error is not tracked at
873
- * the type level.
913
+ * The MicroExit type is a data type that represents the result of a Micro
914
+ * computation.
874
915
  *
875
- * @since 3.4.0
876
- * @experimental
877
- * @category constructors
878
- */
879
- export declare const die: (defect: unknown) => Micro<never>;
880
- /**
881
- * Creates a `Micro` effect that will fail with the specified `MicroCause`.
916
+ * It uses the `Either` data type to represent the success and failure cases.
882
917
  *
883
918
  * @since 3.4.6
884
919
  * @experimental
885
- * @category constructors
920
+ * @category MicroExit
886
921
  */
887
- export declare const failCause: <E>(cause: MicroCause<E>) => Micro<never, E>;
922
+ export type MicroExit<A, E = never> = MicroExit.Success<A, E> | MicroExit.Failure<A, E>;
888
923
  /**
889
- * Creates a `Micro` effect that will fail with the lazily evaluated `MicroCause`.
890
- *
891
924
  * @since 3.4.6
892
925
  * @experimental
893
- * @category constructors
894
- */
895
- export declare const failCauseSync: <E>(cause: LazyArg<MicroCause<E>>) => Micro<never, E>;
896
- /**
897
- * Creates a `Micro` effect that will succeed with the lazily evaluated value.
898
- *
899
- * If the evaluation of the value throws an error, the effect will fail with
900
- * `CauseDie`.
901
- *
902
- * @since 3.4.0
903
- * @experimental
904
- * @category constructors
926
+ * @category MicroExit
905
927
  */
906
- export declare const sync: <A>(evaluate: LazyArg<A>) => Micro<A>;
928
+ export declare namespace MicroExit {
929
+ /**
930
+ * @since 3.4.6
931
+ * @experimental
932
+ * @category MicroExit
933
+ */
934
+ interface Proto<out A, out E = never> extends Micro<A, E> {
935
+ readonly [MicroExitTypeId]: MicroExitTypeId;
936
+ }
937
+ /**
938
+ * @since 3.4.6
939
+ * @experimental
940
+ * @category MicroExit
941
+ */
942
+ interface Success<out A, out E> extends Proto<A, E> {
943
+ readonly _tag: "Success";
944
+ readonly value: A;
945
+ }
946
+ /**
947
+ * @since 3.4.6
948
+ * @experimental
949
+ * @category MicroExit
950
+ */
951
+ interface Failure<out A, out E> extends Proto<A, E> {
952
+ readonly _tag: "Failure";
953
+ readonly cause: MicroCause<E>;
954
+ }
955
+ }
907
956
  /**
908
- * Converts an `Option` into a `Micro` effect, that will fail with
909
- * `NoSuchElementException` if the option is `None`. Otherwise, it will succeed with the
910
- * value of the option.
911
- *
912
- * @since 3.4.0
957
+ * @since 3.4.6
913
958
  * @experimental
914
- * @category constructors
959
+ * @category MicroExit
915
960
  */
916
- export declare const fromOption: <A>(option: Option.Option<A>) => Micro<A, NoSuchElementException>;
961
+ export declare const isMicroExit: (u: unknown) => u is MicroExit<unknown, unknown>;
917
962
  /**
918
- * Converts an `Either` into a `Micro` effect, that will fail with the left side
919
- * of the either if it is a `Left`. Otherwise, it will succeed with the right
920
- * side of the either.
921
- *
922
- * @since 3.4.0
963
+ * @since 3.4.6
923
964
  * @experimental
924
- * @category constructors
965
+ * @category MicroExit
925
966
  */
926
- export declare const fromEither: <R, L>(either: Either.Either<R, L>) => Micro<R, L>;
967
+ export declare const exitSucceed: <A>(a: A) => MicroExit<A, never>;
927
968
  /**
928
- * Lazily creates a `Micro` effect from the given side-effect.
929
- *
930
- * @since 3.4.0
969
+ * @since 3.4.6
931
970
  * @experimental
932
- * @category constructors
971
+ * @category MicroExit
933
972
  */
934
- export declare const suspend: <A, E, R>(evaluate: LazyArg<Micro<A, E, R>>) => Micro<A, E, R>;
935
- declare const void_: Micro<void>;
936
- export {
973
+ export declare const exitFailCause: <E>(cause: MicroCause<E>) => MicroExit<never, E>;
937
974
  /**
938
- * A `Micro` effect that will succeed with `void` (`undefined`).
939
- *
940
- * @since 3.4.0
975
+ * @since 3.4.6
941
976
  * @experimental
942
- * @category constructors
977
+ * @category MicroExit
943
978
  */
944
- void_ as void };
979
+ export declare const exitInterrupt: MicroExit<never>;
945
980
  /**
946
- * Create a `Micro` effect from an asynchronous computation.
947
- *
948
- * You can return a cleanup effect that will be run when the effect is aborted.
949
- * It is also passed an `AbortSignal` that is triggered when the effect is
950
- * aborted.
951
- *
952
- * @since 3.4.0
981
+ * @since 3.4.6
953
982
  * @experimental
954
- * @category constructors
983
+ * @category MicroExit
955
984
  */
956
- export declare const async: <A, E = never, R = never>(register: (resume: (effect: Micro<A, E, R>) => void, signal: AbortSignal) => void | Micro<void, never, R>) => Micro<A, E, R>;
957
- declare const try_: <A, E>(options: {
958
- try: LazyArg<A>;
959
- catch: (error: unknown) => E;
960
- }) => Micro<A, E>;
961
- export {
985
+ export declare const exitFail: <E>(e: E) => MicroExit<never, E>;
962
986
  /**
963
- * The `Micro` equivalent of a try / catch block, which allows you to map
964
- * thrown errors to a specific error type.
965
- *
966
- * @since 3.4.0
987
+ * @since 3.4.6
967
988
  * @experimental
968
- * @category constructors
969
- * @example
970
- * ```ts
971
- * import { Micro } from "effect"
972
- *
973
- * Micro.try({
974
- * try: () => throw new Error("boom"),
975
- * catch: (cause) => new Error("caught", { cause })
976
- * })
977
- * ```
989
+ * @category MicroExit
978
990
  */
979
- try_ as try };
991
+ export declare const exitDie: (defect: unknown) => MicroExit<never>;
980
992
  /**
981
- * Wrap a `Promise` into a `Micro` effect. Any errors will result in a
982
- * `CauseDie`.
983
- *
984
- * @since 3.4.0
993
+ * @since 3.4.6
985
994
  * @experimental
986
- * @category constructors
995
+ * @category MicroExit
987
996
  */
988
- export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Micro<A>;
997
+ export declare const exitIsSuccess: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Success<A, E>;
989
998
  /**
990
- * Wrap a `Promise` into a `Micro` effect. Any errors will be caught and
991
- * converted into a specific error type.
992
- *
993
- * @since 3.4.0
999
+ * @since 3.4.6
994
1000
  * @experimental
995
- * @category constructors
996
- * @example
997
- * ```ts
998
- * import { Micro } from "effect"
999
- *
1000
- * Micro.tryPromise({
1001
- * try: () => Promise.resolve("success"),
1002
- * catch: (cause) => new Error("caught", { cause })
1003
- * })
1004
- * ```
1001
+ * @category MicroExit
1005
1002
  */
1006
- export declare const tryPromise: <A, E>(options: {
1007
- readonly try: (signal: AbortSignal) => PromiseLike<A>;
1008
- readonly catch: (error: unknown) => E;
1009
- }) => Micro<A, E>;
1003
+ export declare const exitIsFailure: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Failure<A, E>;
1010
1004
  /**
1011
- * Pause the execution of the current `Micro` effect, and resume it on the next
1012
- * iteration of the event loop.
1013
- *
1014
- * You can specify a priority for the task, which will determine when it is
1015
- * executed relative to other tasks.
1016
- *
1017
- * @since 3.4.0
1005
+ * @since 3.4.6
1018
1006
  * @experimental
1019
- * @category constructors
1007
+ * @category MicroExit
1020
1008
  */
1021
- export declare const yieldWithPriority: (priority: number) => Micro<void>;
1009
+ export declare const exitIsInterrupt: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Failure<A, E> & {
1010
+ readonly cause: MicroCause.Interrupt;
1011
+ };
1022
1012
  /**
1023
- * Pause the execution of the current `Micro` effect, and resume it on the next
1024
- * iteration of the event loop.
1025
- *
1026
- * @since 3.4.0
1013
+ * @since 3.4.6
1027
1014
  * @experimental
1028
- * @category constructors
1015
+ * @category MicroExit
1029
1016
  */
1030
- export declare const yieldNow: Micro<void>;
1017
+ export declare const exitIsFail: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Failure<A, E> & {
1018
+ readonly cause: MicroCause.Fail<E>;
1019
+ };
1031
1020
  /**
1032
- * Flush any yielded effects that are waiting to be executed.
1033
- *
1034
- * @since 3.4.0
1021
+ * @since 3.4.6
1035
1022
  * @experimental
1036
- * @category constructors
1023
+ * @category MicroExit
1037
1024
  */
1038
- export declare const yieldFlush: Micro<void>;
1039
- /**
1040
- * A `Micro` that will never succeed or fail. It wraps `setInterval` to prevent
1041
- * the Javascript runtime from exiting.
1042
- *
1043
- * @since 3.4.0
1025
+ export declare const exitIsDie: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Failure<A, E> & {
1026
+ readonly cause: MicroCause.Die;
1027
+ };
1028
+ /**
1029
+ * @since 3.4.6
1044
1030
  * @experimental
1045
- * @category constructors
1031
+ * @category MicroExit
1046
1032
  */
1047
- export declare const never: Micro<never>;
1033
+ export declare const exitVoid: MicroExit<void>;
1048
1034
  /**
1049
- * @since 3.4.0
1035
+ * @since 3.11.0
1050
1036
  * @experimental
1051
- * @category constructors
1037
+ * @category MicroExit
1052
1038
  */
1053
- export declare const gen: <Self, Eff extends YieldWrap<Micro<any, any, any>>, AEff>(...args: [self: Self, body: (this: Self) => Generator<Eff, AEff, never>] | [body: () => Generator<Eff, AEff, never>]) => Micro<AEff, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Micro<infer _A, infer E, infer _R>>] ? E : never, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Micro<infer _A, infer _E, infer R>>] ? R : never>;
1039
+ export declare const exitVoidAll: <I extends Iterable<MicroExit<any, any>>>(exits: I) => MicroExit<void, I extends Iterable<MicroExit<infer _A, infer _E>> ? _E : never>;
1054
1040
  /**
1055
- * Flattens any nested `Micro` effects, merging the error and requirement types.
1056
- *
1057
- * @since 3.4.0
1041
+ * @since 3.5.9
1058
1042
  * @experimental
1059
- * @category mapping & sequencing
1043
+ * @category scheduler
1060
1044
  */
1061
- export declare const flatten: <A, E, R, E2, R2>(self: Micro<Micro<A, E, R>, E2, R2>) => Micro<A, E | E2, R | R2>;
1045
+ export interface MicroScheduler {
1046
+ readonly scheduleTask: (task: () => void, priority: number) => void;
1047
+ readonly shouldYield: (fiber: Fiber<unknown, unknown>) => boolean;
1048
+ readonly flush: () => void;
1049
+ }
1062
1050
  /**
1063
- * Transforms the success value of the `Micro` effect with the specified
1064
- * function.
1065
- *
1066
- * @since 3.4.0
1051
+ * @since 3.5.9
1067
1052
  * @experimental
1068
- * @category mapping & sequencing
1053
+ * @category scheduler
1069
1054
  */
1070
- export declare const map: {
1055
+ export declare class MicroSchedulerDefault implements MicroScheduler {
1056
+ private tasks;
1057
+ private running;
1071
1058
  /**
1072
- * Transforms the success value of the `Micro` effect with the specified
1073
- * function.
1074
- *
1075
- * @since 3.4.0
1076
- * @experimental
1077
- * @category mapping & sequencing
1059
+ * @since 3.5.9
1078
1060
  */
1079
- <A, B>(f: (a: A) => B): <E, R>(self: Micro<A, E, R>) => Micro<B, E, R>;
1061
+ scheduleTask(task: () => void, _priority: number): void;
1080
1062
  /**
1081
- * Transforms the success value of the `Micro` effect with the specified
1082
- * function.
1083
- *
1084
- * @since 3.4.0
1085
- * @experimental
1086
- * @category mapping & sequencing
1063
+ * @since 3.5.9
1087
1064
  */
1088
- <A, E, R, B>(self: Micro<A, E, R>, f: (a: A) => B): Micro<B, E, R>;
1089
- };
1065
+ afterScheduled: () => void;
1066
+ /**
1067
+ * @since 3.5.9
1068
+ */
1069
+ runTasks(): void;
1070
+ /**
1071
+ * @since 3.5.9
1072
+ */
1073
+ shouldYield(fiber: Fiber<unknown, unknown>): boolean;
1074
+ /**
1075
+ * @since 3.5.9
1076
+ */
1077
+ flush(): void;
1078
+ }
1090
1079
  /**
1091
- * Create a `Micro` effect that will replace the success value of the given
1092
- * effect.
1080
+ * Access the given `Context.Tag` from the environment.
1093
1081
  *
1094
1082
  * @since 3.4.0
1095
1083
  * @experimental
1096
- * @category mapping & sequencing
1084
+ * @category environment
1097
1085
  */
1098
- export declare const as: {
1086
+ export declare const service: {
1099
1087
  /**
1100
- * Create a `Micro` effect that will replace the success value of the given
1101
- * effect.
1088
+ * Access the given `Context.Tag` from the environment.
1102
1089
  *
1103
1090
  * @since 3.4.0
1104
1091
  * @experimental
1105
- * @category mapping & sequencing
1092
+ * @category environment
1106
1093
  */
1107
- <A, B>(value: B): <E, R>(self: Micro<A, E, R>) => Micro<B, E, R>;
1094
+ <I, S>(tag: Context.Reference<I, S>): Micro<S>;
1108
1095
  /**
1109
- * Create a `Micro` effect that will replace the success value of the given
1110
- * effect.
1096
+ * Access the given `Context.Tag` from the environment.
1111
1097
  *
1112
1098
  * @since 3.4.0
1113
1099
  * @experimental
1114
- * @category mapping & sequencing
1100
+ * @category environment
1115
1101
  */
1116
- <A, E, R, B>(self: Micro<A, E, R>, value: B): Micro<B, E, R>;
1102
+ <I, S>(tag: Context.Tag<I, S>): Micro<S, never, I>;
1117
1103
  };
1118
1104
  /**
1119
- * Wrap the success value of this `Micro` effect in an `Option.Some`.
1105
+ * Access the given `Context.Tag` from the environment, without tracking the
1106
+ * dependency at the type level.
1107
+ *
1108
+ * It will return an `Option` of the service, depending on whether it is
1109
+ * available in the environment or not.
1120
1110
  *
1121
1111
  * @since 3.4.0
1122
1112
  * @experimental
1123
- * @category mapping & sequencing
1113
+ * @category environment
1124
1114
  */
1125
- export declare const asSome: <A, E, R>(self: Micro<A, E, R>) => Micro<Option.Option<A>, E, R>;
1115
+ export declare const serviceOption: <I, S>(tag: Context.Tag<I, S>) => Micro<Option.Option<S>>;
1126
1116
  /**
1127
- * Map the success value of this `Micro` effect to another `Micro` effect, then
1128
- * flatten the result.
1117
+ * Update the Context with the given mapping function.
1129
1118
  *
1130
- * @since 3.4.0
1119
+ * @since 3.11.0
1131
1120
  * @experimental
1132
- * @category mapping & sequencing
1121
+ * @category environment
1133
1122
  */
1134
- export declare const flatMap: {
1123
+ export declare const updateContext: {
1135
1124
  /**
1136
- * Map the success value of this `Micro` effect to another `Micro` effect, then
1137
- * flatten the result.
1125
+ * Update the Context with the given mapping function.
1138
1126
  *
1139
- * @since 3.4.0
1127
+ * @since 3.11.0
1140
1128
  * @experimental
1141
- * @category mapping & sequencing
1129
+ * @category environment
1142
1130
  */
1143
- <A, B, E2, R2>(f: (a: A) => Micro<B, E2, R2>): <E, R>(self: Micro<A, E, R>) => Micro<B, E | E2, R | R2>;
1131
+ <R2, R>(f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>): <A, E>(self: Micro<A, E, R>) => Micro<A, E, R2>;
1144
1132
  /**
1145
- * Map the success value of this `Micro` effect to another `Micro` effect, then
1146
- * flatten the result.
1133
+ * Update the Context with the given mapping function.
1147
1134
  *
1148
- * @since 3.4.0
1135
+ * @since 3.11.0
1149
1136
  * @experimental
1150
- * @category mapping & sequencing
1137
+ * @category environment
1151
1138
  */
1152
- <A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (a: A) => Micro<B, E2, R2>): Micro<B, E | E2, R | R2>;
1139
+ <A, E, R, R2>(self: Micro<A, E, R>, f: (context: Context.Context<R2>) => Context.Context<NoInfer<R>>): Micro<A, E, R2>;
1153
1140
  };
1154
1141
  /**
1155
- * Swap the error and success types of the `Micro` effect.
1156
- *
1157
- * @since 3.4.0
1158
- * @experimental
1159
- * @category mapping & sequencing
1160
- */
1161
- export declare const flip: <A, E, R>(self: Micro<A, E, R>) => Micro<E, A, R>;
1162
- /**
1163
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1164
- * a single api.
1165
- *
1166
- * It also allows you to pass in a `Micro` effect directly, which will be
1167
- * executed after the current effect.
1142
+ * Update the service for the given `Context.Tag` in the environment.
1168
1143
  *
1169
- * @since 3.4.0
1144
+ * @since 3.11.0
1170
1145
  * @experimental
1171
- * @category mapping & sequencing
1146
+ * @category environment
1172
1147
  */
1173
- export declare const andThen: {
1148
+ export declare const updateService: {
1174
1149
  /**
1175
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1176
- * a single api.
1177
- *
1178
- * It also allows you to pass in a `Micro` effect directly, which will be
1179
- * executed after the current effect.
1150
+ * Update the service for the given `Context.Tag` in the environment.
1180
1151
  *
1181
- * @since 3.4.0
1152
+ * @since 3.11.0
1182
1153
  * @experimental
1183
- * @category mapping & sequencing
1154
+ * @category environment
1184
1155
  */
1185
- <A, X>(f: (a: A) => X): <E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
1156
+ <I, A>(tag: Context.Reference<I, A>, f: (value: A) => A): <XA, E, R>(self: Micro<XA, E, R>) => Micro<XA, E, R>;
1186
1157
  /**
1187
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1188
- * a single api.
1158
+ * Update the service for the given `Context.Tag` in the environment.
1189
1159
  *
1190
- * It also allows you to pass in a `Micro` effect directly, which will be
1191
- * executed after the current effect.
1192
- *
1193
- * @since 3.4.0
1160
+ * @since 3.11.0
1194
1161
  * @experimental
1195
- * @category mapping & sequencing
1162
+ * @category environment
1196
1163
  */
1197
- <X>(f: NotFunction<X>): <A, E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
1164
+ <I, A>(tag: Context.Tag<I, A>, f: (value: A) => A): <XA, E, R>(self: Micro<XA, E, R>) => Micro<XA, E, R | I>;
1198
1165
  /**
1199
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1200
- * a single api.
1201
- *
1202
- * It also allows you to pass in a `Micro` effect directly, which will be
1203
- * executed after the current effect.
1166
+ * Update the service for the given `Context.Tag` in the environment.
1204
1167
  *
1205
- * @since 3.4.0
1168
+ * @since 3.11.0
1206
1169
  * @experimental
1207
- * @category mapping & sequencing
1170
+ * @category environment
1208
1171
  */
1209
- <A, E, R, X>(self: Micro<A, E, R>, f: (a: A) => X): [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
1172
+ <XA, E, R, I, A>(self: Micro<XA, E, R>, tag: Context.Reference<I, A>, f: (value: A) => A): Micro<XA, E, R>;
1210
1173
  /**
1211
- * A more flexible version of `flatMap`, that combines `map` and `flatMap` into
1212
- * a single api.
1213
- *
1214
- * It also allows you to pass in a `Micro` effect directly, which will be
1215
- * executed after the current effect.
1174
+ * Update the service for the given `Context.Tag` in the environment.
1216
1175
  *
1217
- * @since 3.4.0
1176
+ * @since 3.11.0
1218
1177
  * @experimental
1219
- * @category mapping & sequencing
1178
+ * @category environment
1220
1179
  */
1221
- <A, E, R, X>(self: Micro<A, E, R>, f: NotFunction<X>): [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
1180
+ <XA, E, R, I, A>(self: Micro<XA, E, R>, tag: Context.Tag<I, A>, f: (value: A) => A): Micro<XA, E, R | I>;
1222
1181
  };
1223
1182
  /**
1224
- * Execute a side effect from the success value of the `Micro` effect.
1183
+ * Access the current `Context` from the environment.
1225
1184
  *
1226
- * It is similar to the `andThen` api, but the success value is ignored.
1185
+ * @since 3.4.0
1186
+ * @experimental
1187
+ * @category environment
1188
+ */
1189
+ export declare const context: <R>() => Micro<Context.Context<R>>;
1190
+ /**
1191
+ * Merge the given `Context` with the current context.
1227
1192
  *
1228
1193
  * @since 3.4.0
1229
1194
  * @experimental
1230
- * @category mapping & sequencing
1195
+ * @category environment
1231
1196
  */
1232
- export declare const tap: {
1233
- /**
1234
- * Execute a side effect from the success value of the `Micro` effect.
1235
- *
1236
- * It is similar to the `andThen` api, but the success value is ignored.
1237
- *
1238
- * @since 3.4.0
1239
- * @experimental
1240
- * @category mapping & sequencing
1241
- */
1242
- <A, X>(f: (a: NoInfer<A>) => X): <E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
1243
- /**
1244
- * Execute a side effect from the success value of the `Micro` effect.
1245
- *
1246
- * It is similar to the `andThen` api, but the success value is ignored.
1247
- *
1248
- * @since 3.4.0
1249
- * @experimental
1250
- * @category mapping & sequencing
1251
- */
1252
- <X>(f: NotFunction<X>): <A, E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
1197
+ export declare const provideContext: {
1253
1198
  /**
1254
- * Execute a side effect from the success value of the `Micro` effect.
1255
- *
1256
- * It is similar to the `andThen` api, but the success value is ignored.
1199
+ * Merge the given `Context` with the current context.
1257
1200
  *
1258
1201
  * @since 3.4.0
1259
1202
  * @experimental
1260
- * @category mapping & sequencing
1203
+ * @category environment
1261
1204
  */
1262
- <A, E, R, X>(self: Micro<A, E, R>, f: (a: NoInfer<A>) => X): [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
1205
+ <XR>(context: Context.Context<XR>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Exclude<R, XR>>;
1263
1206
  /**
1264
- * Execute a side effect from the success value of the `Micro` effect.
1265
- *
1266
- * It is similar to the `andThen` api, but the success value is ignored.
1207
+ * Merge the given `Context` with the current context.
1267
1208
  *
1268
1209
  * @since 3.4.0
1269
1210
  * @experimental
1270
- * @category mapping & sequencing
1211
+ * @category environment
1271
1212
  */
1272
- <A, E, R, X>(self: Micro<A, E, R>, f: NotFunction<X>): [X] extends [Micro<infer _A1, infer E1, infer R1>] ? Micro<A, E | E1, R | R1> : Micro<A, E, R>;
1213
+ <A, E, R, XR>(self: Micro<A, E, R>, context: Context.Context<XR>): Micro<A, E, Exclude<R, XR>>;
1273
1214
  };
1274
1215
  /**
1275
- * Replace the success value of the `Micro` effect with `void`.
1276
- *
1277
- * @since 3.4.0
1278
- * @experimental
1279
- * @category mapping & sequencing
1280
- */
1281
- export declare const asVoid: <A, E, R>(self: Micro<A, E, R>) => Micro<void, E, R>;
1282
- /**
1283
- * Access the `MicroExit` of the given `Micro` effect.
1284
- *
1285
- * @since 3.4.6
1286
- * @experimental
1287
- * @category mapping & sequencing
1288
- */
1289
- export declare const exit: <A, E, R>(self: Micro<A, E, R>) => Micro<MicroExit<A, E>, never, R>;
1290
- /**
1291
- * Replace the error type of the given `Micro` with the full `MicroCause` object.
1292
- *
1293
- * @since 3.4.0
1294
- * @experimental
1295
- * @category mapping & sequencing
1296
- */
1297
- export declare const sandbox: <A, E, R>(self: Micro<A, E, R>) => Micro<A, MicroCause<E>, R>;
1298
- /**
1299
- * Returns an effect that races all the specified effects,
1300
- * yielding the value of the first effect to succeed with a value. Losers of
1301
- * the race will be interrupted immediately
1302
- *
1303
- * @since 3.4.0
1304
- * @experimental
1305
- * @category sequencing
1306
- */
1307
- export declare const raceAll: <Eff extends Micro<any, any, any>>(all: Iterable<Eff>) => Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>>;
1308
- /**
1309
- * Returns an effect that races all the specified effects,
1310
- * yielding the value of the first effect to succeed or fail. Losers of
1311
- * the race will be interrupted immediately
1216
+ * Add the provided service to the current context.
1312
1217
  *
1313
1218
  * @since 3.4.0
1314
1219
  * @experimental
1315
- * @category sequencing
1220
+ * @category environment
1316
1221
  */
1317
- export declare const raceAllFirst: <Eff extends Micro<any, any, any>>(all: Iterable<Eff>) => Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>>;
1222
+ export declare const provideService: {
1223
+ /**
1224
+ * Add the provided service to the current context.
1225
+ *
1226
+ * @since 3.4.0
1227
+ * @experimental
1228
+ * @category environment
1229
+ */
1230
+ <I, S>(tag: Context.Tag<I, S>, service: S): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Exclude<R, I>>;
1231
+ /**
1232
+ * Add the provided service to the current context.
1233
+ *
1234
+ * @since 3.4.0
1235
+ * @experimental
1236
+ * @category environment
1237
+ */
1238
+ <A, E, R, I, S>(self: Micro<A, E, R>, tag: Context.Tag<I, S>, service: S): Micro<A, E, Exclude<R, I>>;
1239
+ };
1318
1240
  /**
1319
- * Returns an effect that races two effects, yielding the value of the first
1320
- * effect to succeed. Losers of the race will be interrupted immediately
1241
+ * Create a service using the provided `Micro` effect, and add it to the
1242
+ * current context.
1321
1243
  *
1322
- * @since 3.4.0
1244
+ * @since 3.4.6
1323
1245
  * @experimental
1324
- * @category sequencing
1246
+ * @category environment
1325
1247
  */
1326
- export declare const race: {
1248
+ export declare const provideServiceEffect: {
1327
1249
  /**
1328
- * Returns an effect that races two effects, yielding the value of the first
1329
- * effect to succeed. Losers of the race will be interrupted immediately
1250
+ * Create a service using the provided `Micro` effect, and add it to the
1251
+ * current context.
1330
1252
  *
1331
- * @since 3.4.0
1253
+ * @since 3.4.6
1332
1254
  * @experimental
1333
- * @category sequencing
1255
+ * @category environment
1334
1256
  */
1335
- <A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
1257
+ <I, S, E2, R2>(tag: Context.Tag<I, S>, acquire: Micro<S, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | E2, Exclude<R, I> | R2>;
1336
1258
  /**
1337
- * Returns an effect that races two effects, yielding the value of the first
1338
- * effect to succeed. Losers of the race will be interrupted immediately
1259
+ * Create a service using the provided `Micro` effect, and add it to the
1260
+ * current context.
1339
1261
  *
1340
- * @since 3.4.0
1262
+ * @since 3.4.6
1341
1263
  * @experimental
1342
- * @category sequencing
1264
+ * @category environment
1343
1265
  */
1344
- <A, E, R, A2, E2, R2>(self: Micro<A, E, R>, that: Micro<A2, E2, R2>): Micro<A | A2, E | E2, R | R2>;
1266
+ <A, E, R, I, S, E2, R2>(self: Micro<A, E, R>, tag: Context.Tag<I, S>, acquire: Micro<S, E2, R2>): Micro<A, E | E2, Exclude<R, I> | R2>;
1345
1267
  };
1268
+ declare const MaxOpsBeforeYield_base: Context.ReferenceClass<MaxOpsBeforeYield, "effect/Micro/currentMaxOpsBeforeYield", number>;
1346
1269
  /**
1347
- * Returns an effect that races two effects, yielding the value of the first
1348
- * effect to succeed *or* fail. Losers of the race will be interrupted immediately
1270
+ * @since 3.11.0
1271
+ * @experimental
1272
+ * @category references
1273
+ */
1274
+ export declare class MaxOpsBeforeYield extends MaxOpsBeforeYield_base {
1275
+ }
1276
+ declare const CurrentConcurrency_base: Context.ReferenceClass<CurrentConcurrency, "effect/Micro/currentConcurrency", number | "unbounded">;
1277
+ /**
1278
+ * @since 3.11.0
1279
+ * @experimental
1280
+ * @category environment refs
1281
+ */
1282
+ export declare class CurrentConcurrency extends CurrentConcurrency_base {
1283
+ }
1284
+ declare const CurrentScheduler_base: Context.ReferenceClass<CurrentScheduler, "effect/Micro/currentScheduler", MicroScheduler>;
1285
+ /**
1286
+ * @since 3.11.0
1287
+ * @experimental
1288
+ * @category environment refs
1289
+ */
1290
+ export declare class CurrentScheduler extends CurrentScheduler_base {
1291
+ }
1292
+ /**
1293
+ * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
1294
+ * api to control the concurrency of that `Micro` when it is run.
1349
1295
  *
1350
1296
  * @since 3.4.0
1351
1297
  * @experimental
1352
- * @category sequencing
1298
+ * @category environment refs
1299
+ * @example
1300
+ * import * as Micro from "effect/Micro"
1301
+ *
1302
+ * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
1303
+ * concurrency: "inherit"
1304
+ * }).pipe(
1305
+ * Micro.withConcurrency(2) // use a concurrency of 2
1306
+ * )
1353
1307
  */
1354
- export declare const raceFirst: {
1308
+ export declare const withConcurrency: {
1355
1309
  /**
1356
- * Returns an effect that races two effects, yielding the value of the first
1357
- * effect to succeed *or* fail. Losers of the race will be interrupted immediately
1310
+ * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
1311
+ * api to control the concurrency of that `Micro` when it is run.
1358
1312
  *
1359
1313
  * @since 3.4.0
1360
1314
  * @experimental
1361
- * @category sequencing
1315
+ * @category environment refs
1316
+ * @example
1317
+ * import * as Micro from "effect/Micro"
1318
+ *
1319
+ * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
1320
+ * concurrency: "inherit"
1321
+ * }).pipe(
1322
+ * Micro.withConcurrency(2) // use a concurrency of 2
1323
+ * )
1362
1324
  */
1363
- <A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
1325
+ (concurrency: "unbounded" | number): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
1364
1326
  /**
1365
- * Returns an effect that races two effects, yielding the value of the first
1366
- * effect to succeed *or* fail. Losers of the race will be interrupted immediately
1327
+ * If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
1328
+ * api to control the concurrency of that `Micro` when it is run.
1367
1329
  *
1368
1330
  * @since 3.4.0
1369
1331
  * @experimental
1370
- * @category sequencing
1332
+ * @category environment refs
1333
+ * @example
1334
+ * import * as Micro from "effect/Micro"
1335
+ *
1336
+ * Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
1337
+ * concurrency: "inherit"
1338
+ * }).pipe(
1339
+ * Micro.withConcurrency(2) // use a concurrency of 2
1340
+ * )
1371
1341
  */
1372
- <A, E, R, A2, E2, R2>(self: Micro<A, E, R>, that: Micro<A2, E2, R2>): Micro<A | A2, E | E2, R | R2>;
1342
+ <A, E, R>(self: Micro<A, E, R>, concurrency: "unbounded" | number): Micro<A, E, R>;
1373
1343
  };
1374
1344
  /**
1375
1345
  * Combine two `Micro` effects into a single effect that produces a tuple of
@@ -1663,6 +1633,84 @@ export declare const repeat: {
1663
1633
  schedule?: MicroSchedule | undefined;
1664
1634
  } | undefined): Micro<A, E, R>;
1665
1635
  };
1636
+ /**
1637
+ * Replicates the given effect `n` times.
1638
+ *
1639
+ * @since 3.11.0
1640
+ * @experimental
1641
+ * @category repetition
1642
+ */
1643
+ export declare const replicate: {
1644
+ /**
1645
+ * Replicates the given effect `n` times.
1646
+ *
1647
+ * @since 3.11.0
1648
+ * @experimental
1649
+ * @category repetition
1650
+ */
1651
+ (n: number): <A, E, R>(self: Micro<A, E, R>) => Array<Micro<A, E, R>>;
1652
+ /**
1653
+ * Replicates the given effect `n` times.
1654
+ *
1655
+ * @since 3.11.0
1656
+ * @experimental
1657
+ * @category repetition
1658
+ */
1659
+ <A, E, R>(self: Micro<A, E, R>, n: number): Array<Micro<A, E, R>>;
1660
+ };
1661
+ /**
1662
+ * Performs this effect the specified number of times and collects the
1663
+ * results.
1664
+ *
1665
+ * @since 3.11.0
1666
+ * @category repetition
1667
+ */
1668
+ export declare const replicateEffect: {
1669
+ /**
1670
+ * Performs this effect the specified number of times and collects the
1671
+ * results.
1672
+ *
1673
+ * @since 3.11.0
1674
+ * @category repetition
1675
+ */
1676
+ (n: number, options?: {
1677
+ readonly concurrency?: Concurrency | undefined;
1678
+ readonly discard?: false | undefined;
1679
+ }): <A, E, R>(self: Micro<A, E, R>) => Micro<Array<A>, E, R>;
1680
+ /**
1681
+ * Performs this effect the specified number of times and collects the
1682
+ * results.
1683
+ *
1684
+ * @since 3.11.0
1685
+ * @category repetition
1686
+ */
1687
+ (n: number, options: {
1688
+ readonly concurrency?: Concurrency | undefined;
1689
+ readonly discard: true;
1690
+ }): <A, E, R>(self: Micro<A, E, R>) => Micro<void, E, R>;
1691
+ /**
1692
+ * Performs this effect the specified number of times and collects the
1693
+ * results.
1694
+ *
1695
+ * @since 3.11.0
1696
+ * @category repetition
1697
+ */
1698
+ <A, E, R>(self: Micro<A, E, R>, n: number, options?: {
1699
+ readonly concurrency?: Concurrency | undefined;
1700
+ readonly discard?: false | undefined;
1701
+ }): Micro<Array<A>, E, R>;
1702
+ /**
1703
+ * Performs this effect the specified number of times and collects the
1704
+ * results.
1705
+ *
1706
+ * @since 3.11.0
1707
+ * @category repetition
1708
+ */
1709
+ <A, E, R>(self: Micro<A, E, R>, n: number, options: {
1710
+ readonly concurrency?: Concurrency | undefined;
1711
+ readonly discard: true;
1712
+ }): Micro<void, E, R>;
1713
+ };
1666
1714
  /**
1667
1715
  * Repeat the given `Micro` effect forever, only stopping if the effect fails.
1668
1716
  *
@@ -2751,6 +2799,31 @@ export declare const onExit: {
2751
2799
  */
2752
2800
  <A, E, R, XE, XR>(self: Micro<A, E, R>, f: (exit: MicroExit<A, E>) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
2753
2801
  };
2802
+ /**
2803
+ * Regardless of the result of the this `Micro` effect, run the finalizer effect.
2804
+ *
2805
+ * @since 3.4.0
2806
+ * @experimental
2807
+ * @category resources & finalization
2808
+ */
2809
+ export declare const ensuring: {
2810
+ /**
2811
+ * Regardless of the result of the this `Micro` effect, run the finalizer effect.
2812
+ *
2813
+ * @since 3.4.0
2814
+ * @experimental
2815
+ * @category resources & finalization
2816
+ */
2817
+ <XE, XR>(finalizer: Micro<void, XE, XR>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
2818
+ /**
2819
+ * Regardless of the result of the this `Micro` effect, run the finalizer effect.
2820
+ *
2821
+ * @since 3.4.0
2822
+ * @experimental
2823
+ * @category resources & finalization
2824
+ */
2825
+ <A, E, R, XE, XR>(self: Micro<A, E, R>, finalizer: Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
2826
+ };
2754
2827
  /**
2755
2828
  * When the `Micro` effect is completed, run the given finalizer effect if it
2756
2829
  * matches the specified predicate.
@@ -2797,31 +2870,6 @@ export declare const onExitIf: {
2797
2870
  */
2798
2871
  <A, E, R, XE, XR>(self: Micro<A, E, R>, predicate: Predicate<MicroExit<NoInfer<A>, NoInfer<E>>>, f: (exit: MicroExit<NoInfer<A>, NoInfer<E>>) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
2799
2872
  };
2800
- /**
2801
- * Regardless of the result of the this `Micro` effect, run the finalizer effect.
2802
- *
2803
- * @since 3.4.0
2804
- * @experimental
2805
- * @category resources & finalization
2806
- */
2807
- export declare const ensuring: {
2808
- /**
2809
- * Regardless of the result of the this `Micro` effect, run the finalizer effect.
2810
- *
2811
- * @since 3.4.0
2812
- * @experimental
2813
- * @category resources & finalization
2814
- */
2815
- <XE, XR>(finalizer: Micro<void, XE, XR>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
2816
- /**
2817
- * Regardless of the result of the this `Micro` effect, run the finalizer effect.
2818
- *
2819
- * @since 3.4.0
2820
- * @experimental
2821
- * @category resources & finalization
2822
- */
2823
- <A, E, R, XE, XR>(self: Micro<A, E, R>, finalizer: Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
2824
- };
2825
2873
  /**
2826
2874
  * When the `Micro` effect fails, run the given finalizer effect with the
2827
2875
  * `MicroCause` of the executed effect.
@@ -2893,14 +2941,23 @@ export declare const acquireUseRelease: <Resource, E, R, A, E2, R2, E3, R3>(acqu
2893
2941
  */
2894
2942
  export declare const interrupt: Micro<never>;
2895
2943
  /**
2896
- * Wrap the given `Micro` effect in an uninterruptible region, preventing the
2897
- * effect from being aborted.
2944
+ * Flag the effect as uninterruptible, which means that when the effect is
2945
+ * interrupted, it will be allowed to continue running until completion.
2898
2946
  *
2899
2947
  * @since 3.4.0
2900
2948
  * @experimental
2901
- * @category interruption
2949
+ * @category flags
2902
2950
  */
2903
2951
  export declare const uninterruptible: <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
2952
+ /**
2953
+ * Flag the effect as interruptible, which means that when the effect is
2954
+ * interrupted, it will be interrupted immediately.
2955
+ *
2956
+ * @since 3.4.0
2957
+ * @experimental
2958
+ * @category flags
2959
+ */
2960
+ export declare const interruptible: <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
2904
2961
  /**
2905
2962
  * Wrap the given `Micro` effect in an uninterruptible region, preventing the
2906
2963
  * effect from being aborted.
@@ -2923,15 +2980,6 @@ export declare const uninterruptible: <A, E, R>(self: Micro<A, E, R>) => Micro<A
2923
2980
  * ```
2924
2981
  */
2925
2982
  export declare const uninterruptibleMask: <A, E, R>(f: (restore: <A_1, E_1, R_1>(effect: Micro<A_1, E_1, R_1>) => Micro<A_1, E_1, R_1>) => Micro<A, E, R>) => Micro<A, E, R>;
2926
- /**
2927
- * Wrap the given `Micro` effect in an interruptible region, allowing the effect
2928
- * to be aborted.
2929
- *
2930
- * @since 3.4.0
2931
- * @experimental
2932
- * @category interruption
2933
- */
2934
- export declare const interruptible: <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
2935
2983
  /**
2936
2984
  * @since 3.4.0
2937
2985
  * @experimental
@@ -2994,6 +3042,16 @@ export declare const all: <const Arg extends Iterable<Micro<any, any, any>> | Re
2994
3042
  readonly concurrency?: Concurrency | undefined;
2995
3043
  readonly discard?: boolean | undefined;
2996
3044
  }>(arg: Arg, options?: O) => All.Return<Arg, O>;
3045
+ /**
3046
+ * @since 3.11.0
3047
+ * @experimental
3048
+ * @category collecting & elements
3049
+ */
3050
+ export declare const whileLoop: <A, E, R>(options: {
3051
+ readonly while: LazyArg<boolean>;
3052
+ readonly body: LazyArg<Micro<A, E, R>>;
3053
+ readonly step: (a: A) => void;
3054
+ }) => Micro<void, E, R>;
2997
3055
  /**
2998
3056
  * For each element of the provided iterable, run the effect and collect the results.
2999
3057
  *
@@ -3151,60 +3209,6 @@ export {
3151
3209
  * @category do notation
3152
3210
  */
3153
3211
  let_ as let };
3154
- /**
3155
- * @since 3.4.0
3156
- * @experimental
3157
- * @category handle & forking
3158
- */
3159
- export declare const HandleTypeId: unique symbol;
3160
- /**
3161
- * @since 3.4.0
3162
- * @experimental
3163
- * @category handle & forking
3164
- */
3165
- export type HandleTypeId = typeof HandleTypeId;
3166
- /**
3167
- * @since 3.4.0
3168
- * @experimental
3169
- * @category handle & forking
3170
- */
3171
- export interface Handle<A, E = never> extends Micro<A, E> {
3172
- readonly [HandleTypeId]: HandleTypeId;
3173
- readonly await: Micro<MicroExit<A, E>>;
3174
- readonly join: Micro<A, E>;
3175
- readonly interrupt: Micro<MicroExit<A, E>>;
3176
- readonly unsafeInterrupt: () => void;
3177
- readonly addObserver: (observer: (exit: MicroExit<A, E>) => void) => void;
3178
- readonly removeObserver: (observer: (exit: MicroExit<A, E>) => void) => void;
3179
- readonly unsafePoll: () => MicroExit<A, E> | null;
3180
- [Unify.typeSymbol]?: unknown;
3181
- [Unify.unifySymbol]?: HandleUnify<this>;
3182
- [Unify.ignoreSymbol]?: HandleUnifyIgnore;
3183
- }
3184
- /**
3185
- * @category models
3186
- * @since 3.8.4
3187
- * @experimental
3188
- */
3189
- export interface HandleUnify<A extends {
3190
- [Unify.typeSymbol]?: any;
3191
- }> extends MicroUnify<A> {
3192
- Handle?: () => A[Unify.typeSymbol] extends Handle<infer A0, infer E0> | infer _ ? Handle<A0, E0> : never;
3193
- }
3194
- /**
3195
- * @category models
3196
- * @since 3.8.4
3197
- * @experimental
3198
- */
3199
- export interface HandleUnifyIgnore extends MicroUnifyIgnore {
3200
- Micro?: true;
3201
- }
3202
- /**
3203
- * @since 3.4.0
3204
- * @experimental
3205
- * @category handle & forking
3206
- */
3207
- export declare const isHandle: (u: unknown) => u is Handle<unknown, unknown>;
3208
3212
  /**
3209
3213
  * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
3210
3214
  * aborted.
@@ -3215,7 +3219,7 @@ export declare const isHandle: (u: unknown) => u is Handle<unknown, unknown>;
3215
3219
  * @experimental
3216
3220
  * @category handle & forking
3217
3221
  */
3218
- export declare const fork: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>, never, R>;
3222
+ export declare const fork: <A, E, R>(self: Micro<A, E, R>) => Micro<Fiber<A, E>, never, R>;
3219
3223
  /**
3220
3224
  * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
3221
3225
  * aborted.
@@ -3226,7 +3230,7 @@ export declare const fork: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>
3226
3230
  * @experimental
3227
3231
  * @category handle & forking
3228
3232
  */
3229
- export declare const forkDaemon: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>, never, R>;
3233
+ export declare const forkDaemon: <A, E, R>(self: Micro<A, E, R>) => Micro<Fiber<A, E>, never, R>;
3230
3234
  /**
3231
3235
  * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
3232
3236
  * aborted.
@@ -3248,7 +3252,7 @@ export declare const forkIn: {
3248
3252
  * @experimental
3249
3253
  * @category handle & forking
3250
3254
  */
3251
- (scope: MicroScope): <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>, never, R>;
3255
+ (scope: MicroScope): <A, E, R>(self: Micro<A, E, R>) => Micro<Fiber<A, E>, never, R>;
3252
3256
  /**
3253
3257
  * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
3254
3258
  * aborted.
@@ -3259,7 +3263,7 @@ export declare const forkIn: {
3259
3263
  * @experimental
3260
3264
  * @category handle & forking
3261
3265
  */
3262
- <A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<Handle<A, E>, never, R>;
3266
+ <A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<Fiber<A, E>, never, R>;
3263
3267
  };
3264
3268
  /**
3265
3269
  * Run the `Micro` effect in a new `Handle` that can be awaited, joined, or
@@ -3271,7 +3275,7 @@ export declare const forkIn: {
3271
3275
  * @experimental
3272
3276
  * @category handle & forking
3273
3277
  */
3274
- export declare const forkScoped: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle<A, E>, never, R | MicroScope>;
3278
+ export declare const forkScoped: <A, E, R>(self: Micro<A, E, R>) => Micro<Fiber<A, E>, never, R | MicroScope>;
3275
3279
  /**
3276
3280
  * Execute the `Micro` effect and return a `Handle` that can be awaited, joined,
3277
3281
  * or aborted.
@@ -3299,7 +3303,7 @@ export declare const forkScoped: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle
3299
3303
  export declare const runFork: <A, E>(effect: Micro<A, E>, options?: {
3300
3304
  readonly signal?: AbortSignal | undefined;
3301
3305
  readonly scheduler?: MicroScheduler | undefined;
3302
- } | undefined) => Handle<A, E>;
3306
+ } | undefined) => FiberImpl<A, E>;
3303
3307
  /**
3304
3308
  * Execute the `Micro` effect and return a `Promise` that resolves with the
3305
3309
  * `MicroExit` of the computation.
@@ -3350,12 +3354,11 @@ export declare const runSync: <A, E>(effect: Micro<A, E>) => A;
3350
3354
  * @category errors
3351
3355
  */
3352
3356
  export interface YieldableError extends Pipeable, Inspectable, Readonly<Error> {
3353
- readonly [EffectTypeId]: Effect.VarianceStruct<never, this, never>;
3354
- readonly [StreamTypeId]: Stream.VarianceStruct<never, this, never>;
3355
- readonly [SinkTypeId]: Sink.VarianceStruct<never, unknown, never, this, never>;
3356
- readonly [ChannelTypeId]: Channel.VarianceStruct<never, unknown, this, unknown, never, unknown, never>;
3357
+ readonly [Effectable.EffectTypeId]: Effect.VarianceStruct<never, this, never>;
3358
+ readonly [Effectable.StreamTypeId]: Stream.VarianceStruct<never, this, never>;
3359
+ readonly [Effectable.SinkTypeId]: Sink.VarianceStruct<never, unknown, never, this, never>;
3360
+ readonly [Effectable.ChannelTypeId]: Channel.VarianceStruct<never, unknown, this, unknown, never, unknown, never>;
3357
3361
  readonly [TypeId]: Micro.Variance<never, this, never>;
3358
- readonly [runSymbol]: (env: Env<any>, onExit: (exit: MicroExit<never, this>) => void) => void;
3359
3362
  [Symbol.iterator](): MicroIterator<Micro<never, this, never>>;
3360
3363
  }
3361
3364
  /**