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

Function failInTheMiddle

packages/effect/test/TArray.test.ts:1049–1050  ·  view source on GitHub ↗
(acc: number, n: number)

Source from the content-addressed store, hash-verified

1047 Effect.gen(function*() {
1048 const n = 1_000
1049 const failInTheMiddle = (acc: number, n: number): STM.STM<number, string> =>
1050 acc === Math.floor(n / 2) ? STM.fail("boom") : STM.succeed(acc + n)
1051 const array = yield* (makeTArray(n, 1))
1052 const result = yield* (pipe(array, TArray.reduceSTM(0, failInTheMiddle), STM.either))
1053 assertLeft(result, "boom")

Callers

nothing calls this directly

Calls 1

failMethod · 0.65

Tested by

no test coverage detected