Copyright | (c) 2019 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Stream operations that require transformers or containers like Set or Map.
Synopsis
- nub :: (Monad m, Ord a) => Stream m a -> Stream m a
- joinLeftGeneric :: Monad m => (a -> b -> Bool) -> Stream m a -> Stream m b -> Stream m (a, Maybe b)
- joinOuterGeneric :: MonadIO m => (a -> b -> Bool) -> Stream m a -> Stream m b -> Stream m (Maybe a, Maybe b)
- joinInner :: (Monad m, Ord k) => Stream m (k, a) -> Stream m (k, b) -> Stream m (k, a, b)
- joinLeft :: (Ord k, Monad m) => Stream m (k, a) -> Stream m (k, b) -> Stream m (k, a, Maybe b)
- joinOuter :: (Ord k, MonadIO m) => Stream m (k, a) -> Stream m (k, b) -> Stream m (k, Maybe a, Maybe b)
Documentation
nub :: (Monad m, Ord a) => Stream m a -> Stream m a Source #
The memory used is proportional to the number of unique elements in the stream. If we want to limit the memory we can just use "take" to limit the uniq elements in the stream.
Joins for unconstrained types
joinLeftGeneric :: Monad m => (a -> b -> Bool) -> Stream m a -> Stream m b -> Stream m (a, Maybe b) Source #
Like joinInner
but emit (a, Just b)
, and additionally, for those a
's
that are not equal to any b
emit (a, Nothing)
.
The second stream is evaluated multiple times. If the stream is a
consume-once stream then the caller should cache it in an Array
before calling this function. Caching may also improve performance if the
stream is expensive to evaluate.
>>>
joinRightGeneric eq = flip (Stream.joinLeftGeneric eq)
Space: O(n) assuming the second stream is cached in memory.
Time: O(m x n)
Unimplemented
joinOuterGeneric :: MonadIO m => (a -> b -> Bool) -> Stream m a -> Stream m b -> Stream m (Maybe a, Maybe b) Source #
Like joinLeft
but emits a (Just a, Just b)
. Like joinLeft
, for those
a
's that are not equal to any b
emit (Just a, Nothing)
, but
additionally, for those b
's that are not equal to any a
emit (Nothing,
Just b)
.
For space efficiency use the smaller stream as the second stream.
Space: O(n)
Time: O(m x n)
Pre-release
Joins with Ord constraint
joinInner :: (Monad m, Ord k) => Stream m (k, a) -> Stream m (k, b) -> Stream m (k, a, b) Source #
Like joinInner
but uses a Map
for efficiency.
If the input streams have duplicate keys, the behavior is undefined.
For space efficiency use the smaller stream as the second stream.
Space: O(n)
Time: O(m + n)
Pre-release