import * as tsplus_module_1 from "@effect/core/stm/STM/operations/asSome";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/succeedNone";
import * as tsplus_module_3 from "@effect/core/stm/STM/operations/suspend";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/flatMap";
/**
 * The moral equivalent of `if (p) exp` when `p` has side-effects.
 *
 * @tsplus static ets/STM/Ops whenSTM
 */

export function whenSTM(predicate, effect) {
  return tsplus_module_4.flatMap_(tsplus_module_3.suspend(predicate), b => b ? tsplus_module_1.asSome(effect()) : tsplus_module_2.succeedNone);
}
//# sourceMappingURL=whenSTM.mjs.map