<V, U>(zero: U, f: (accumulator: U, value: V) => U): (
self: HashSet<V>
) => U
<V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UReduces the HashSet to a single value by iterating through the values and applying an accumulator function.
Example (Reducing HashSet values)
import { HashSet } from "effect"
const numbers = HashSet.make(1, 2, 3, 4, 5)
const sum = HashSet.reduce(numbers, 0, (acc, n) => acc + n)
console.log(sum) // 15
const strings = HashSet.make("a", "b", "c")
const concatenated = HashSet.reduce(strings, "", (acc, s) => acc + s)
console.log(concatenated) // Order may vary: "abc", "bac", etc.export const const reduce: {
<V, U>(
zero: U,
f: (accumulator: U, value: V) => U
): (self: HashSet<V>) => U
<V, U>(
self: HashSet<V>,
zero: U,
f: (accumulator: U, value: V) => U
): U
}
Reduces the HashSet to a single value by iterating through the values and applying an accumulator function.
Example (Reducing HashSet values)
import { HashSet } from "effect"
const numbers = HashSet.make(1, 2, 3, 4, 5)
const sum = HashSet.reduce(numbers, 0, (acc, n) => acc + n)
console.log(sum) // 15
const strings = HashSet.make("a", "b", "c")
const concatenated = HashSet.reduce(strings, "", (acc, s) => acc + s)
console.log(concatenated) // Order may vary: "abc", "bac", etc.
reduce: {
<function (type parameter) V in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UV, function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU>(zero: Uzero: function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU, f: (accumulator: U, value: V) => Uf: (accumulator: Uaccumulator: function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU, value: Vvalue: function (type parameter) V in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UV) => function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU): (self: HashSet<V>(parameter) self: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface HashSet<out Value>A HashSet is an immutable set data structure that provides efficient storage
and retrieval of unique values. It uses a HashMap internally for optimal performance.
Example (Creating and updating a HashSet)
import { HashSet } from "effect"
// Create a HashSet
const set = HashSet.make("apple", "banana", "cherry")
// Check membership
console.log(HashSet.has(set, "apple")) // true
console.log(HashSet.has(set, "grape")) // false
// Add values (returns new HashSet)
const updated = HashSet.add(set, "grape")
console.log(HashSet.size(updated)) // 4
// Remove values (returns new HashSet)
const smaller = HashSet.remove(set, "banana")
console.log(HashSet.size(smaller)) // 2
The HashSet namespace contains type-level utilities and helper types
for working with HashSet instances.
Example (Extracting value types from a HashSet)
import { HashSet } from "effect"
// Create a concrete HashSet for type extraction
const fruits = HashSet.make("apple", "banana", "cherry")
// Extract the value type for reuse
type Fruit = HashSet.HashSet.Value<typeof fruits> // string
// Use extracted type in functions
const processFruit = (fruit: Fruit) => {
return `Processing ${fruit}`
}
HashSet<function (type parameter) V in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UV>) => function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU
<function (type parameter) V in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UV, function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU>(self: HashSet<V>(parameter) self: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface HashSet<out Value>A HashSet is an immutable set data structure that provides efficient storage
and retrieval of unique values. It uses a HashMap internally for optimal performance.
Example (Creating and updating a HashSet)
import { HashSet } from "effect"
// Create a HashSet
const set = HashSet.make("apple", "banana", "cherry")
// Check membership
console.log(HashSet.has(set, "apple")) // true
console.log(HashSet.has(set, "grape")) // false
// Add values (returns new HashSet)
const updated = HashSet.add(set, "grape")
console.log(HashSet.size(updated)) // 4
// Remove values (returns new HashSet)
const smaller = HashSet.remove(set, "banana")
console.log(HashSet.size(smaller)) // 2
The HashSet namespace contains type-level utilities and helper types
for working with HashSet instances.
Example (Extracting value types from a HashSet)
import { HashSet } from "effect"
// Create a concrete HashSet for type extraction
const fruits = HashSet.make("apple", "banana", "cherry")
// Extract the value type for reuse
type Fruit = HashSet.HashSet.Value<typeof fruits> // string
// Use extracted type in functions
const processFruit = (fruit: Fruit) => {
return `Processing ${fruit}`
}
HashSet<function (type parameter) V in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UV>, zero: Uzero: function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU, f: (accumulator: U, value: V) => Uf: (accumulator: Uaccumulator: function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU, value: Vvalue: function (type parameter) V in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UV) => function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU): function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU
} = import DualDual.dual<
<function (type parameter) V in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UV, function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU>(zero: Uzero: function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU, f: (accumulator: U, value: V) => Uf: (accumulator: Uaccumulator: function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU, value: Vvalue: function (type parameter) V in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UV) => function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU) => (self: HashSet<V>(parameter) self: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface HashSet<out Value>A HashSet is an immutable set data structure that provides efficient storage
and retrieval of unique values. It uses a HashMap internally for optimal performance.
Example (Creating and updating a HashSet)
import { HashSet } from "effect"
// Create a HashSet
const set = HashSet.make("apple", "banana", "cherry")
// Check membership
console.log(HashSet.has(set, "apple")) // true
console.log(HashSet.has(set, "grape")) // false
// Add values (returns new HashSet)
const updated = HashSet.add(set, "grape")
console.log(HashSet.size(updated)) // 4
// Remove values (returns new HashSet)
const smaller = HashSet.remove(set, "banana")
console.log(HashSet.size(smaller)) // 2
The HashSet namespace contains type-level utilities and helper types
for working with HashSet instances.
Example (Extracting value types from a HashSet)
import { HashSet } from "effect"
// Create a concrete HashSet for type extraction
const fruits = HashSet.make("apple", "banana", "cherry")
// Extract the value type for reuse
type Fruit = HashSet.HashSet.Value<typeof fruits> // string
// Use extracted type in functions
const processFruit = (fruit: Fruit) => {
return `Processing ${fruit}`
}
HashSet<function (type parameter) V in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UV>) => function (type parameter) U in <V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => UU,
<function (type parameter) V in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UV, function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU>(self: HashSet<V>(parameter) self: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface HashSet<out Value>A HashSet is an immutable set data structure that provides efficient storage
and retrieval of unique values. It uses a HashMap internally for optimal performance.
Example (Creating and updating a HashSet)
import { HashSet } from "effect"
// Create a HashSet
const set = HashSet.make("apple", "banana", "cherry")
// Check membership
console.log(HashSet.has(set, "apple")) // true
console.log(HashSet.has(set, "grape")) // false
// Add values (returns new HashSet)
const updated = HashSet.add(set, "grape")
console.log(HashSet.size(updated)) // 4
// Remove values (returns new HashSet)
const smaller = HashSet.remove(set, "banana")
console.log(HashSet.size(smaller)) // 2
The HashSet namespace contains type-level utilities and helper types
for working with HashSet instances.
Example (Extracting value types from a HashSet)
import { HashSet } from "effect"
// Create a concrete HashSet for type extraction
const fruits = HashSet.make("apple", "banana", "cherry")
// Extract the value type for reuse
type Fruit = HashSet.HashSet.Value<typeof fruits> // string
// Use extracted type in functions
const processFruit = (fruit: Fruit) => {
return `Processing ${fruit}`
}
HashSet<function (type parameter) V in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UV>, zero: Uzero: function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU, f: (accumulator: U, value: V) => Uf: (accumulator: Uaccumulator: function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU, value: Vvalue: function (type parameter) V in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UV) => function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU) => function (type parameter) U in <V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): UU
>(3, import internalinternal.const reduce: <V, U>(
self: internal.HashSet<V>,
zero: U,
f: (accumulator: U, value: V) => U
) => U
reduce)