VarSet/NameSet/UniqSet/... are not great for use cases where we only add elements and check for membership.
VarSet
is implemented as (eventually after indirections) as IntMap Var
.
We use the unique as key, and keep around the actual Var as element in the underlying map.
However there are cases where we are not interested in the actual value, so we could just use a set of Uniques (e.g. IntSet) which is a much more performant representation of such sets.
One example in GHC where this happens is in compiler/GHC/Tc/TyCl/Utils.hs
for SynCycleState
but I assume there are others.