Skip to main content
Module

x/fun/mod.ts>set.set

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
interface set.set
implements Kind
Re-export
import { type set } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { set } = set;

Specifies ReadonlySet as a Higher Kinded Type, with covariant parameter A corresponding to the 0th index of any substitutions.

Properties

readonly
kind: ReadonlySet<Out<this, 0>>
type alias set.set
Re-export
import { type set } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { set } = set;

Extract the inner type of a ReadonlySet

definition: T extends ReadonlySet<infer A> ? A : never
variable set.set
Re-export
import { set } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { set } = set;

The canonical implementation of Functor for ReadonlySet. It contains the method map.

function set.set
Re-export
import { set } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { set } = set;

Constructs a new ReadonlySet from an arbitrary number of values.

Examples

Example 1

import * as S from "./set.ts";

const result = S.set(1, 2, 3); // ReadonlySet<number>

Parameters

...as: readonly [A, ...A[]]

Returns

ReadonlySet<A>

Given a Refinement or Predicate over A and a ReadonlySet return a new ReadonlySet with only values for which the predicate or refinement return true.

Examples

Example 1

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

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

const result1 = pipe(set, S.filter(n => n > 2)); // Set(3, 4, 5)
const result2 = pipe(set, S.filter(n => n === 0)); // Set()

Type Parameters

A
B extends A

Parameters

refinement: Refinement<A, B>

Returns

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

Parameters

predicate: Predicate<A>

Returns

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

Given a Predicate or Refinement over A and a ReadonlySet return a Pair with a first value being a ReadonlySet of values that return true when applied to the refinement or predicate and a second value being a ReadonlySet of values that return false when applied to the predicate.

Examples

Example 1

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

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

const result = pipe(
  set,
  S.partition(n => n > 2),
); // [Set(3, 4), Set(1, 2)]

Type Parameters

A
B extends A

Parameters

refinement: Refinement<A, B>

Returns

(ua: ReadonlySet<A>) => Pair<ReadonlySet<B>, ReadonlySet<A>>

Parameters

predicate: Predicate<A>

Returns

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