Skip to main content Link Search Menu Expand Document (external link)

TSet overview

Added in v2.0.0


Table of contents


constructors

empty

Makes an empty TSet.

Signature

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

Added in v2.0.0

fromIterable

Creates a new TSet from an iterable collection of values.

Signature

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

Added in v2.0.0

make

Makes a new TSet that is initialized with specified values.

Signature

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

Added in v2.0.0

destructors

toArray

Collects all elements into a Array.

Signature

export declare const toArray: <A>(self: TSet<A>) => STM.STM<A[], never, never>

Added in v2.0.0

toChunk

Collects all elements into a Chunk.

Signature

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

Added in v2.0.0

toHashSet

Collects all elements into a HashSet.

Signature

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

Added in v2.0.0

toReadonlySet

Collects all elements into a ReadonlySet.

Signature

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

Added in v2.0.0

elements

forEach

Atomically performs transactional-effect for each element in set.

Signature

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

Added in v2.0.0

has

Tests whether or not set contains an element.

Signature

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

Added in v2.0.0

folding

reduce

Atomically folds using a pure function.

Signature

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

Added in v2.0.0

reduceSTM

Atomically folds using a transactional function.

Signature

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

Added in v2.0.0

getters

isEmpty

Tests if the set is empty or not

Signature

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

Added in v2.0.0

size

Returns the set’s cardinality.

Signature

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

Added in v2.0.0

models

TSet (interface)

Transactional set implemented on top of TMap.

Signature

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

Added in v2.0.0

mutations

add

Stores new element in the set.

Signature

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

Added in v2.0.0

difference

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

Signature

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

Added in v2.0.0

intersection

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

Signature

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

Added in v2.0.0

remove

Removes a single element from the set.

Signature

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

Added in v2.0.0

removeAll

Removes elements from the set.

Signature

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

Added in v2.0.0

removeIf

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

Signature

export declare const removeIf: {
  <A>(predicate: Predicate<A>, options: { readonly discard: true }): (self: TSet<A>) => STM.STM<void>
  <A>(predicate: Predicate<A>, options?: { readonly discard: false }): (self: TSet<A>) => STM.STM<A[], never, never>
  <A>(self: TSet<A>, predicate: Predicate<A>, options: { readonly discard: true }): STM.STM<void>
  <A>(self: TSet<A>, predicate: Predicate<A>, options?: { readonly discard: false }): STM.STM<A[], never, never>
}

Added in v2.0.0

retainIf

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

Signature

export declare const retainIf: {
  <A>(predicate: Predicate<A>, options: { readonly discard: true }): (self: TSet<A>) => STM.STM<void>
  <A>(predicate: Predicate<A>, options?: { readonly discard: false }): (self: TSet<A>) => STM.STM<A[], never, never>
  <A>(self: TSet<A>, predicate: Predicate<A>, options: { readonly discard: true }): STM.STM<void>
  <A>(self: TSet<A>, predicate: Predicate<A>, options?: { readonly discard: false }): STM.STM<A[], never, never>
}

Added in v2.0.0

takeFirst

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

Signature

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

Added in v2.0.0

takeFirstSTM

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

Signature

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

Added in v2.0.0

takeSome

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

Signature

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

Added in v2.0.0

takeSomeSTM

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

Signature

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

Added in v2.0.0

transform

Atomically updates all elements using a pure function.

Signature

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

Added in v2.0.0

transformSTM

Atomically updates all elements using a transactional function.

Signature

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

Added in v2.0.0

union

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

Signature

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

Added in v2.0.0

symbols

TSetTypeId

Signature

export declare const TSetTypeId: typeof TSetTypeId

Added in v2.0.0

TSetTypeId (type alias)

Signature

export type TSetTypeId = typeof TSetTypeId

Added in v2.0.0

utils

TSet (namespace)

Added in v2.0.0

Variance (interface)

Signature

export interface Variance<in out A> {
  readonly [TSetTypeId]: {
    readonly _A: Types.Invariant<A>
  }
}

Added in v2.0.0