// tracing: off
import { pipe } from "../Function"
import * as O from "../Option/core"
import { chain_, succeed } from "./core"
import { failWith } from "./fail"
/**
 * Fail with `e` if the supplied `PartialFunction` does not match, otherwise
 * continue with the returned value.
 */

export function continueOrFailM_(fa, f, pf, __trace) {
  return chain_(fa, (a) => O.getOrElse_(pf(a), () => failWith(f)), __trace)
}
/**
 * Fail with `e` if the supplied `PartialFunction` does not match, otherwise
 * continue with the returned value.
 *
 * @dataFirst continueOrFailM_
 */

export function continueOrFailM(f, pf, __trace) {
  return (fa) => continueOrFailM_(fa, f, pf, __trace)
}
/**
 * Fail with `e` if the supplied `PartialFunction` does not match, otherwise
 * succeed with the returned value.
 */

export function continueOrFail_(fa, f, pf, __trace) {
  return continueOrFailM_(fa, f, (x) => O.map_(pf(x), succeed), __trace)
}
/**
 * Fail with `e` if the supplied `PartialFunction` does not match, otherwise
 * succeed with the returned value.
 *
 * @dataFirst continueOrFail_
 */

export function continueOrFail(f, pf, __trace) {
  return (fa) => continueOrFail_(fa, f, pf, __trace)
}
//# sourceMappingURL=continueOrFail.js.map
