Skip to main content
Module

x/fun/mod.ts>comparable.union

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

Create a Comparable from two other Comparables. The resultant Comparable checks that any two values are equal according to at least one of the supplied eqs.

It should be noted that we cannot differentiate the eq used to compare two disparate types like number and number[]. Thus, internally union must type cast to any and treat thrown errors as a false equivalence.

Examples

Example 1

import { union, number, string } from "./comparable.ts";
import { pipe } from "./fn.ts";

const { compare } = pipe(number, union(string));

const result1 = compare(1)("Hello"); // false
const result2 = compare(1)(1); // true

Returns

<A>(first: Comparable<A>) => Comparable<A | I>