Skip to main content
Module

x/fun/set.ts>chain

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

Given a function A -> ReadonlySet and a ReadonlySet return a ReadonlySet created by applying the function to every value A and joining all the resulting ReadonlySets.

Examples

Example 1

import * as S from "./set.ts";
import { pipe } from "./fn.ts";

const set = S.set(1, 2, 3, 4, 5);

const result = pipe(
  set,
  S.chain(n => S.set(n, n + 1, n + 2)),
); // Set(1, 2, 3, 4, 5, 6, 7);

Parameters

fati: (a: A) => ReadonlySet<I>

Returns

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