<V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (
self: TxHashSet<V>
) => Effect.Effect<TxHashSet<U>>
<V>(predicate: Predicate<NoInfer<V>>): (
self: TxHashSet<V>
) => Effect.Effect<TxHashSet<V>>
<V, U extends V>(
self: TxHashSet<V>,
refinement: Refinement<V, U>
): Effect.Effect<TxHashSet<U>>
<V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<
TxHashSet<V>
>Filters the TxHashSet keeping only values that satisfy the predicate, returning a new TxHashSet.
Example (Filtering values)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
const numbers = yield* TxHashSet.make(1, 2, 3, 4, 5, 6)
const evens = yield* TxHashSet.filter(numbers, (n) => n % 2 === 0)
const values = yield* TxHashSet.toHashSet(evens)
console.log(Array.from(values).sort()) // [2, 4, 6]
console.log(yield* TxHashSet.size(evens)) // 3
})export const const filter: {
<V, U extends V>(
refinement: Refinement<NoInfer<V>, U>
): (
self: TxHashSet<V>
) => Effect.Effect<TxHashSet<U>>
<V>(predicate: Predicate<NoInfer<V>>): (
self: TxHashSet<V>
) => Effect.Effect<TxHashSet<V>>
<V, U extends V>(
self: TxHashSet<V>,
refinement: Refinement<V, U>
): Effect.Effect<TxHashSet<U>>
<V>(
self: TxHashSet<V>,
predicate: Predicate<V>
): Effect.Effect<TxHashSet<V>>
}
Filters the TxHashSet keeping only values that satisfy the predicate, returning a new TxHashSet.
Example (Filtering values)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
const numbers = yield* TxHashSet.make(1, 2, 3, 4, 5, 6)
const evens = yield* TxHashSet.filter(numbers, (n) => n % 2 === 0)
const values = yield* TxHashSet.toHashSet(evens)
console.log(Array.from(values).sort()) // [2, 4, 6]
console.log(yield* TxHashSet.size(evens)) // 3
})
filter: {
<function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>V, function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>U extends function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>V>(
refinement: Refinement<NoInfer<V>, U>refinement: import RefinementRefinement<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: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>V>, function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>U>
): (self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>V>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>U>>
<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<V>>V>(
predicate: Predicate<NoInfer<V>>predicate: import PredicatePredicate<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: TxHashSet<V>) => Effect.Effect<TxHashSet<V>>V>>
): (self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<V>>V>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<V>>V>>
<function (type parameter) V in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>V, function (type parameter) U in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>U extends function (type parameter) V in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>V>(
self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>V>,
refinement: Refinement<V, U>refinement: import RefinementRefinement<function (type parameter) V in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>V, function (type parameter) U in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>U>
): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) U in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>U>>
<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<TxHashSet<V>>V>(self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<TxHashSet<V>>V>, predicate: Predicate<V>predicate: import PredicatePredicate<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<TxHashSet<V>>V>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<TxHashSet<V>>V>>
} = import dualdual<
{
<function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>V, function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>U extends function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>V>(
refinement: Refinement<NoInfer<V>, U>refinement: import RefinementRefinement<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: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>V>, function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>U>
): (self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>V>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) U in <V, U extends V>(refinement: Refinement<NoInfer<V>, U>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<U>>U>>
<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<V>>V>(
predicate: Predicate<NoInfer<V>>predicate: import PredicatePredicate<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: TxHashSet<V>) => Effect.Effect<TxHashSet<V>>V>>
): (self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<V>>V>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(predicate: Predicate<NoInfer<V>>): (self: TxHashSet<V>) => Effect.Effect<TxHashSet<V>>V>>
},
{
<function (type parameter) V in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>V, function (type parameter) U in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>U extends function (type parameter) V in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>V>(
self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>V>,
refinement: Refinement<V, U>refinement: import RefinementRefinement<function (type parameter) V in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>V, function (type parameter) U in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>U>
): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) U in <V, U extends V>(self: TxHashSet<V>, refinement: Refinement<V, U>): Effect.Effect<TxHashSet<U>>U>>
<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<TxHashSet<V>>V>(self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<TxHashSet<V>>V>, predicate: Predicate<V>predicate: import PredicatePredicate<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<TxHashSet<V>>V>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): Effect.Effect<TxHashSet<V>>V>>
}
>(2, <function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): anyV>(self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self: interface TxHashSet<in out V>A TxHashSet is a transactional hash set data structure that provides atomic operations on unique values within Effect transactions. It uses an immutable HashSet internally with TxRef for transactional semantics, ensuring all operations are performed atomically.
Details
Mutation operations such as add, remove, and clear update the original TxHashSet and return Effect<void> or Effect<boolean>. Transform operations such as union, intersection, difference, map, and filter create new TxHashSet instances and leave the original TxHashSet unchanged.
Example (Using transactional hash sets)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional hash set
const txSet = yield* TxHashSet.make("apple", "banana", "cherry")
// Single operations are automatically transactional
yield* TxHashSet.add(txSet, "grape")
const hasApple = yield* TxHashSet.has(txSet, "apple")
console.log(hasApple) // true
// Multi-step atomic operations
yield* Effect.tx(
Effect.gen(function*() {
const hasCherry = yield* TxHashSet.has(txSet, "cherry")
if (hasCherry) {
yield* TxHashSet.remove(txSet, "cherry")
yield* TxHashSet.add(txSet, "orange")
}
})
)
const size = yield* TxHashSet.size(txSet)
console.log(size) // 4
})
The TxHashSet namespace contains type-level utilities and helper types
for working with TxHashSet instances.
Example (Extracting value types inside transactions)
import { Effect, TxHashSet } from "effect"
const program = Effect.gen(function*() {
// Create a transactional color set
const colors = yield* TxHashSet.make("red", "green", "blue")
// Extract the value type for reuse
type Color = TxHashSet.TxHashSet.Value<typeof colors> // string
// Use extracted type in functions
const addColor = (color: Color) => TxHashSet.add(colors, color)
yield* addColor("yellow")
})
TxHashSet<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): anyV>, predicate: Predicate<V>predicate: import PredicatePredicate<function (type parameter) V in <V>(self: TxHashSet<V>, predicate: Predicate<V>): anyV>) =>
import EffectEffect.gen(function*() {
const const currentSet: HashSet.HashSet<V>const currentSet: {
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;
}
currentSet = yield* import TxRefTxRef.const get: <A>(
self: TxRef<A>
) => Effect.Effect<A>
Reads the current value of the TxRef.
When to use
Use to read the current value of a TxRef.
Example (Reading transactional references)
import { Effect, TxRef } from "effect"
const program = Effect.gen(function*() {
const counter = yield* TxRef.make(42)
// Read the value within a transaction
const value = yield* Effect.tx(
TxRef.get(counter)
)
console.log(value) // 42
})
get(self: TxHashSet<V>(parameter) self: {
ref: TxRef.TxRef<HashSet.HashSet<V>>;
toString: () => string;
toJSON: () => unknown;
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; <…;
}
self.TxHashSet<in out V>.ref: TxRef.TxRef<HashSet.HashSet<V>>(property) TxHashSet<in out V>.ref: {
version: number;
pending: Map<unknown, () => void>;
value: A;
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; <…;
}
ref)
const const filteredSet: HashSet.HashSet<V>const filteredSet: {
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;
}
filteredSet = import HashSetHashSet.filter(const currentSet: HashSet.HashSet<V>const currentSet: {
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;
}
currentSet, predicate: Predicate<V>predicate)
return yield* const fromHashSet: <V>(
hashSet: HashSet.HashSet<V>
) => Effect.Effect<TxHashSet<V>>
Creates a TxHashSet from an existing HashSet.
Example (Creating a transactional hash set from a HashSet)
import { Effect, HashSet, TxHashSet } from "effect"
const program = Effect.gen(function*() {
const hashSet = HashSet.make("x", "y", "z")
const txSet = yield* TxHashSet.fromHashSet(hashSet)
console.log(yield* TxHashSet.size(txSet)) // 3
console.log(yield* TxHashSet.has(txSet, "y")) // true
// Original hashSet is unchanged when txSet is modified
yield* TxHashSet.add(txSet, "w")
console.log(HashSet.size(hashSet)) // 3 (original unchanged)
console.log(yield* TxHashSet.size(txSet)) // 4
})
fromHashSet(const filteredSet: HashSet.HashSet<V>const filteredSet: {
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;
}
filteredSet)
}).pipe(import EffectEffect.tx))