// tracing: off
import * as C from "../Cause"
import * as E from "../Either/core"
import { pipe } from "../Function"
import * as O from "../Option/core"
import { foldCauseM_, halt, succeed } from "./core"
/**
 * Recovers from some or all of the error cases.
 *
 * @dataFirst catchSome_
 */

export function catchSome(f, __trace) {
  return (fa) => catchSome_(fa, f, __trace)
}
/**
 * Recovers from some or all of the error cases.
 */

export function catchSome_(fa, f, __trace) {
  return foldCauseM_(
    fa,
    (cause) =>
      E.fold_(
        C.failureOrCause(cause),
        (x) => O.getOrElse(() => halt(cause))(f(x)),
        halt
      ),
    succeed,
    __trace
  )
}
//# sourceMappingURL=catchSome.js.map
