This seems weird:
union [0, 0] [1, 1] == [0, 0, 1]
I would have expected the result to be [0, 1], but at least it should be symmetrical in both arguments. I would consider several possible fixes:
- Remove all duplicates (i.e.
union a b == nub (a <> b))
- Keep the duplicates within both of the arguments (i.e.
union [0, 0] [1, 1] == [0, 0, 1, 1]).
- Remove
union and unionBy from Data.Array (given that Set is the better data structure for something like this)
- Document the behavior if it is intended
I would vote for 1 or 3.