Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>comparable.thunk

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

Create a eq that tests the output of a thunk (IO). This assumes that the output of the thunk is always the same, which for true IO is not the case. This assumes that the context for the function is undefined, which means that it doesn't rely on "this" to execute.

Examples

Example 1

import { struct, thunk, number } from "./comparable.ts";

const { compare } = struct({ asNumber: thunk(number) });

const one = { asNumber: () => 1 };
const two = { asNumber: () => 2 };

const result1 = compare(one)(two); // false
const result2 = compare(one)(one); // true