/**
* Atomically transforms the set into the intersection of itself and the
* provided set.
*
* @tsplus static effect/core/stm/TSet.Aspects intersect
* @tsplus pipeable effect/core/stm/TSet intersect
*/
export function intersect(other: TSet) {
return (self: TSet): STM =>
other.toHashSet.flatMap(vals => self.retainIfDiscard((_) => vals.has(_)))
}