Skip to content
Effect Days 2026 Get your ticket

TSet

31 exports Added in v2.0.0 Source

Constructors

empty

Added in v2.0.0 Source

Makes an empty TSet.

Signature

declare const empty: <A>() => STM.STM<TSet<A>>

fromIterable

Added in v2.0.0 Source

Creates a new TSet from an iterable collection of values.

Signature

declare const fromIterable: <A>(iterable: Iterable<A>) => STM.STM<TSet<A>>

make

Added in v2.0.0 Source

Makes a new TSet that is initialized with specified values.

Signature

declare const make: <Elements extends Array<any>>(...elements: Elements) => STM.STM<TSet<Elements[number]>>

Destructors

toArray

Added in v2.0.0 Source

Collects all elements into a Array.

Signature

declare const toArray: <A>(self: TSet<A>) => STM.STM<Array<A>>

toChunk

Added in v2.0.0 Source

Collects all elements into a Chunk.

Signature

declare const toChunk: <A>(self: TSet<A>) => STM.STM<Chunk.Chunk<A>>

toHashSet

Added in v2.0.0 Source

Collects all elements into a HashSet.

Signature

declare const toHashSet: <A>(self: TSet<A>) => STM.STM<HashSet.HashSet<A>>

Collects all elements into a ReadonlySet.

Signature

declare const toReadonlySet: <A>(self: TSet<A>) => STM.STM<ReadonlySet<A>>

Elements

forEach

Added in v2.0.0 Source

Atomically performs transactional-effect for each element in set.

Signature

declare const forEach: {
<A, R, E>(f: (value: A) => STM<void, E, R>): (self: TSet<A>) => STM<void, E, R>;
<A, R, E>(self: TSet<A>, f: (value: A) => STM<void, E, R>): STM<void, E, R>;
}

has

Added in v2.0.0 Source

Tests whether or not set contains an element.

Signature

declare const has: {
<A>(value: A): (self: TSet<A>) => STM<boolean>;
<A>(self: TSet<A>, value: A): STM<boolean>;
}

Folding

reduce

Added in v2.0.0 Source

Atomically folds using a pure function.

Signature

declare const reduce: {
<Z, A>(zero: Z, f: (accumulator: Z, value: A) => Z): (self: TSet<A>) => STM<Z>;
<Z, A>(self: TSet<A>, zero: Z, f: (accumulator: Z, value: A) => Z): STM<Z>;
}

reduceSTM

Added in v2.0.0 Source

Atomically folds using a transactional function.

Signature

declare const reduceSTM: {
<Z, A, R, E>(zero: Z, f: (accumulator: Z, value: A) => STM<Z, E, R>): (self: TSet<A>) => STM<Z, E, R>;
<Z, A, R, E>(self: TSet<A>, zero: Z, f: (accumulator: Z, value: A) => STM<Z, E, R>): STM<Z, E, R>;
}

Getters

isEmpty

Added in v2.0.0 Source

Tests if the set is empty or not

Signature

declare const isEmpty: <A>(self: TSet<A>) => STM.STM<boolean>

size

Added in v2.0.0 Source

Returns the set's cardinality.

Signature

declare const size: <A>(self: TSet<A>) => STM.STM<number>

Models

TSet interface

Added in v2.0.0 Source

Transactional set implemented on top of TMap.

Signature

interface TSet<in out A> extends Variance<A> {}

Mutations

add

Added in v2.0.0 Source

Stores new element in the set.

Signature

declare const add: {
<A>(value: A): (self: TSet<A>) => STM<void>;
<A>(self: TSet<A>, value: A): STM<void>;
}

difference

Added in v2.0.0 Source

Atomically transforms the set into the difference of itself and the provided set.

Signature

declare const difference: {
<A>(other: TSet<A>): (self: TSet<A>) => STM<void>;
<A>(self: TSet<A>, other: TSet<A>): STM<void>;
}

intersection

Added in v2.0.0 Source

Atomically transforms the set into the intersection of itself and the provided set.

Signature

declare const intersection: {
<A>(other: TSet<A>): (self: TSet<A>) => STM<void>;
<A>(self: TSet<A>, other: TSet<A>): STM<void>;
}

remove

Added in v2.0.0 Source

Removes a single element from the set.

Signature

declare const remove: {
<A>(value: A): (self: TSet<A>) => STM<void>;
<A>(self: TSet<A>, value: A): STM<void>;
}

removeAll

Added in v2.0.0 Source

Removes elements from the set.

Signature

declare const removeAll: {
<A>(iterable: Iterable<A>): (self: TSet<A>) => STM<void>;
<A>(self: TSet<A>, iterable: Iterable<A>): STM<void>;
}

removeIf

Added in v2.0.0 Source

Removes entries from a TSet that satisfy the specified predicate and returns the removed entries (or void if discard = true).

Signature

declare const removeIf: {
<A>(predicate: Predicate<A>, options: {
readonly discard: true;
}): (self: TSet<A>) => STM<void>;
<A>(predicate: Predicate<A>, options?: {
readonly discard: false;
}): (self: TSet<A>) => STM<Array<A>>;
<A>(self: TSet<A>, predicate: Predicate<A>, options: {
readonly discard: true;
}): STM<void>;
<A>(self: TSet<A>, predicate: Predicate<A>, options?: {
readonly discard: false;
}): STM<Array<A>>;
}

retainIf

Added in v2.0.0 Source

Retains entries in a TSet that satisfy the specified predicate and returns the removed entries (or void if discard = true).

Signature

declare const retainIf: {
<A>(predicate: Predicate<A>, options: {
readonly discard: true;
}): (self: TSet<A>) => STM<void>;
<A>(predicate: Predicate<A>, options?: {
readonly discard: false;
}): (self: TSet<A>) => STM<Array<A>>;
<A>(self: TSet<A>, predicate: Predicate<A>, options: {
readonly discard: true;
}): STM<void>;
<A>(self: TSet<A>, predicate: Predicate<A>, options?: {
readonly discard: false;
}): STM<Array<A>>;
}

takeFirst

Added in v2.0.0 Source

Takes the first matching value, or retries until there is one.

Signature

declare const takeFirst: {
<A, B>(pf: (a: A) => Option<B>): (self: TSet<A>) => STM<B>;
<A, B>(self: TSet<A>, pf: (a: A) => Option<B>): STM<B>;
}

takeFirstSTM

Added in v2.0.0 Source

Takes the first matching value, or retries until there is one.

Signature

declare const takeFirstSTM: {
<A, B, E, R>(pf: (a: A) => STM<B, Option<E>, R>): (self: TSet<A>) => STM<B, E, R>;
<A, B, E, R>(self: TSet<A>, pf: (a: A) => STM<B, Option<E>, R>): STM<B, E, R>;
}

takeSome

Added in v2.0.0 Source

Takes all matching values, or retries until there is at least one.

Signature

declare const takeSome: {
<A, B>(pf: (a: A) => Option<B>): (self: TSet<A>) => STM<[B, ...Array<B>]>;
<A, B>(self: TSet<A>, pf: (a: A) => Option<B>): STM<[B, ...Array<B>]>;
}

takeSomeSTM

Added in v2.0.0 Source

Takes all matching values, or retries until there is at least one.

Signature

declare const takeSomeSTM: {
<A, B, E, R>(pf: (a: A) => STM<B, Option<E>, R>): (self: TSet<A>) => STM<[B, ...Array<B>], E, R>;
<A, B, E, R>(self: TSet<A>, pf: (a: A) => STM<B, Option<E>, R>): STM<[B, ...Array<B>], E, R>;
}

transform

Added in v2.0.0 Source

Atomically updates all elements using a pure function.

Signature

declare const transform: {
<A>(f: (a: A) => A): (self: TSet<A>) => STM<void>;
<A>(self: TSet<A>, f: (a: A) => A): STM<void>;
}

transformSTM

Added in v2.0.0 Source

Atomically updates all elements using a transactional function.

Signature

declare const transformSTM: {
<A, R, E>(f: (a: A) => STM<A, E, R>): (self: TSet<A>) => STM<void, E, R>;
<A, R, E>(self: TSet<A>, f: (a: A) => STM<A, E, R>): STM<void, E, R>;
}

union

Added in v2.0.0 Source

Atomically transforms the set into the union of itself and the provided set.

Signature

declare const union: {
<A>(other: TSet<A>): (self: TSet<A>) => STM<void>;
<A>(self: TSet<A>, other: TSet<A>): STM<void>;
}

Other

TSet

Added in v2.0.0 Source

Symbols

TSetTypeId

Added in v2.0.0 Source

Signature

declare const TSetTypeId: unique symbol

TSetTypeId type

Added in v2.0.0 Source

Signature

type TSetTypeId = typeof TSetTypeId