The
union function returns the list union of the two lists. It
is a special case of
unionBy, which allows the programmer to
supply their own equality test.
Examples
>>> "dog" `union` "cow"
"dogcw"
If equal elements are present in both lists, an element from the first
list will be used. If the second list contains equal elements, only
the first one will be retained:
>>> import Data.Semigroup(Arg(..))
>>> union [Arg () "dog"] [Arg () "cow"]
[Arg () "dog"]
>>> union [] [Arg () "dog", Arg () "cow"]
[Arg () "dog"]
However if the first list contains duplicates, so will the result:
>>> "coot" `union` "duck"
"cootduk"
>>> "duck" `union` "coot"
"duckot"
union is productive even if both arguments are infinite.
>>> [0, 2 ..] `union` [1, 3 ..]
[0,2,4,6,8,10,12..