Set module: persistent hash-array-mapped-trie set.
Set(a) is an immutable, hash-indexed collection backed by a HAMT via the Map module (Set(a) ≅ Map(a, Unit) internally). This gives O(log₃₂ n) ≈ O(1) amortized membership tests, insert, and delete.
Operations that need key identity take an explicit comparator: cmp : a -> a -> Bool where cmp(a)(b) = true means a < b
Standard comparators: fn(a) -> fn(b) -> a < b for Int elements fn(a) -> fn(b) -> a < b for String elements (lexicographic)
Iteration order is hash-traversal order (not sorted). Use to_list then sort externally if sorted order is needed.
Left fold over all elements. Argument order: collection first, init second, callback last (uncurried-collection convention). The callback f is called uncurried as f(acc, elem) = new_acc.