import * as tracing_1 from "../../../../Tracing"
import * as tracing_2 from "../../../../Tracing"
const fileName_1 = "(@effect-ts/system): _src/Collections/Immutable/List/api/filterM.ts"
import * as core from "../../../../Effect/core"
import * as coreZip from "../../../../Effect/zipWith"
import * as List from "../core"
/**
 * Filters this list by the specified effectful predicate, retaining all elements for
 * which the predicate evaluates to true.
 */

export function filterM_(self, f) {
  return core.suspend(() => {
    let dest = core.succeed(List.empty(), fileName_1 + ":15:56")

    for (const a of self) {
      dest = coreZip.zipWith_(
        dest,
        f(a),
        (d, b) => (b ? List.append_(d, a) : d),
        fileName_1 + ":18:30"
      )
    }

    return dest
  }, fileName_1 + ":14:22")
}
/**
 * Filters this list by the specified effectful predicate, retaining all elements for
 * which the predicate evaluates to true.
 *
 * @dataFirst filterM_
 */

export function filterM(f) {
  return (self) => filterM_(self, f)
}
//# sourceMappingURL=filterM.js.map
