Hyperlinkv0.8.0-beta.28

HashSet

HashSet.addconsteffect/HashSet.ts:223
<V>(value: V): (self: HashSet<V>) => HashSet<V>
<V>(self: HashSet<V>, value: V): HashSet<V>

Adds a value to the HashSet, returning a new HashSet.

Example (Adding values to a HashSet)

import { HashSet } from "effect"

const set = HashSet.make("a", "b")
const withC = HashSet.add(set, "c")

console.log(HashSet.size(set)) // 2 (original unchanged)
console.log(HashSet.size(withC)) // 3
console.log(HashSet.has(withC, "c")) // true

// Adding existing value has no effect
const same = HashSet.add(set, "a")
console.log(HashSet.size(same)) // 2
mutations
Source effect/HashSet.ts:2237 lines
export const add: {
  <V>(value: V): (self: HashSet<V>) => HashSet<V>
  <V>(self: HashSet<V>, value: V): HashSet<V>
} = Dual.dual<
  <V>(value: V) => (self: HashSet<V>) => HashSet<V>,
  <V>(self: HashSet<V>, value: V) => HashSet<V>
>(2, internal.add)
Referenced by 1 symbols