intersect package:rio

The intersect function takes the list intersection of two lists. For example,
>>> [1,2,3,4] `intersect` [2,4,6,8]
[2,4]
If the first list contains duplicates, so will the result.
>>> [1,2,2,3,4] `intersect` [6,4,4,2]
[2,2,4]
It is a special case of intersectBy, which allows the programmer to supply their own equality test. If the element is found in both the first and the second list, the element from the first list will be used.
Intersection of two maps. Return elements of the first map for keys existing in the second.
Intersection of two maps. If a key occurs in both maps the provided function is used to combine the values from the two maps.
Intersection of two maps. If a key occurs in both maps the provided function is used to combine the values from the two maps.
Intersection of two sets. Return elements present in both the first set and the second.
>>> HashSet.intersection (HashSet.fromList [1,2,3]) (HashSet.fromList [2,3,4])
fromList [2,3]
The intersectBy function is the non-overloaded version of intersect.
O(m*log(n/m + 1)), m <= n. Intersection of two maps. Return data in the first map for the keys existing in both maps. (intersection m1 m2 == intersectionWith const m1 m2).
intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"
O(m*log(n/m + 1)), m <= n. Intersection with a combining function.
intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"
O(m*log(n/m + 1)), m <= n. Intersection with a combining function.
let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar
intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"
O(m*log(n/m + 1)), m <= n. The intersection of two sets. Elements of the result come from the first set, so for example
import qualified Data.Set as S
data AB = A | B deriving Show
instance Ord AB where compare _ _ = EQ
instance Eq AB where _ == _ = True
main = print (S.singleton A `S.intersection` S.singleton B,
S.singleton B `S.intersection` S.singleton A)
prints (fromList [A],fromList [B]).