Hyperlinkv0.8.0-beta.28

TxHashSet

TxHashSet.toHashSetconsteffect/TxHashSet.ts:908
<V>(self: TxHashSet<V>): Effect.Effect<HashSet.HashSet<V>>

Converts the TxHashSet to an immutable HashSet snapshot.

Example (Taking a HashSet snapshot)

import { Effect, HashSet, TxHashSet } from "effect"

const program = Effect.gen(function*() {
  const txSet = yield* TxHashSet.make("x", "y", "z")
  const hashSet = yield* TxHashSet.toHashSet(txSet)

  console.log(HashSet.size(hashSet)) // 3
  console.log(HashSet.has(hashSet, "y")) // true

  // hashSet is a snapshot - modifications to txSet don't affect it
  yield* TxHashSet.add(txSet, "w")
  console.log(HashSet.size(hashSet)) // 3 (unchanged)
  console.log(yield* TxHashSet.size(txSet)) // 4
})
converting
export const toHashSet = <V>(self: TxHashSet<V>): Effect.Effect<HashSet.HashSet<V>> => TxRef.get(self.ref)