match
import { match } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/these.ts";Pattern match on a These to extract values.
@example
import { match, left, right, both } from "./these.ts";
const matcher = match(
(error) => `Error: ${error}`,
(value) => `Success: ${value}`,
(warning, value) => `Partial: ${warning} - ${value}`
);
console.log(matcher(left("Failed"))); // "Error: Failed"
console.log(matcher(right(42))); // "Success: 42"
console.log(matcher(both("Warning", 42))); // "Partial: Warning - 42"
function match<A, B, O>(
onLeft: (b: B) => O,
onRight: (a: A) => O,
onBoth: (b: B, a: A) => O,
): (ta: These<B, A>) => O;