// ets_tracing: off import type { Predicate, Refinement } from "../Function/index.js" import * as core from "./core.js" import type { IO } from "./effect.js" import * as fail from "./fail.js" /** * Lift a predicate into an effectful function */ export function fromPredicate( refinement: Refinement, onFalse: (a: A) => E ): (a: A) => IO export function fromPredicate( predicate: Predicate, onFalse: (a: A) => E ): (a: A) => IO export function fromPredicate(predicate: Predicate, onFalse: (a: A) => E) { return (a: A): IO => core.suspend(() => (predicate(a) ? core.succeed(a) : fail.fail(onFalse(a)))) }