MCPcopy Create free account
hub / github.com/Effect-TS/effect / gen

Function gen

packages/effect/src/Result.ts:1490–1502  ·  view source on GitHub ↗
(...args)

Source from the content-addressed store, hash-verified

1488 * @since 2.0.0
1489 */
1490export const gen: Gen.Gen<ResultTypeLambda> = (...args) => {
1491 const f = args.length === 1 ? args[0] : args[1].bind(args[0])
1492 const iterator = f()
1493 let state: IteratorResult<any> = iterator.next()
1494 while (!state.done) {
1495 const current = state.value
1496 if (isFailure(current)) {
1497 return current
1498 }
1499 state = iterator.next(current.success as never)
1500 }
1501 return succeed(state.value) as any
1502}
1503
1504// -------------------------------------------------------------------------------------
1505// do notation

Callers

nothing calls this directly

Calls 4

succeedFunction · 0.70
nextMethod · 0.65
fFunction · 0.50
isFailureFunction · 0.50

Tested by

no test coverage detected