import * as tsplus_module_1 from "@effect/core/stm/STM/operations/zipRight";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/unit";
import * as tsplus_module_3 from "@effect/core/stm/STM/operations/suspend";
export const loopDiscard = loopDiscard_1;
/**
 * Loops with the specified transactional function purely for its
 * transactional effects. The moral equivalent of:
 *
 * ```typescript
 * var s = initial
 *
 * while (cont(s)) {
 *   body(s)
 *   s = inc(s)
 * }
 * ```
 *
 * @tsplus static ets/STM/Ops loopDiscard
 */

function loopDiscard_1(initial, cont, inc) {
  return body => {
    return tsplus_module_3.suspend(() => {
      const initial0 = initial();
      return cont(initial0) ? tsplus_module_1.zipRight_(body(initial0), () => loopDiscard_1(() => inc(initial0), cont, inc)(body)) : tsplus_module_2.unit_;
    });
  };
}
//# sourceMappingURL=loopDiscard.mjs.map