Skip to main content
Module

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

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>>