MCPcopy Index your code
hub / github.com/Effect-TS/effect / incRight

Function incRight

packages/effect/test/Effect/stack-safety.test.ts:77–82  ·  view source on GitHub ↗
(n: number, ref: Ref.Ref<number>)

Source from the content-addressed store, hash-verified

75 return pipe(incLeft(n - 1, ref), Effect.zipLeft(Ref.update(ref, (n) => n + 1)))
76 }
77 const incRight = (n: number, ref: Ref.Ref<number>): Effect.Effect<number> => {
78 if (n <= 0) {
79 return Ref.get(ref)
80 }
81 return pipe(Ref.update(ref, (n) => n + 1), Effect.zipRight(incRight(n - 1, ref)))
82 }
83 const left = pipe(Ref.make(0), Effect.flatMap((ref) => incLeft(100, ref)), Effect.map((n) => n === 0))
84 const right = pipe(Ref.make(0), Effect.flatMap((ref) => incRight(1000, ref)), Effect.map((n) => n === 1000))
85 const result = yield* pipe(left, Effect.zipWith(right, (a, b) => a && b))

Callers 1

Calls 3

getMethod · 0.65
updateMethod · 0.65
pipeFunction · 0.50

Tested by

no test coverage detected