import * as Tp from "../../Collections/Immutable/Tuple";
import * as O from "../../Option";
import * as SC from "../../Schedule";
import * as T from "../_internal/effect";
import { chain_ } from "./chain";
import { concat_ } from "./concat";
import { fromEffect } from "./fromEffect";
import { succeed } from "./succeed";
import { unfoldM } from "./unfoldM";
/**
 * Creates a stream from an effect producing a value of type `A`, which is repeated using the
 * specified schedule.
 */

export function repeatEffectWith(effect, schedule) {
  return chain_(fromEffect(T.zip_(effect, SC.driver(schedule))), ({
    tuple: [a, driver]
  }) => concat_(succeed(a), unfoldM(a, _ => T.foldM_(driver.next(_), T.succeed, _ => T.map_(effect, nextA => O.some(Tp.tuple(nextA, nextA)))))));
}
//# sourceMappingURL=repeatEffectWith.js.map