Skip to content

Commit ccf34a2

Browse files
committed
Implement unionBySorted API
1 parent fe066d6 commit ccf34a2

File tree

3 files changed

+595
-8
lines changed

3 files changed

+595
-8
lines changed

src/Streamly/Internal/Data/Stream/IsStream/Top.hs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ module Streamly.Internal.Data.Stream.IsStream.Top
2828
-- | These are not exactly set operations because streams are not
2929
-- necessarily sets, they may have duplicated elements.
3030
, intersectBy
31-
, intersectBySorted
31+
, intersectBySorted
3232
, differenceBy
3333
, mergeDifferenceBy
3434
, unionBy
35-
, mergeUnionBy
35+
, unionBySorted
3636

3737
-- ** Join operations
3838
, crossJoin
@@ -587,7 +587,9 @@ intersectBy eq s1 s2 =
587587
intersectBySorted :: (IsStream t, MonadIO m, Eq a) =>
588588
(a -> a -> Ordering) -> t m a -> t m a -> t m a
589589
intersectBySorted eq s1 =
590-
IsStream.fromStreamD . StreamD.intersectBySorted eq (IsStream.toStreamD s1) . IsStream.toStreamD
590+
IsStream.fromStreamD
591+
. StreamD.intersectBySorted eq (IsStream.toStreamD s1)
592+
. IsStream.toStreamD
591593

592594
-- Roughly joinLeft s1 s2 = s1 `difference` s2 + s1 `intersection` s2
593595

@@ -679,8 +681,11 @@ unionBy eq s1 s2 =
679681
--
680682
-- Space: O(1)
681683
--
682-
-- /Unimplemented/
683-
{-# INLINE mergeUnionBy #-}
684-
mergeUnionBy :: -- (IsStream t, Monad m) =>
684+
-- /Pre-release/
685+
{-# INLINE unionBySorted #-}
686+
unionBySorted :: (IsStream t, MonadAsync m, Ord a) =>
685687
(a -> a -> Ordering) -> t m a -> t m a -> t m a
686-
mergeUnionBy _eq _s1 _s2 = undefined
688+
unionBySorted cmp s1 =
689+
IsStream.fromStreamD
690+
. StreamD.unionBySorted cmp (IsStream.toStreamD s1)
691+
. IsStream.toStreamD

0 commit comments

Comments
 (0)