Skip to main content
Module

x/fun/mod.ts>set.partitionMap

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

Given a function A -> Either<J, I> and a ReadonlySet return a Pair(ReadonlySet, ReadonlySet) by applying every value A in the set to the partitioning function.

Examples

Example 1

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

const set = S.set("one", "two", "three", "four");

const result = pipe(
  set,
  S.partitionMap(s => s.includes('o') ? E.right(s) : E.left(s.length)),
); // [Set("one", "two", "four"), Set(5)]

Parameters

fai: (a: A) => Either<J, I>

Returns

(ua: ReadonlySet<A>) => Pair<ReadonlySet<I>, ReadonlySet<J>>