import type { Driver } from "@effect/core/io/Schedule" /** * Runs this effect according to the specified schedule. * * See `scheduleFrom` for a variant that allows the schedule's decision to * depend on the result of this effect. * * @tsplus static effect/core/io/Effect.Aspects scheduleFrom * @tsplus pipeable effect/core/io/Effect scheduleFrom */ export function scheduleFrom(a: A, schedule: Schedule) { return (self: Effect): Effect => schedule.driver.flatMap(scheduleFromLoop(self, a)) } function scheduleFromLoop(self: Effect, value: A) { return (driver: Driver): Effect => driver.next(value).foldEffect( () => driver.last.orDie, () => self.flatMap((a) => scheduleFromLoop(self, a)(driver)) ) }