Skip to main content
Module

x/fun/comparable.ts>thunk

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

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