Skip to main content
Module

x/fun/mod.ts>set.getUnionMonoid

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 set.getUnionMonoid
import { set } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { getUnionMonoid } = set;

Given an instance of Eq create a Monoid<ReadonlySet> where concat creates a union of two ReadonlySets.

Examples

Example 1

import * as S from "./set.ts";
import * as N from "./number.ts";
import * as M from "./monoid.ts";
import { pipe } from "./fn.ts";

const monoid = S.getUnionMonoid(N.EqNumber);
const concatAll = M.concatAll(monoid);

const result1 = concatAll([
  S.set(1, 2, 3),
  S.set(4, 5, 6),
  S.set(1, 3, 5, 7)
]); // Set(1, 2, 3, 4, 5, 6, 7)
const result2 = concatAll([]); // Set()
const result3 = concatAll([S.empty()]); // Set()

Returns

Monoid<ReadonlySet<A>>