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

Function unfoldEffectLoop

packages/effect/test/utils/unfoldEffect.ts:14–25  ·  view source on GitHub ↗
(
  s: S,
  f: (s: S) => Effect.Effect<Option.Option<readonly [A, S]>, E, R>,
  acc: List.List<A>
)

Source from the content-addressed store, hash-verified

12 )
13
14const unfoldEffectLoop = <A, S, E, R>(
15 s: S,
16 f: (s: S) => Effect.Effect<Option.Option<readonly [A, S]>, E, R>,
17 acc: List.List<A>
18): Effect.Effect<List.List<A>, E, R> =>
19 Effect.flatMap(f(s), (option) => {
20 if (Option.isSome(option)) {
21 return unfoldEffectLoop(option.value[1], f, List.prepend(acc, option.value[0]))
22 } else {
23 return Effect.succeed(acc)
24 }
25 })

Callers 1

unfoldEffectFunction · 0.85

Calls 1

fFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…