MCPcopy
hub / github.com/Effect-TS/effect / run

Method run

packages/effect/src/internal/stm/core.ts:474–586  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

472 }
473
474 run(): TExit.TExit<A, E> {
475 let curr = this.self as Primitive | Context.Tag<any, any> | Either.Either<any, any> | Option.Option<any> | undefined
476 let exit: TExit.TExit<unknown, unknown> | undefined = undefined
477 while (exit === undefined && curr !== undefined) {
478 try {
479 const current = curr
480 if (current) {
481 switch (current._op) {
482 case "Tag": {
483 curr = effect((_, __, env) => Context.unsafeGet(env, current)) as Primitive
484 break
485 }
486 case "Left": {
487 curr = fail(current.left) as Primitive
488 break
489 }
490 case "None": {
491 curr = fail(new Cause.NoSuchElementException()) as Primitive
492 break
493 }
494 case "Right": {
495 curr = succeed(current.right) as Primitive
496 break
497 }
498 case "Some": {
499 curr = succeed(current.value) as Primitive
500 break
501 }
502 case "Commit": {
503 switch (current.effect_instruction_i0) {
504 case OpCodes.OP_DIE: {
505 exit = TExit.die(internalCall(() => current.effect_instruction_i1()))
506 break
507 }
508 case OpCodes.OP_FAIL: {
509 const cont = this.nextFailure()
510 if (cont === undefined) {
511 exit = TExit.fail(internalCall(() => current.effect_instruction_i1()))
512 } else {
513 curr = internalCall(() =>
514 cont.effect_instruction_i2(
515 internalCall(() => current.effect_instruction_i1())
516 ) as Primitive
517 )
518 }
519 break
520 }
521 case OpCodes.OP_RETRY: {
522 const cont = this.nextRetry()
523 if (cont === undefined) {
524 exit = TExit.retry
525 } else {
526 curr = internalCall(() => cont.effect_instruction_i2() as Primitive)
527 }
528 break
529 }
530 case OpCodes.OP_INTERRUPT: {
531 exit = TExit.interrupt(this.fiberId)

Callers 5

makeWithFunction · 0.45
channel.tsFile · 0.45
interpretToPullFunction · 0.45
tryCommitFunction · 0.45
tryCommitSyncFunction · 0.45

Calls 14

nextFailureMethod · 0.95
nextRetryMethod · 0.95
pushStackMethod · 0.95
nextSuccessMethod · 0.95
unsafeGetMethod · 0.80
effectFunction · 0.70
failFunction · 0.70
succeedFunction · 0.70
syncFunction · 0.70
dieFunction · 0.70
dieMethod · 0.65
failMethod · 0.65

Tested by

no test coverage detected