intersection package:multiset
O(n+m). The intersection of two multisets.
prints (fromList [A],fromList [B]).
O(n+m). The intersection of two multisets. Elements of the
result come from the first multiset, so for example
import qualified Data.MultiSet as MS
data AB = A | B deriving Show
instance Ord AB where compare _ _ = EQ
instance Eq AB where _ == _ = True
main = print (MS.singleton A `MS.intersection` MS.singleton B,
MS.singleton B `MS.intersection` MS.singleton A)
prints
(fromList [A],fromList [B]).