<V>(u: Iterable<V>): u is HashSet<V>
(u: unknown): u is HashSet<unknown>Checks whether a value is a HashSet.
Example (Checking for a HashSet)
import { HashSet } from "effect"
const set = HashSet.make(1, 2, 3)
const array = [1, 2, 3]
console.log(HashSet.isHashSet(set)) // true
console.log(HashSet.isHashSet(array)) // false
console.log(HashSet.isHashSet(null)) // falseexport const const isHashSet: {
<V>(u: Iterable<V>): u is HashSet<V>
(u: unknown): u is HashSet<unknown>
}
Checks whether a value is a HashSet.
Example (Checking for a HashSet)
import { HashSet } from "effect"
const set = HashSet.make(1, 2, 3)
const array = [1, 2, 3]
console.log(HashSet.isHashSet(set)) // true
console.log(HashSet.isHashSet(array)) // false
console.log(HashSet.isHashSet(null)) // false
isHashSet: {
<function (type parameter) V in <V>(u: Iterable<V>): u is HashSet<V>V>(u: Iterable<V>u: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) V in <V>(u: Iterable<V>): u is HashSet<V>V>): u: Iterable<V>u is 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: Iterable<V>): u is HashSet<V>V>
(u: unknownu: unknown): u: unknownu is 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<unknown>
} = import internalinternal.const isHashSet: (
u: unknown
) => u is internal.HashSet<unknown>
isHashSet