// tracing: off
import { pipe } from "../Function"
import * as catchAll from "./catchAll"
import * as core from "./core"
import * as fail from "./fail"
/**
 * Retries this effect until its error satisfies the specified effectful predicate.
 *
 * @dataFirst retryUtilM_
 */

export function retryUntilM(f, __trace) {
  return (self) => retryUntilM_(self, f)
}
/**
 * Retries this effect until its error satisfies the specified effectful predicate.
 */

export function retryUntilM_(self, f, __trace) {
  return core.suspend(
    () =>
      catchAll.catchAll_(self, (e) =>
        core.chain_(f(e), (b) => (b ? fail.fail(e) : retryUntilM_(self, f)))
      ),
    __trace
  )
}
/**
 * Retries this effect until its error satisfies the specified predicate.
 *
 * @dataFirst retryUntil_
 */

export function retryUntil(f, __trace) {
  return (self) => retryUntil_(self, f, __trace)
}
/**
 * Retries this effect until its error satisfies the specified predicate.
 */

export function retryUntil_(self, f, __trace) {
  return retryUntilM_(self, (a) => core.succeed(f(a)), __trace)
}
//# sourceMappingURL=retryUntil.js.map
