Skip to main content
Module

x/fun/comparable.ts>intersect

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 intersect
import { intersect } from "https://deno.land/x/fun@v2.0.0-alpha.12/comparable.ts";

Create a eq from two other eqs. The resultant eq checks that any two values are equal according to both supplied eqs.

Examples

Example 1

import { intersect, struct, partial, string } from "./comparable.ts";
import { pipe } from "./fn.ts";

const { compare } = pipe(
  struct({ firstName: string }),
  intersect(partial({ lastName: string }))
);

const batman = { firstName: "Batman" };
const grace = { firstName: "Grace", lastName: "Hopper" };

const result1 = compare(batman)(grace); // false
const result2 = compare(grace)(grace); // true

Returns

<A>(first: Comparable<A>) => Comparable<Spread<A & I>>