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

TSet overview

Added in v1.0.0


Table of contents


constructors

empty

Makes an empty TSet.

Signature

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

Added in v1.0.0

fromIterable

Makes a new TSet initialized with provided iterable.

Signature

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

Added in v1.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<never, never, TSet<Elements[number]>>

Added in v1.0.0

destructors

toChunk

Collects all elements into a Chunk.

Signature

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

Added in v1.0.0

toHashSet

Collects all elements into a HashSet.

Signature

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

Added in v1.0.0

toReadonlyArray

Collects all elements into a ReadonlyArray.

Signature

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

Added in v1.0.0

toReadonlySet

Collects all elements into a ReadonlySet.

Signature

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

Added in v1.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<R, E, void>): (self: TSet<A>) => STM.STM<R, E, void>
  <A, R, E>(self: TSet<A>, f: (value: A) => STM.STM<R, E, void>): STM.STM<R, E, void>
}

Added in v1.0.0

has

Tests whether or not set contains an element.

Signature

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

Added in v1.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<never, never, Z>
  <Z, A>(self: TSet<A>, zero: Z, f: (accumulator: Z, value: A) => Z): STM.STM<never, never, Z>
}

Added in v1.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<R, E, Z>): (self: TSet<A>) => STM.STM<R, E, Z>
  <Z, A, R, E>(self: TSet<A>, zero: Z, f: (accumulator: Z, value: A) => STM.STM<R, E, Z>): STM.STM<R, E, Z>
}

Added in v1.0.0

getters

isEmpty

Tests if the set is empty or not

Signature

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

Added in v1.0.0

size

Returns the set’s cardinality.

Signature

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

Added in v1.0.0

models

TSet (interface)

Transactional set implemented on top of TMap.

Signature

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

Added in v1.0.0

mutations

add

Stores new element in the set.

Signature

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

Added in v1.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<never, never, void>
  <A>(self: TSet<A>, other: TSet<A>): STM.STM<never, never, void>
}

Added in v1.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<never, never, void>
  <A>(self: TSet<A>, other: TSet<A>): STM.STM<never, never, void>
}

Added in v1.0.0

remove

Removes a single element from the set.

Signature

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

Added in v1.0.0

removeAll

Removes elements from the set.

Signature

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

Added in v1.0.0

removeIf

Removes bindings matching predicate and returns the removed entries.

Signature

export declare const removeIf: {
  <A>(predicate: Predicate<A>): (self: TSet<A>) => STM.STM<never, never, A[]>
  <A>(self: TSet<A>, predicate: Predicate<A>): STM.STM<never, never, A[]>
}

Added in v1.0.0

removeIfDiscard

Removes elements matching predicate.

Signature

export declare const removeIfDiscard: {
  <A>(predicate: Predicate<A>): (self: TSet<A>) => STM.STM<never, never, void>
  <A>(self: TSet<A>, predicate: Predicate<A>): STM.STM<never, never, void>
}

Added in v1.0.0

retainIf

Retains bindings matching predicate and returns removed bindings.

Signature

export declare const retainIf: {
  <A>(predicate: Predicate<A>): (self: TSet<A>) => STM.STM<never, never, A[]>
  <A>(self: TSet<A>, predicate: Predicate<A>): STM.STM<never, never, A[]>
}

Added in v1.0.0

retainIfDiscard

Retains elements matching predicate.

Signature

export declare const retainIfDiscard: {
  <A>(predicate: Predicate<A>): (self: TSet<A>) => STM.STM<never, never, void>
  <A>(self: TSet<A>, predicate: Predicate<A>): STM.STM<never, never, void>
}

Added in v1.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<never, never, B>
  <A, B>(self: TSet<A>, pf: (a: A) => Option.Option<B>): STM.STM<never, never, B>
}

Added in v1.0.0

takeFirstSTM

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

Signature

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

Added in v1.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<never, never, [B, ...B[]]>
  <A, B>(self: TSet<A>, pf: (a: A) => Option.Option<B>): STM.STM<never, never, [B, ...B[]]>
}

Added in v1.0.0

takeSomeSTM

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

Signature

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

Added in v1.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<never, never, void>
  <A>(self: TSet<A>, f: (a: A) => A): STM.STM<never, never, void>
}

Added in v1.0.0

transformSTM

Atomically updates all elements using a transactional function.

Signature

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

Added in v1.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<never, never, void>
  <A>(self: TSet<A>, other: TSet<A>): STM.STM<never, never, void>
}

Added in v1.0.0

symbols

TSetTypeId

Signature

export declare const TSetTypeId: typeof TSetTypeId

Added in v1.0.0

TSetTypeId (type alias)

Signature

export type TSetTypeId = typeof TSetTypeId

Added in v1.0.0

utils

TSet (namespace)

Added in v1.0.0

Variance (interface)

Signature

export interface Variance<A> {
  readonly [TSetTypeId]: {
    readonly _A: (_: never) => A
  }
}

Added in v1.0.0