"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dropWhile_ = exports.dropWhile = void 0;
const core_1 = require("./core");
const map_1 = require("./map");
/**
 * Drops all elements so long as the effectful predicate returns true.
 *
 * @ets_data_first dropWhile_
 */
function dropWhile(p, __trace) {
    return (as) => dropWhile_(as, p, __trace);
}
exports.dropWhile = dropWhile;
/**
 * Drops all elements so long as the effectful predicate returns true.
 */
function dropWhile_(as, p, __trace) {
    return (0, core_1.suspend)(() => {
        let dropping = (0, core_1.succeed)(true);
        const r = [];
        for (const a of as) {
            dropping = (0, core_1.chain_)(dropping, (d) => {
                if (d) {
                    return p(a);
                }
                else {
                    r.push(a);
                    return (0, core_1.succeed)(false);
                }
            });
        }
        return (0, map_1.map_)(dropping, () => r, __trace);
    });
}
exports.dropWhile_ = dropWhile_;
//# sourceMappingURL=dropWhile.js.map