( s: S, max: number, costFn: (s: S, input: In) => Effect.Effect<number, E, R>, decompose: (input: In) => Effect.Effect<Chunk.Chunk<In>, E2, R2>, f: (s: S, input: In) => Effect.Effect<S, E3, R3>, cost: number, dirty: boolean )
| 1246 | }) |
| 1247 | |
| 1248 | const foldWeightedDecomposeEffectLoop = <S, In, E, R, E2, R2, E3, R3>( |
| 1249 | s: S, |
| 1250 | max: number, |
| 1251 | costFn: (s: S, input: In) => Effect.Effect<number, E, R>, |
| 1252 | decompose: (input: In) => Effect.Effect<Chunk.Chunk<In>, E2, R2>, |
| 1253 | f: (s: S, input: In) => Effect.Effect<S, E3, R3>, |
| 1254 | cost: number, |
| 1255 | dirty: boolean |
| 1256 | ): Channel.Channel<Chunk.Chunk<In>, Chunk.Chunk<In>, E | E2 | E3, E | E2 | E3, S, unknown, R | R2 | R3> => |
| 1257 | core.readWith({ |
| 1258 | onInput: (input: Chunk.Chunk<In>) => |
| 1259 | pipe( |
| 1260 | core.fromEffect(foldWeightedDecomposeEffectFold(s, max, costFn, decompose, f, input, dirty, cost, 0)), |
| 1261 | core.flatMap(([nextS, nextCost, nextDirty, leftovers]) => { |
| 1262 | if (Chunk.isNonEmpty(leftovers)) { |
| 1263 | return pipe(core.write(leftovers), channel.zipRight(core.succeedNow(nextS))) |
| 1264 | } |
| 1265 | if (cost > max) { |
| 1266 | return core.succeedNow(nextS) |
| 1267 | } |
| 1268 | return foldWeightedDecomposeEffectLoop(nextS, max, costFn, decompose, f, nextCost, nextDirty) |
| 1269 | }) |
| 1270 | ), |
| 1271 | onFailure: core.fail, |
| 1272 | onDone: () => core.succeedNow(s) |
| 1273 | }) |
| 1274 | |
| 1275 | /** @internal */ |
| 1276 | const foldWeightedDecomposeEffectFold = <S, In, E, R, E2, R2, E3, R3>( |
no test coverage detected
searching dependent graphs…