Skip to main content
Module

x/fun/option.ts>getComparable

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

Create an instance of Comparable<Option> given an instance of Comparable.

Examples

Example 1

import * as O from "./option.ts";
import * as N from "./number.ts";
import { pipe } from "./fn.ts";

const { compare } = O.getComparable(N.ComparableNumber);

const result1 = pipe(O.some(1), compare(O.some(2))); // false
const result2 = pipe(O.some(1), compare(O.some(1))); // true
const result3 = pipe(O.none, compare(O.none)); // true
const result4 = pipe(O.some(1), compare(O.none)); // false