"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.condM = exports.condM_ = exports.cond_ = exports.cond = void 0
// tracing: off
const core_1 = require("./core")
const fail_1 = require("./fail")
/**
 * Evaluate the predicate,
 * return the given A as success if predicate returns true,
 * and the given E as error otherwise
 *
 * @dataFirst cond_
 */
function cond(onTrue, onFalse, __trace) {
  return (b) => cond_(b, onTrue, onFalse, __trace)
}
exports.cond = cond
/**
 * Evaluate the predicate,
 * return the given A as success if predicate returns true,
 * and the given E as error otherwise
 */
function cond_(b, onTrue, onFalse, __trace) {
  return condM_(
    b,
    (0, core_1.succeedWith)(onTrue),
    (0, core_1.succeedWith)(onFalse),
    __trace
  )
}
exports.cond_ = cond_
/**
 * Evaluate the predicate,
 * return the given A as success if predicate returns true,
 * and the given E as error otherwise
 */
function condM_(b, onTrue, onFalse, __trace) {
  return (0, core_1.suspend)(
    () => (b ? onTrue : (0, core_1.chain_)(onFalse, (x) => (0, fail_1.fail)(x))),
    __trace
  )
}
exports.condM_ = condM_
/**
 * Evaluate the predicate,
 * return the given A as success if predicate returns true,
 * and the given E as error otherwise
 */
function condM(onTrue, onFalse, __trace) {
  return (b) => condM_(b, onTrue, onFalse, __trace)
}
exports.condM = condM
//# sourceMappingURL=cond.js.map
