import * as tsplus_module_1 from "@tsplus/stdlib/collections/Chunk/isEmpty";
import * as tsplus_module_2 from "@tsplus/stdlib/collections/Chunk/definition";
import * as tsplus_module_3 from "@effect/core/stm/STM/operations/succeedNow";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/fail";
import * as tsplus_module_5 from "@effect/core/stm/STM/operations/partition";
import * as tsplus_module_6 from "@effect/core/stm/STM/operations/flatMap";
/**
 * Feeds elements of type `A` to `f` and accumulates all errors in error
 * channel or successes in success channel.
 *
 * This combinator is lossy meaning that if there are errors all successes
 * will be lost. To retain all information please use `partition`.
 *
 * @tsplus static ets/STM/Ops validate
 */

export function validate(as, f) {
  return tsplus_module_6.flatMap_(tsplus_module_5.partition(as, f), ({
    tuple: [es, bs]
  }) => tsplus_module_1.isEmpty(es) ? tsplus_module_3.succeedNow(tsplus_module_2.from(bs)) : tsplus_module_4.fail(() => es));
}
//# sourceMappingURL=validate.mjs.map