"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateFirstParN = exports.validateFirstParN_ = exports.validateFirstPar = exports.validateFirstPar_ = exports.validateFirst = exports.validateFirst_ = void 0;
const excl_forEach_1 = require("./excl-forEach");
const flip_1 = require("./flip");
/**
 * Feeds elements of type `A` to `f` until it succeeds. Returns first success
 * or the accumulation of all errors.
 */
function validateFirst_(i, f, __trace) {
    return (0, flip_1.flip)((0, excl_forEach_1.forEach_)(i, (a) => (0, flip_1.flip)(f(a)), __trace));
}
exports.validateFirst_ = validateFirst_;
/**
 * Feeds elements of type `A` to `f` until it succeeds. Returns first success
 * or the accumulation of all errors.
 *
 * @ets_data_first validateFirst_
 */
function validateFirst(f, __trace) {
    return (i) => validateFirst_(i, f, __trace);
}
exports.validateFirst = validateFirst;
/**
 * Feeds elements of type `A` to `f`, in parallel, until it succeeds. Returns
 * first success or the accumulation of all errors.
 *
 * In case of success all other running fibers are terminated.
 */
function validateFirstPar_(i, f, __trace) {
    return (0, flip_1.flip)((0, excl_forEach_1.forEachPar_)(i, (a) => (0, flip_1.flip)(f(a)), __trace));
}
exports.validateFirstPar_ = validateFirstPar_;
/**
 * Feeds elements of type `A` to `f`, in parallel, until it succeeds. Returns
 * first success or the accumulation of all errors.
 *
 * In case of success all other running fibers are terminated.
 *
 * @ets_data_first validateFirstPar_
 */
function validateFirstPar(f, __trace) {
    return (i) => validateFirstPar_(i, f, __trace);
}
exports.validateFirstPar = validateFirstPar;
/**
 * Feeds elements of type `A` to `f`, in parallel, until it succeeds. Returns
 * first success or the accumulation of all errors.
 *
 * In case of success all other running fibers are terminated.
 *
 * Uses up to N fibers.
 */
function validateFirstParN_(i, n, f, __trace) {
    return (0, flip_1.flip)((0, excl_forEach_1.forEachParN_)(i, n, (a) => (0, flip_1.flip)(f(a)), __trace));
}
exports.validateFirstParN_ = validateFirstParN_;
/**
 * Feeds elements of type `A` to `f`, in parallel, until it succeeds. Returns
 * first success or the accumulation of all errors.
 *
 * In case of success all other running fibers are terminated.
 *
 * Uses up to N fibers.
 *
 * @ets_data_first validateFirstParN_
 */
function validateFirstParN(n, f, __trace) {
    return (i) => validateFirstParN_(i, n, f, __trace);
}
exports.validateFirstParN = validateFirstParN;
//# sourceMappingURL=validateFirst.js.map