import * as tsplus_module_1 from "@effect/core/stm/STM/operations/failNow";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/succeed";
import * as tsplus_module_3 from "@effect/core/stm/STM/operations/flatMap";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/succeedNow";
import * as tsplus_module_5 from "@tsplus/stdlib/data/Maybe/fold";
/**
 * Extracts the optional value, or fails with the given error 'e'.
 *
 * @tsplus fluent ets/STM someOrFail
 */

export function someOrFail_(self, orFail) {
  return tsplus_module_3.flatMap_(self, option => tsplus_module_5.fold_(option, () => tsplus_module_3.flatMap_(tsplus_module_2.succeed(orFail), tsplus_module_1.failNow), tsplus_module_4.succeedNow));
}
/**
 * Extracts the optional value, or fails with the given error 'e'.
 *
 * @tsplus static ets/STM/Aspects someOrFail
 */

export const someOrFail = orFail => self => someOrFail_(self, orFail);
//# sourceMappingURL=someOrFail.mjs.map