Generalized JavaScript set operations and comparisons in the style of Haskell