// tracing: off
import { failureOrCause } from "../../Cause"
import * as E from "../../Either"
import { pipe } from "../../Function"
import { foldCauseM_ } from "../core"
import { halt } from "./halt"
/**
 * Recovers from errors by accepting one effect to execute for the case of an
 * error, and one effect to execute for the case of success.
 *
 * @dataFirst foldM_
 */

export function foldM(failure, success, __trace) {
  return (self) => foldM_(self, failure, success, __trace)
}
/**
 * Recovers from errors by accepting one effect to execute for the case of an
 * error, and one effect to execute for the case of success.
 */

export function foldM_(self, failure, success, __trace) {
  return foldCauseM_(
    self,
    (x) => E.fold_(failureOrCause(x), failure, halt),
    success,
    __trace
  )
}
//# sourceMappingURL=foldM.js.map
