Skip to main content
Module

x/fun/boolean.ts>match

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function match
import { match } from "https://deno.land/x/fun@v2.0.0/boolean.ts";

Create a match function over boolean

Examples

Example 1

import { match } from "./boolean.ts";
import * as O from "./option.ts";

const match1 = match(() => "Tina", () => "Turner");
const match2 = match(() => O.some("Hi"), () => O.none);

const result1 = match1(true); // "Tina"
const result2 = match1(false); // "Turner"
const result3 = match2(true); // Some("Hi")
const result4 = match2(false); // None

Parameters

onTrue: () => A
onFalse: () => B

Returns

(a: boolean) => A | B