effect 2.4.5 → 2.4.7

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 (83) hide show
  1. package/dist/cjs/Channel.js +10 -2
  2. package/dist/cjs/Channel.js.map +1 -1
  3. package/dist/cjs/Effect.js +26 -4
  4. package/dist/cjs/Effect.js.map +1 -1
  5. package/dist/cjs/FiberMap.js +3 -0
  6. package/dist/cjs/FiberMap.js.map +1 -1
  7. package/dist/cjs/FiberSet.js +4 -0
  8. package/dist/cjs/FiberSet.js.map +1 -1
  9. package/dist/cjs/internal/cause.js +2 -2
  10. package/dist/cjs/internal/cause.js.map +1 -1
  11. package/dist/cjs/internal/channel.js +75 -1
  12. package/dist/cjs/internal/channel.js.map +1 -1
  13. package/dist/cjs/internal/core-effect.js +0 -2
  14. package/dist/cjs/internal/core-effect.js.map +1 -1
  15. package/dist/cjs/internal/core.js +148 -126
  16. package/dist/cjs/internal/core.js.map +1 -1
  17. package/dist/cjs/internal/fiberRuntime.js +29 -29
  18. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  19. package/dist/cjs/internal/layer.js +2 -2
  20. package/dist/cjs/internal/layer.js.map +1 -1
  21. package/dist/cjs/internal/runtime.js +4 -6
  22. package/dist/cjs/internal/runtime.js.map +1 -1
  23. package/dist/cjs/internal/stm/core.js +36 -36
  24. package/dist/cjs/internal/stm/core.js.map +1 -1
  25. package/dist/cjs/internal/stream.js +2 -73
  26. package/dist/cjs/internal/stream.js.map +1 -1
  27. package/dist/cjs/internal/version.js +1 -1
  28. package/dist/dts/Channel.d.ts +8 -0
  29. package/dist/dts/Channel.d.ts.map +1 -1
  30. package/dist/dts/Effect.d.ts +38 -2
  31. package/dist/dts/Effect.d.ts.map +1 -1
  32. package/dist/dts/FiberMap.d.ts.map +1 -1
  33. package/dist/dts/FiberSet.d.ts.map +1 -1
  34. package/dist/esm/Channel.js +8 -0
  35. package/dist/esm/Channel.js.map +1 -1
  36. package/dist/esm/Effect.js +22 -0
  37. package/dist/esm/Effect.js.map +1 -1
  38. package/dist/esm/FiberMap.js +3 -0
  39. package/dist/esm/FiberMap.js.map +1 -1
  40. package/dist/esm/FiberSet.js +4 -0
  41. package/dist/esm/FiberSet.js.map +1 -1
  42. package/dist/esm/internal/cause.js +2 -2
  43. package/dist/esm/internal/cause.js.map +1 -1
  44. package/dist/esm/internal/channel.js +73 -0
  45. package/dist/esm/internal/channel.js.map +1 -1
  46. package/dist/esm/internal/core-effect.js +0 -2
  47. package/dist/esm/internal/core-effect.js.map +1 -1
  48. package/dist/esm/internal/core.js +144 -123
  49. package/dist/esm/internal/core.js.map +1 -1
  50. package/dist/esm/internal/fiberRuntime.js +29 -29
  51. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  52. package/dist/esm/internal/layer.js +2 -2
  53. package/dist/esm/internal/layer.js.map +1 -1
  54. package/dist/esm/internal/runtime.js +4 -6
  55. package/dist/esm/internal/runtime.js.map +1 -1
  56. package/dist/esm/internal/stm/core.js +36 -36
  57. package/dist/esm/internal/stm/core.js.map +1 -1
  58. package/dist/esm/internal/stream.js +2 -73
  59. package/dist/esm/internal/stream.js.map +1 -1
  60. package/dist/esm/internal/version.js +1 -1
  61. package/package.json +1 -1
  62. package/src/Channel.ts +17 -0
  63. package/src/Effect.ts +45 -2
  64. package/src/Exit.ts +2 -2
  65. package/src/FiberMap.ts +4 -0
  66. package/src/FiberSet.ts +4 -0
  67. package/src/internal/cause.ts +2 -2
  68. package/src/internal/channel.ts +92 -0
  69. package/src/internal/core-effect.ts +0 -2
  70. package/src/internal/core.ts +167 -134
  71. package/src/internal/fiberRuntime.ts +30 -30
  72. package/src/internal/layer.ts +4 -4
  73. package/src/internal/runtime.ts +4 -6
  74. package/src/internal/stm/core.ts +49 -49
  75. package/src/internal/stream.ts +2 -82
  76. package/src/internal/version.ts +1 -1
  77. package/dist/cjs/internal/internalize.js +0 -15
  78. package/dist/cjs/internal/internalize.js.map +0 -1
  79. package/dist/dts/internal/internalize.d.ts +0 -2
  80. package/dist/dts/internal/internalize.d.ts.map +0 -1
  81. package/dist/esm/internal/internalize.js +0 -8
  82. package/dist/esm/internal/internalize.js.map +0 -1
  83. package/src/internal/internalize.ts +0 -5
@@ -43,7 +43,6 @@ import * as internalDiffer from "./differ.js"
43
43
  import { effectVariance, StructuralCommitPrototype } from "./effectable.js"
44
44
  import type * as FiberRuntime from "./fiberRuntime.js"
45
45
  import type * as fiberScope from "./fiberScope.js"
46
- import { internalize } from "./internalize.js"
47
46
  import * as DeferredOpCodes from "./opCodes/deferred.js"
48
47
  import * as OpCodes from "./opCodes/effect.js"
49
48
  import * as _runtimeFlags from "./runtimeFlags.js"
@@ -87,8 +86,8 @@ export const blocked = <A, E>(
87
86
  _continue: Effect.Effect<A, E>
88
87
  ): Effect.Blocked<A, E> => {
89
88
  const effect = new EffectPrimitive("Blocked") as any
90
- effect.i0 = blockedRequests
91
- effect.i1 = _continue
89
+ effect.effect_instruction_i0 = blockedRequests
90
+ effect.effect_instruction_i1 = _continue
92
91
  return effect
93
92
  }
94
93
 
@@ -99,7 +98,7 @@ export const runRequestBlock = (
99
98
  blockedRequests: BlockedRequests.RequestBlock
100
99
  ): Effect.Effect<void> => {
101
100
  const effect = new EffectPrimitive("RunBlocked") as any
102
- effect.i0 = blockedRequests
101
+ effect.effect_instruction_i0 = blockedRequests
103
102
  return effect
104
103
  }
105
104
 
@@ -148,9 +147,9 @@ export class RevertFlags {
148
147
 
149
148
  /** @internal */
150
149
  class EffectPrimitive {
151
- public i0 = undefined
152
- public i1 = undefined
153
- public i2 = undefined
150
+ public effect_instruction_i0 = undefined
151
+ public effect_instruction_i1 = undefined
152
+ public effect_instruction_i2 = undefined
154
153
  public trace = undefined;
155
154
  [EffectTypeId] = effectVariance
156
155
  constructor(readonly _op: Primitive["_op"]) {}
@@ -167,9 +166,9 @@ class EffectPrimitive {
167
166
  return {
168
167
  _id: "Effect",
169
168
  _op: this._op,
170
- i0: toJSON(this.i0),
171
- i1: toJSON(this.i1),
172
- i2: toJSON(this.i2)
169
+ effect_instruction_i0: toJSON(this.effect_instruction_i0),
170
+ effect_instruction_i1: toJSON(this.effect_instruction_i1),
171
+ effect_instruction_i2: toJSON(this.effect_instruction_i2)
173
172
  }
174
173
  }
175
174
  toString() {
@@ -182,9 +181,9 @@ class EffectPrimitive {
182
181
 
183
182
  /** @internal */
184
183
  class EffectPrimitiveFailure {
185
- public i0 = undefined
186
- public i1 = undefined
187
- public i2 = undefined
184
+ public effect_instruction_i0 = undefined
185
+ public effect_instruction_i1 = undefined
186
+ public effect_instruction_i2 = undefined
188
187
  public trace = undefined;
189
188
  [EffectTypeId] = effectVariance
190
189
  constructor(readonly _op: Primitive["_op"]) {
@@ -198,7 +197,7 @@ class EffectPrimitiveFailure {
198
197
  return Hash.cached(this, Hash.random(this))
199
198
  }
200
199
  get cause() {
201
- return this.i0
200
+ return this.effect_instruction_i0
202
201
  }
203
202
  pipe() {
204
203
  return pipeArguments(this, arguments)
@@ -220,9 +219,9 @@ class EffectPrimitiveFailure {
220
219
 
221
220
  /** @internal */
222
221
  class EffectPrimitiveSuccess {
223
- public i0 = undefined
224
- public i1 = undefined
225
- public i2 = undefined
222
+ public effect_instruction_i0 = undefined
223
+ public effect_instruction_i1 = undefined
224
+ public effect_instruction_i2 = undefined
226
225
  public trace = undefined;
227
226
  [EffectTypeId] = effectVariance
228
227
  constructor(readonly _op: Primitive["_op"]) {
@@ -236,7 +235,7 @@ class EffectPrimitiveSuccess {
236
235
  return Hash.cached(this, Hash.random(this))
237
236
  }
238
237
  get value() {
239
- return this.i0
238
+ return this.effect_instruction_i0
240
239
  }
241
240
  pipe() {
242
241
  return pipeArguments(this, arguments)
@@ -264,30 +263,30 @@ export type Op<Tag extends string, Body = {}> = Effect.Effect<never> & Body & {
264
263
  /** @internal */
265
264
  export interface Async extends
266
265
  Op<OpCodes.OP_ASYNC, {
267
- i0(resume: (effect: Primitive) => void): void
268
- readonly i1: FiberId.FiberId
266
+ effect_instruction_i0(resume: (effect: Primitive) => void): void
267
+ readonly effect_instruction_i1: FiberId.FiberId
269
268
  }>
270
269
  {}
271
270
 
272
271
  /** @internal */
273
272
  export interface Blocked<out E = any, out A = any> extends
274
273
  Op<"Blocked", {
275
- readonly i0: BlockedRequests.RequestBlock
276
- readonly i1: Effect.Effect<A, E>
274
+ readonly effect_instruction_i0: BlockedRequests.RequestBlock
275
+ readonly effect_instruction_i1: Effect.Effect<A, E>
277
276
  }>
278
277
  {}
279
278
 
280
279
  /** @internal */
281
280
  export interface RunBlocked extends
282
281
  Op<"RunBlocked", {
283
- readonly i0: BlockedRequests.RequestBlock
282
+ readonly effect_instruction_i0: BlockedRequests.RequestBlock
284
283
  }>
285
284
  {}
286
285
 
287
286
  /** @internal */
288
287
  export interface Failure extends
289
288
  Op<OpCodes.OP_FAILURE, {
290
- readonly i0: Cause.Cause<unknown>
289
+ readonly effect_instruction_i0: Cause.Cause<unknown>
291
290
  }>
292
291
  {}
293
292
 
@@ -304,66 +303,66 @@ export interface Commit extends
304
303
  /** @internal */
305
304
  export interface OnFailure extends
306
305
  Op<OpCodes.OP_ON_FAILURE, {
307
- readonly i0: Primitive
308
- i1(a: Cause.Cause<unknown>): Primitive
306
+ readonly effect_instruction_i0: Primitive
307
+ effect_instruction_i1(a: Cause.Cause<unknown>): Primitive
309
308
  }>
310
309
  {}
311
310
 
312
311
  /** @internal */
313
312
  export interface OnSuccess extends
314
313
  Op<OpCodes.OP_ON_SUCCESS, {
315
- readonly i0: Primitive
316
- i1(a: unknown): Primitive
314
+ readonly effect_instruction_i0: Primitive
315
+ effect_instruction_i1(a: unknown): Primitive
317
316
  }>
318
317
  {}
319
318
 
320
319
  /** @internal */
321
- export interface OnStep extends Op<"OnStep", { readonly i0: Primitive }> {}
320
+ export interface OnStep extends Op<"OnStep", { readonly effect_instruction_i0: Primitive }> {}
322
321
 
323
322
  /** @internal */
324
323
  export interface OnSuccessAndFailure extends
325
324
  Op<OpCodes.OP_ON_SUCCESS_AND_FAILURE, {
326
- readonly i0: Primitive
327
- i1(a: Cause.Cause<unknown>): Primitive
328
- i2(a: unknown): Primitive
325
+ readonly effect_instruction_i0: Primitive
326
+ effect_instruction_i1(a: Cause.Cause<unknown>): Primitive
327
+ effect_instruction_i2(a: unknown): Primitive
329
328
  }>
330
329
  {}
331
330
 
332
331
  /** @internal */
333
332
  export interface Success extends
334
333
  Op<OpCodes.OP_SUCCESS, {
335
- readonly i0: unknown
334
+ readonly effect_instruction_i0: unknown
336
335
  }>
337
336
  {}
338
337
 
339
338
  /** @internal */
340
339
  export interface Sync extends
341
340
  Op<OpCodes.OP_SYNC, {
342
- i0(): unknown
341
+ effect_instruction_i0(): unknown
343
342
  }>
344
343
  {}
345
344
 
346
345
  /** @internal */
347
346
  export interface UpdateRuntimeFlags extends
348
347
  Op<OpCodes.OP_UPDATE_RUNTIME_FLAGS, {
349
- readonly i0: RuntimeFlagsPatch.RuntimeFlagsPatch
350
- readonly i1?: (oldRuntimeFlags: RuntimeFlags.RuntimeFlags) => Primitive
348
+ readonly effect_instruction_i0: RuntimeFlagsPatch.RuntimeFlagsPatch
349
+ readonly effect_instruction_i1?: (oldRuntimeFlags: RuntimeFlags.RuntimeFlags) => Primitive
351
350
  }>
352
351
  {}
353
352
 
354
353
  /** @internal */
355
354
  export interface While extends
356
355
  Op<OpCodes.OP_WHILE, {
357
- i0(): boolean
358
- i1(): Primitive
359
- i2(a: unknown): void
356
+ effect_instruction_i0(): boolean
357
+ effect_instruction_i1(): Primitive
358
+ effect_instruction_i2(a: unknown): void
360
359
  }>
361
360
  {}
362
361
 
363
362
  /** @internal */
364
363
  export interface WithRuntime extends
365
364
  Op<OpCodes.OP_WITH_RUNTIME, {
366
- i0(fiber: FiberRuntime.FiberRuntime<unknown, unknown>, status: FiberStatus.Running): Primitive
365
+ effect_instruction_i0(fiber: FiberRuntime.FiberRuntime<unknown, unknown>, status: FiberStatus.Running): Primitive
367
366
  }>
368
367
  {}
369
368
 
@@ -377,9 +376,8 @@ export const isEffect = (u: unknown): u is Effect.Effect<unknown, unknown, unkno
377
376
  export const withFiberRuntime = <A, E = never, R = never>(
378
377
  withRuntime: (fiber: FiberRuntime.FiberRuntime<A, E>, status: FiberStatus.Running) => Effect.Effect<A, E, R>
379
378
  ): Effect.Effect<A, E, R> => {
380
- internalize(withRuntime)
381
379
  const effect = new EffectPrimitive(OpCodes.OP_WITH_RUNTIME) as any
382
- effect.i0 = withRuntime
380
+ effect.effect_instruction_i0 = withRuntime
383
381
  return effect
384
382
  }
385
383
 
@@ -409,7 +407,7 @@ export const acquireUseRelease: {
409
407
  onFailure: (cause) => {
410
408
  switch (exit._tag) {
411
409
  case OpCodes.OP_FAILURE:
412
- return failCause(internalCause.parallel(exit.i0, cause))
410
+ return failCause(internalCause.parallel(exit.effect_instruction_i0, cause))
413
411
  case OpCodes.OP_SUCCESS:
414
412
  return failCause(cause)
415
413
  }
@@ -433,6 +431,50 @@ export const as: {
433
431
  /* @internal */
434
432
  export const asUnit = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<void, E, R> => as(self, void 0)
435
433
 
434
+ /* @internal */
435
+ export const custom: {
436
+ <X, A, E, R>(i0: X, body: (this: { effect_instruction_i0: X }) => Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
437
+ <X, Y, A, E, R>(
438
+ i0: X,
439
+ i1: Y,
440
+ body: (this: { effect_instruction_i0: X; effect_instruction_i1: Y }) => Effect.Effect<A, E, R>
441
+ ): Effect.Effect<A, E, R>
442
+ <X, Y, Z, A, E, R>(
443
+ i0: X,
444
+ i1: Y,
445
+ i2: Z,
446
+ body: (
447
+ this: { effect_instruction_i0: X; effect_instruction_i1: Y; effect_instruction_i2: Z }
448
+ ) => Effect.Effect<A, E, R>
449
+ ): Effect.Effect<A, E, R>
450
+ } = function() {
451
+ const wrapper = new EffectPrimitive(OpCodes.OP_COMMIT) as any
452
+ switch (arguments.length) {
453
+ case 2: {
454
+ wrapper.effect_instruction_i0 = arguments[0]
455
+ wrapper.commit = arguments[1]
456
+ break
457
+ }
458
+ case 3: {
459
+ wrapper.effect_instruction_i0 = arguments[0]
460
+ wrapper.effect_instruction_i1 = arguments[1]
461
+ wrapper.commit = arguments[2]
462
+ break
463
+ }
464
+ case 4: {
465
+ wrapper.effect_instruction_i0 = arguments[0]
466
+ wrapper.effect_instruction_i1 = arguments[1]
467
+ wrapper.effect_instruction_i2 = arguments[2]
468
+ wrapper.commit = arguments[3]
469
+ break
470
+ }
471
+ default: {
472
+ throw new Error("Bug, you're not supposed to end up here")
473
+ }
474
+ }
475
+ return wrapper
476
+ }
477
+
436
478
  /* @internal */
437
479
  export const async = <A, E = never, R = never>(
438
480
  register: (
@@ -440,9 +482,8 @@ export const async = <A, E = never, R = never>(
440
482
  signal: AbortSignal
441
483
  ) => void | Effect.Effect<void, never, R>,
442
484
  blockingOn: FiberId.FiberId = FiberId.none
443
- ): Effect.Effect<A, E, R> =>
444
- suspend(() => {
445
- internalize(register)
485
+ ): Effect.Effect<A, E, R> => {
486
+ return custom(register, function() {
446
487
  let backingResume: ((_: Effect.Effect<A, E, R>) => void) | undefined = undefined
447
488
  let pendingEffect: Effect.Effect<A, E, R> | undefined = undefined
448
489
  function proxyResume(effect: Effect.Effect<A, E, R>) {
@@ -453,23 +494,21 @@ export const async = <A, E = never, R = never>(
453
494
  }
454
495
  }
455
496
  const effect = new EffectPrimitive(OpCodes.OP_ASYNC) as any
456
- effect.i0 = (resume: (_: Effect.Effect<A, E, R>) => void) => {
497
+ effect.effect_instruction_i0 = (resume: (_: Effect.Effect<A, E, R>) => void) => {
457
498
  backingResume = resume
458
499
  if (pendingEffect) {
459
500
  resume(pendingEffect)
460
501
  }
461
502
  }
462
- effect.i1 = blockingOn
463
-
503
+ effect.effect_instruction_i1 = blockingOn
464
504
  let cancelerRef: Effect.Effect<void, never, R> | void = undefined
465
505
  let controllerRef: AbortController | void = undefined
466
- if (register.length !== 1) {
506
+ if (this.effect_instruction_i0.length !== 1) {
467
507
  controllerRef = new AbortController()
468
- cancelerRef = register(proxyResume, controllerRef.signal)
508
+ cancelerRef = this.effect_instruction_i0(proxyResume, controllerRef.signal)
469
509
  } else {
470
- cancelerRef = (register as any)(proxyResume)
510
+ cancelerRef = (this.effect_instruction_i0 as any)(proxyResume)
471
511
  }
472
-
473
512
  return (cancelerRef || controllerRef) ?
474
513
  onInterrupt(effect, (_) => {
475
514
  if (controllerRef) {
@@ -479,6 +518,7 @@ export const async = <A, E = never, R = never>(
479
518
  }) :
480
519
  effect
481
520
  })
521
+ }
482
522
 
483
523
  /* @internal */
484
524
  export const catchAllCause = dual<
@@ -491,9 +531,8 @@ export const catchAllCause = dual<
491
531
  ) => Effect.Effect<A2 | A, E2, R2 | R>
492
532
  >(2, (self, f) => {
493
533
  const effect = new EffectPrimitive(OpCodes.OP_ON_FAILURE) as any
494
- effect.i0 = self
495
- effect.i1 = f
496
- internalize(f)
534
+ effect.effect_instruction_i0 = self
535
+ effect.effect_instruction_i1 = f
497
536
  return effect
498
537
  })
499
538
 
@@ -650,7 +689,7 @@ export const failSync = <E>(evaluate: LazyArg<E>): Effect.Effect<never, E> => fl
650
689
  /* @internal */
651
690
  export const failCause = <E>(cause: Cause.Cause<E>): Effect.Effect<never, E> => {
652
691
  const effect = new EffectPrimitiveFailure(OpCodes.OP_FAILURE) as any
653
- effect.i0 = cause
692
+ effect.effect_instruction_i0 = cause
654
693
  return effect
655
694
  }
656
695
 
@@ -679,10 +718,9 @@ export const flatMap = dual<
679
718
  >(
680
719
  2,
681
720
  (self, f) => {
682
- internalize(f)
683
721
  const effect = new EffectPrimitive(OpCodes.OP_ON_SUCCESS) as any
684
- effect.i0 = self
685
- effect.i1 = f
722
+ effect.effect_instruction_i0 = self
723
+ effect.effect_instruction_i1 = f
686
724
  return effect
687
725
  }
688
726
  )
@@ -733,7 +771,7 @@ export const step = <A, E, R>(
733
771
  self: Effect.Effect<A, E, R>
734
772
  ): Effect.Effect<Exit.Exit<A, E> | Effect.Blocked<A, E>, never, R> => {
735
773
  const effect = new EffectPrimitive("OnStep") as any
736
- effect.i0 = self
774
+ effect.effect_instruction_i0 = self
737
775
  return effect
738
776
  }
739
777
 
@@ -796,11 +834,9 @@ export const matchCauseEffect: {
796
834
  }
797
835
  ): Effect.Effect<A2 | A3, E2 | E3, R2 | R3 | R> => {
798
836
  const effect = new EffectPrimitive(OpCodes.OP_ON_SUCCESS_AND_FAILURE) as any
799
- effect.i0 = self
800
- effect.i1 = options.onFailure
801
- effect.i2 = options.onSuccess
802
- internalize(options.onFailure)
803
- internalize(options.onSuccess)
837
+ effect.effect_instruction_i0 = self
838
+ effect.effect_instruction_i1 = options.onFailure
839
+ effect.effect_instruction_i2 = options.onSuccess
804
840
  return effect
805
841
  })
806
842
 
@@ -929,24 +965,24 @@ export const interruptWith = (fiberId: FiberId.FiberId): Effect.Effect<never> =>
929
965
  /* @internal */
930
966
  export const interruptible = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => {
931
967
  const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
932
- effect.i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption)
933
- effect.i1 = () => self
968
+ effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption)
969
+ effect.effect_instruction_i1 = () => self
934
970
  return effect
935
971
  }
936
972
 
937
973
  /* @internal */
938
974
  export const interruptibleMask = <A, E, R>(
939
975
  f: (restore: <AX, EX, RX>(effect: Effect.Effect<AX, EX, RX>) => Effect.Effect<AX, EX, RX>) => Effect.Effect<A, E, R>
940
- ): Effect.Effect<A, E, R> => {
941
- internalize(f)
942
- const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
943
- effect.i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption)
944
- effect.i1 = (oldFlags: RuntimeFlags.RuntimeFlags) =>
945
- _runtimeFlags.interruption(oldFlags)
946
- ? f(interruptible)
947
- : f(uninterruptible)
948
- return effect
949
- }
976
+ ): Effect.Effect<A, E, R> =>
977
+ custom(f, function() {
978
+ const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
979
+ effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption)
980
+ effect.effect_instruction_i1 = (oldFlags: RuntimeFlags.RuntimeFlags) =>
981
+ _runtimeFlags.interruption(oldFlags)
982
+ ? this.effect_instruction_i0(interruptible)
983
+ : this.effect_instruction_i0(uninterruptible)
984
+ return effect
985
+ })
950
986
 
951
987
  /* @internal */
952
988
  export const intoDeferred: {
@@ -1026,7 +1062,8 @@ export const onError: {
1026
1062
  } = dual(2, <A, E, R, X, R2>(
1027
1063
  self: Effect.Effect<A, E, R>,
1028
1064
  cleanup: (cause: Cause.Cause<E>) => Effect.Effect<X, never, R2>
1029
- ): Effect.Effect<A, E, R2 | R> => onExit(self, (exit) => exitIsSuccess(exit) ? unit : cleanup(exit.i0)))
1065
+ ): Effect.Effect<A, E, R2 | R> =>
1066
+ onExit(self, (exit) => exitIsSuccess(exit) ? unit : cleanup(exit.effect_instruction_i0)))
1030
1067
 
1031
1068
  /* @internal */
1032
1069
  export const onExit: {
@@ -1142,7 +1179,7 @@ export const runtimeFlags: Effect.Effect<RuntimeFlags.RuntimeFlags> = withFiberR
1142
1179
  /* @internal */
1143
1180
  export const succeed = <A>(value: A): Effect.Effect<A> => {
1144
1181
  const effect = new EffectPrimitiveSuccess(OpCodes.OP_SUCCESS) as any
1145
- effect.i0 = value
1182
+ effect.effect_instruction_i0 = value
1146
1183
  return effect
1147
1184
  }
1148
1185
 
@@ -1152,9 +1189,8 @@ export const suspend = <A, E, R>(effect: LazyArg<Effect.Effect<A, E, R>>): Effec
1152
1189
 
1153
1190
  /* @internal */
1154
1191
  export const sync = <A>(evaluate: LazyArg<A>): Effect.Effect<A> => {
1155
- internalize(evaluate)
1156
1192
  const effect = new EffectPrimitive(OpCodes.OP_SYNC) as any
1157
- effect.i0 = evaluate
1193
+ effect.effect_instruction_i0 = evaluate
1158
1194
  return effect
1159
1195
  }
1160
1196
 
@@ -1245,24 +1281,24 @@ export const uninterruptible: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.
1245
1281
  self: Effect.Effect<A, E, R>
1246
1282
  ): Effect.Effect<A, E, R> => {
1247
1283
  const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1248
- effect.i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption)
1249
- effect.i1 = () => self
1284
+ effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption)
1285
+ effect.effect_instruction_i1 = () => self
1250
1286
  return effect
1251
1287
  }
1252
1288
 
1253
1289
  /* @internal */
1254
1290
  export const uninterruptibleMask = <A, E, R>(
1255
1291
  f: (restore: <AX, EX, RX>(effect: Effect.Effect<AX, EX, RX>) => Effect.Effect<AX, EX, RX>) => Effect.Effect<A, E, R>
1256
- ): Effect.Effect<A, E, R> => {
1257
- internalize(f)
1258
- const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1259
- effect.i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption)
1260
- effect.i1 = (oldFlags: RuntimeFlags.RuntimeFlags) =>
1261
- _runtimeFlags.interruption(oldFlags)
1262
- ? f(interruptible)
1263
- : f(uninterruptible)
1264
- return effect
1265
- }
1292
+ ): Effect.Effect<A, E, R> =>
1293
+ custom(f, function() {
1294
+ const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1295
+ effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption)
1296
+ effect.effect_instruction_i1 = (oldFlags: RuntimeFlags.RuntimeFlags) =>
1297
+ _runtimeFlags.interruption(oldFlags)
1298
+ ? this.effect_instruction_i0(interruptible)
1299
+ : this.effect_instruction_i0(uninterruptible)
1300
+ return effect
1301
+ })
1266
1302
 
1267
1303
  /* @internal */
1268
1304
  export const unit: Effect.Effect<void> = succeed(void 0)
@@ -1270,8 +1306,8 @@ export const unit: Effect.Effect<void> = succeed(void 0)
1270
1306
  /* @internal */
1271
1307
  export const updateRuntimeFlags = (patch: RuntimeFlagsPatch.RuntimeFlagsPatch): Effect.Effect<void> => {
1272
1308
  const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1273
- effect.i0 = patch
1274
- effect.i1 = void 0
1309
+ effect.effect_instruction_i0 = patch
1310
+ effect.effect_instruction_i1 = void 0
1275
1311
  return effect
1276
1312
  }
1277
1313
 
@@ -1306,12 +1342,9 @@ export const whileLoop = <A, E, R>(
1306
1342
  }
1307
1343
  ): Effect.Effect<void, E, R> => {
1308
1344
  const effect = new EffectPrimitive(OpCodes.OP_WHILE) as any
1309
- effect.i0 = options.while
1310
- effect.i1 = options.body
1311
- effect.i2 = options.step
1312
- internalize(options.body)
1313
- internalize(options.step)
1314
- internalize(options.while)
1345
+ effect.effect_instruction_i0 = options.while
1346
+ effect.effect_instruction_i1 = options.body
1347
+ effect.effect_instruction_i2 = options.step
1315
1348
  return effect
1316
1349
  }
1317
1350
 
@@ -1333,8 +1366,8 @@ export const withRuntimeFlags = dual<
1333
1366
  <A, E, R>(self: Effect.Effect<A, E, R>, update: RuntimeFlagsPatch.RuntimeFlagsPatch) => Effect.Effect<A, E, R>
1334
1367
  >(2, (self, update) => {
1335
1368
  const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1336
- effect.i0 = update
1337
- effect.i1 = () => self
1369
+ effect.effect_instruction_i0 = update
1370
+ effect.effect_instruction_i1 = () => self
1338
1371
  return effect
1339
1372
  })
1340
1373
 
@@ -2373,7 +2406,7 @@ export const exitIsSuccess = <A, E>(self: Exit.Exit<A, E>): self is Exit.Success
2373
2406
  export const exitIsInterrupted = <A, E>(self: Exit.Exit<A, E>): boolean => {
2374
2407
  switch (self._tag) {
2375
2408
  case OpCodes.OP_FAILURE:
2376
- return internalCause.isInterrupted(self.i0)
2409
+ return internalCause.isInterrupted(self.effect_instruction_i0)
2377
2410
  case OpCodes.OP_SUCCESS:
2378
2411
  return false
2379
2412
  }
@@ -2386,7 +2419,7 @@ export const exitAs = dual<
2386
2419
  >(2, <A, E, A2>(self: Exit.Exit<A, E>, value: A2): Exit.Exit<A2, E> => {
2387
2420
  switch (self._tag) {
2388
2421
  case OpCodes.OP_FAILURE: {
2389
- return exitFailCause(self.i0)
2422
+ return exitFailCause(self.effect_instruction_i0)
2390
2423
  }
2391
2424
  case OpCodes.OP_SUCCESS: {
2392
2425
  return exitSucceed(value) as Exit.Exit<A2, E>
@@ -2401,7 +2434,7 @@ export const exitAsUnit = <A, E>(self: Exit.Exit<A, E>): Exit.Exit<void, E> => e
2401
2434
  export const exitCauseOption = <A, E>(self: Exit.Exit<A, E>): Option.Option<Cause.Cause<E>> => {
2402
2435
  switch (self._tag) {
2403
2436
  case OpCodes.OP_FAILURE:
2404
- return Option.some(self.i0)
2437
+ return Option.some(self.effect_instruction_i0)
2405
2438
  case OpCodes.OP_SUCCESS:
2406
2439
  return Option.none()
2407
2440
  }
@@ -2431,7 +2464,7 @@ export const exitExists: {
2431
2464
  case OpCodes.OP_FAILURE:
2432
2465
  return false
2433
2466
  case OpCodes.OP_SUCCESS:
2434
- return refinement(self.i0)
2467
+ return refinement(self.effect_instruction_i0)
2435
2468
  }
2436
2469
  })
2437
2470
 
@@ -2442,7 +2475,7 @@ export const exitFail = <E>(error: E): Exit.Exit<never, E> =>
2442
2475
  /** @internal */
2443
2476
  export const exitFailCause = <E>(cause: Cause.Cause<E>): Exit.Exit<never, E> => {
2444
2477
  const effect = new EffectPrimitiveFailure(OpCodes.OP_FAILURE) as any
2445
- effect.i0 = cause
2478
+ effect.effect_instruction_i0 = cause
2446
2479
  return effect
2447
2480
  }
2448
2481
 
@@ -2453,10 +2486,10 @@ export const exitFlatMap = dual<
2453
2486
  >(2, <A, E, E2, A2>(self: Exit.Exit<A, E>, f: (a: A) => Exit.Exit<A2, E2>): Exit.Exit<A2, E | E2> => {
2454
2487
  switch (self._tag) {
2455
2488
  case OpCodes.OP_FAILURE: {
2456
- return exitFailCause(self.i0)
2489
+ return exitFailCause(self.effect_instruction_i0)
2457
2490
  }
2458
2491
  case OpCodes.OP_SUCCESS: {
2459
- return f(self.i0)
2492
+ return f(self.effect_instruction_i0)
2460
2493
  }
2461
2494
  }
2462
2495
  })
@@ -2476,10 +2509,10 @@ export const exitFlatMapEffect: {
2476
2509
  ): Effect.Effect<Exit.Exit<A2, E>, E2, R> => {
2477
2510
  switch (self._tag) {
2478
2511
  case OpCodes.OP_FAILURE: {
2479
- return succeed(exitFailCause(self.i0))
2512
+ return succeed(exitFailCause(self.effect_instruction_i0))
2480
2513
  }
2481
2514
  case OpCodes.OP_SUCCESS: {
2482
- return f(self.i0)
2515
+ return f(self.effect_instruction_i0)
2483
2516
  }
2484
2517
  }
2485
2518
  })
@@ -2504,10 +2537,10 @@ export const exitForEachEffect: {
2504
2537
  ): Effect.Effect<Exit.Exit<B, E | E2>, never, R> => {
2505
2538
  switch (self._tag) {
2506
2539
  case OpCodes.OP_FAILURE: {
2507
- return succeed(exitFailCause(self.i0))
2540
+ return succeed(exitFailCause(self.effect_instruction_i0))
2508
2541
  }
2509
2542
  case OpCodes.OP_SUCCESS: {
2510
- return exit(f(self.i0))
2543
+ return exit(f(self.effect_instruction_i0))
2511
2544
  }
2512
2545
  }
2513
2546
  })
@@ -2539,9 +2572,9 @@ export const exitGetOrElse = dual<
2539
2572
  >(2, (self, orElse) => {
2540
2573
  switch (self._tag) {
2541
2574
  case OpCodes.OP_FAILURE:
2542
- return orElse(self.i0)
2575
+ return orElse(self.effect_instruction_i0)
2543
2576
  case OpCodes.OP_SUCCESS:
2544
- return self.i0
2577
+ return self.effect_instruction_i0
2545
2578
  }
2546
2579
  })
2547
2580
 
@@ -2556,9 +2589,9 @@ export const exitMap = dual<
2556
2589
  >(2, (self, f) => {
2557
2590
  switch (self._tag) {
2558
2591
  case OpCodes.OP_FAILURE:
2559
- return exitFailCause(self.i0)
2592
+ return exitFailCause(self.effect_instruction_i0)
2560
2593
  case OpCodes.OP_SUCCESS:
2561
- return exitSucceed(f(self.i0))
2594
+ return exitSucceed(f(self.effect_instruction_i0))
2562
2595
  }
2563
2596
  })
2564
2597
 
@@ -2580,9 +2613,9 @@ export const exitMapBoth = dual<
2580
2613
  >(2, (self, { onFailure, onSuccess }) => {
2581
2614
  switch (self._tag) {
2582
2615
  case OpCodes.OP_FAILURE:
2583
- return exitFailCause(pipe(self.i0, internalCause.map(onFailure)))
2616
+ return exitFailCause(pipe(self.effect_instruction_i0, internalCause.map(onFailure)))
2584
2617
  case OpCodes.OP_SUCCESS:
2585
- return exitSucceed(onSuccess(self.i0))
2618
+ return exitSucceed(onSuccess(self.effect_instruction_i0))
2586
2619
  }
2587
2620
  })
2588
2621
 
@@ -2593,9 +2626,9 @@ export const exitMapError = dual<
2593
2626
  >(2, (self, f) => {
2594
2627
  switch (self._tag) {
2595
2628
  case OpCodes.OP_FAILURE:
2596
- return exitFailCause(pipe(self.i0, internalCause.map(f)))
2629
+ return exitFailCause(pipe(self.effect_instruction_i0, internalCause.map(f)))
2597
2630
  case OpCodes.OP_SUCCESS:
2598
- return exitSucceed(self.i0)
2631
+ return exitSucceed(self.effect_instruction_i0)
2599
2632
  }
2600
2633
  })
2601
2634
 
@@ -2606,9 +2639,9 @@ export const exitMapErrorCause = dual<
2606
2639
  >(2, (self, f) => {
2607
2640
  switch (self._tag) {
2608
2641
  case OpCodes.OP_FAILURE:
2609
- return exitFailCause(f(self.i0))
2642
+ return exitFailCause(f(self.effect_instruction_i0))
2610
2643
  case OpCodes.OP_SUCCESS:
2611
- return exitSucceed(self.i0)
2644
+ return exitSucceed(self.effect_instruction_i0)
2612
2645
  }
2613
2646
  })
2614
2647
 
@@ -2625,9 +2658,9 @@ export const exitMatch = dual<
2625
2658
  >(2, (self, { onFailure, onSuccess }) => {
2626
2659
  switch (self._tag) {
2627
2660
  case OpCodes.OP_FAILURE:
2628
- return onFailure(self.i0)
2661
+ return onFailure(self.effect_instruction_i0)
2629
2662
  case OpCodes.OP_SUCCESS:
2630
- return onSuccess(self.i0)
2663
+ return onSuccess(self.effect_instruction_i0)
2631
2664
  }
2632
2665
  })
2633
2666
 
@@ -2649,16 +2682,16 @@ export const exitMatchEffect = dual<
2649
2682
  >(2, (self, { onFailure, onSuccess }) => {
2650
2683
  switch (self._tag) {
2651
2684
  case OpCodes.OP_FAILURE:
2652
- return onFailure(self.i0)
2685
+ return onFailure(self.effect_instruction_i0)
2653
2686
  case OpCodes.OP_SUCCESS:
2654
- return onSuccess(self.i0)
2687
+ return onSuccess(self.effect_instruction_i0)
2655
2688
  }
2656
2689
  })
2657
2690
 
2658
2691
  /** @internal */
2659
2692
  export const exitSucceed = <A>(value: A): Exit.Exit<A> => {
2660
2693
  const effect = new EffectPrimitiveSuccess(OpCodes.OP_SUCCESS) as any
2661
- effect.i0 = value
2694
+ effect.effect_instruction_i0 = value
2662
2695
  return effect
2663
2696
  }
2664
2697
 
@@ -2751,18 +2784,18 @@ export const exitZipWith = dual<
2751
2784
  case OpCodes.OP_FAILURE: {
2752
2785
  switch (that._tag) {
2753
2786
  case OpCodes.OP_SUCCESS:
2754
- return exitFailCause(self.i0)
2787
+ return exitFailCause(self.effect_instruction_i0)
2755
2788
  case OpCodes.OP_FAILURE: {
2756
- return exitFailCause(onFailure(self.i0, that.i0))
2789
+ return exitFailCause(onFailure(self.effect_instruction_i0, that.effect_instruction_i0))
2757
2790
  }
2758
2791
  }
2759
2792
  }
2760
2793
  case OpCodes.OP_SUCCESS: {
2761
2794
  switch (that._tag) {
2762
2795
  case OpCodes.OP_SUCCESS:
2763
- return exitSucceed(onSuccess(self.i0, that.i0))
2796
+ return exitSucceed(onSuccess(self.effect_instruction_i0, that.effect_instruction_i0))
2764
2797
  case OpCodes.OP_FAILURE:
2765
- return exitFailCause(that.i0)
2798
+ return exitFailCause(that.effect_instruction_i0)
2766
2799
  }
2767
2800
  }
2768
2801
  }