import type { Decision } from "@effect/core/io/Schedule/Decision" import { makeWithState } from "@effect/core/io/Schedule/operations/_internal/makeWithState" /** * Returns a new schedule that loops this one continuously, resetting the * state when this schedule is done. * * @tsplus getter effect/core/io/Schedule forever */ export function forever( self: Schedule ): Schedule { return makeWithState(self.initial, (now, input, state) => { function step( now: number, input: In, state: State ): Effect { return self .step(now, input, state) .flatMap(([state, out, decision]) => decision._tag === "Done" ? step(now, input, self.initial) : Effect.succeed([state, out, decision]) ) } return step(now, input, state) }) }