Merge two sets.
merge takes two SimpleWhenMissing tactics, a SimpleWhenMatched tactic,
and two sets. It uses the tactics to merge the sets.
Consider
merge (filterMissing g1) (filterMissing g2) (filterMatched f) s1 s2
g1 = (==2)
g2 = (==3)
f = (==6)
s1 = [2, 4, 6, 8, 10, 12]
s2 = [3, 6, 9, 12]
merge will pass the elements to g1, g2, or f as appropriate,
producing a Bool for each element.
m1: [ 2, 4, 6, 8, 10 12]
m2: [ 3, 6, 9, 12]
result: [g1 2, g2 3, g1 4, f 6, g1 8, g2 9, g1 10, f 12]
= [True, True, False, True, False, False, False, False]
The result set contains the element for which we have True.
>>> merge (filterMissing g1) (filterMissing g2) (filterMatched f) s1 s2
fromList [2,3,6]
The other tactics below are optimizations or simplifications of
filterMissing for special cases. Most importantly,
When merge is given three arguments, it is inlined at the call
site. To prevent excessive inlining, you should typically use merge
to define your custom combining functions.
What to do with elements in s1 but not s2
What to do with elements in s2 but not s1
What to do with elements in both s1 and s2
Set s1
Set s2