intersectBy package:streamly

intersectBy is essentially a filtering operation that retains only those elements in the first stream that are present in the second stream.
>>> Stream.toList $ Stream.intersectBy (==) (Stream.fromList [1,2,2,4]) (Stream.fromList [2,1,1,3])
[1,2,2]
>>> Stream.toList $ Stream.intersectBy (==) (Stream.fromList [2,1,1,3]) (Stream.fromList [1,2,2,4])
[2,1,1]
intersectBy is similar to but not the same as joinInner:
>>> Stream.toList $ fmap fst $ Stream.joinInner (==) (Stream.fromList [1,2,2,4]) (Stream.fromList [2,1,1,3])
[1,1,2,2]
Space: O(n) where n is the number of elements in the second stream. Time: O(m x n) where m is the number of elements in the first stream and n is the number of elements in the second stream. Pre-release
Like intersectBy but works only on streams sorted in ascending order. Space: O(1) Time: O(m+n) Pre-release