Skip to main content
Module

x/fun/mod.ts>set.compact

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

Given an instance of Comparable create a function that will take a ReadonlySet and return a new ReadonlySet where any members that are equal are deduplicated.

Examples

Example 1

import * as S from "./set.ts";
import * as N from "./number.ts";
import * as E from "./comparable.ts";

const eq = E.struct({ num: N.ComparableNumber });
const compact = S.compact(eq);

const set = S.set({ num: 1 }, { num: 1 }, { num: 2 });
// Set({ num: 1 }, { num: 1 }, { num: 2 })

const result = compact(set); // Set({ num: 1 }, { num: 2 })

Parameters

S: Comparable<A>

Returns

(ua: ReadonlySet<A>) => ReadonlySet<A>