<V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (
self: HashSet<V>
) => HashSet<U>
<V>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>
<V, U extends V>(
self: HashSet<V>,
refinement: Refinement<V, U>
): HashSet<U>
<V>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>Filters the HashSet keeping only values that satisfy the predicate.
Example (Filtering HashSet values)
import { HashSet } from "effect"
const numbers = HashSet.make(1, 2, 3, 4, 5, 6)
const evens = HashSet.filter(numbers, (n) => n % 2 === 0)
console.log(Array.from(evens).sort()) // [2, 4, 6]
console.log(HashSet.size(evens)) // 3export const const filter: {
<V, U extends V>(
refinement: Refinement<NoInfer<V>, U>
): (self: HashSet<V>) => HashSet<U>
<V>(predicate: Predicate<NoInfer<V>>): (
self: HashSet<V>
) => HashSet<V>
<V, U extends V>(
self: HashSet<V>,
refinement: Refinement<V, U>
): HashSet<U>
<V>(
self: HashSet<V>,
predicate: Predicate<V>
): HashSet<V>
}
Filters the HashSet keeping only values that satisfy the predicate.
Example (Filtering HashSet values)
import { HashSet } from "effect"
const numbers = HashSet.make(1, 2, 3, 4, 5, 6)
const evens = HashSet.filter(numbers, (n) => n % 2 === 0)
console.log(Array.from(evens).sort()) // [2, 4, 6]
console.log(HashSet.size(evens)) // 3
filter: {
<function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>V, function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>U extends function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>V>(refinement: Refinement<NoInfer<V>, U>refinement: interface Refinement<in A, out B extends A>A predicate that also narrows the input type when it returns true.
When to use
Use when you want a runtime check that refines A to B for TypeScript,
especially when composing type guards with
compose
or safely
checking unknown values.
Details
A refinement returns a type predicate (a is B). Use it with if or
filter to narrow types.
Example (Narrowing unknown values)
import { Predicate } from "effect"
const isString: Predicate.Refinement<unknown, string> = (u): u is string => typeof u === "string"
const data: unknown = "hello"
if (isString(data)) {
console.log(data.toUpperCase())
}
Type-level utilities for working with
Refinement
types.
When to use
Use when you need to extract input and output types from refinement
signatures while writing generic helpers over refinements.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting refinement types)
import { Predicate } from "effect"
type IsString = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<IsString>
type Output = Predicate.Refinement.Out<IsString>
Refinement<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>V>, function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>U>): (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 extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>V>) => 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) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>U>
<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>V>(predicate: Predicate<NoInfer<V>>predicate: interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>V>>): (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>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>V>) => 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>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>V>
<function (type parameter) V in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>V, function (type parameter) U in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>U extends function (type parameter) V in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>V>(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 extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>V>, refinement: Refinement<V, U>refinement: interface Refinement<in A, out B extends A>A predicate that also narrows the input type when it returns true.
When to use
Use when you want a runtime check that refines A to B for TypeScript,
especially when composing type guards with
compose
or safely
checking unknown values.
Details
A refinement returns a type predicate (a is B). Use it with if or
filter to narrow types.
Example (Narrowing unknown values)
import { Predicate } from "effect"
const isString: Predicate.Refinement<unknown, string> = (u): u is string => typeof u === "string"
const data: unknown = "hello"
if (isString(data)) {
console.log(data.toUpperCase())
}
Type-level utilities for working with
Refinement
types.
When to use
Use when you need to extract input and output types from refinement
signatures while writing generic helpers over refinements.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting refinement types)
import { Predicate } from "effect"
type IsString = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<IsString>
type Output = Predicate.Refinement.Out<IsString>
Refinement<function (type parameter) V in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>V, function (type parameter) U in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>U>): 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) U in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>U>
<function (type parameter) V in <V>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>V>(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>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>V>, predicate: Predicate<V>predicate: interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<function (type parameter) V in <V>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>V>): 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>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>V>
} = import DualDual.dual<
{
<function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>V, function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>U extends function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>V>(refinement: Refinement<NoInfer<V>, U>refinement: interface Refinement<in A, out B extends A>A predicate that also narrows the input type when it returns true.
When to use
Use when you want a runtime check that refines A to B for TypeScript,
especially when composing type guards with
compose
or safely
checking unknown values.
Details
A refinement returns a type predicate (a is B). Use it with if or
filter to narrow types.
Example (Narrowing unknown values)
import { Predicate } from "effect"
const isString: Predicate.Refinement<unknown, string> = (u): u is string => typeof u === "string"
const data: unknown = "hello"
if (isString(data)) {
console.log(data.toUpperCase())
}
Type-level utilities for working with
Refinement
types.
When to use
Use when you need to extract input and output types from refinement
signatures while writing generic helpers over refinements.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting refinement types)
import { Predicate } from "effect"
type IsString = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<IsString>
type Output = Predicate.Refinement.Out<IsString>
Refinement<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>V>, function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>U>): (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 extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>V>) => 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) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>U>
<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>V>(predicate: Predicate<NoInfer<V>>predicate: interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>V>>): (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>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>V>) => 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>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>V>
},
{
<function (type parameter) V in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>V, function (type parameter) U in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>U extends function (type parameter) V in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>V>(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 extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>V>, refinement: Refinement<V, U>refinement: interface Refinement<in A, out B extends A>A predicate that also narrows the input type when it returns true.
When to use
Use when you want a runtime check that refines A to B for TypeScript,
especially when composing type guards with
compose
or safely
checking unknown values.
Details
A refinement returns a type predicate (a is B). Use it with if or
filter to narrow types.
Example (Narrowing unknown values)
import { Predicate } from "effect"
const isString: Predicate.Refinement<unknown, string> = (u): u is string => typeof u === "string"
const data: unknown = "hello"
if (isString(data)) {
console.log(data.toUpperCase())
}
Type-level utilities for working with
Refinement
types.
When to use
Use when you need to extract input and output types from refinement
signatures while writing generic helpers over refinements.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting refinement types)
import { Predicate } from "effect"
type IsString = Predicate.Refinement<unknown, string>
type Input = Predicate.Refinement.In<IsString>
type Output = Predicate.Refinement.Out<IsString>
Refinement<function (type parameter) V in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>V, function (type parameter) U in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>U>): 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) U in <V, U extends V>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>U>
<function (type parameter) V in <V>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>V>(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>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>V>, predicate: Predicate<V>predicate: interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<function (type parameter) V in <V>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>V>): 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>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>V>
}
>(2, import internalinternal.const filter: <V>(
self: internal.HashSet<V>,
predicate: (value: V) => boolean
) => internal.HashSet<V>
filter)