streamly-core-0.1.0: Streaming, parsers, arrays and more
Copyright(c) 2019 Composewell Technologies
LicenseBSD-3-Clause
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.Data.Stream.StreamD.Container

Description

Stream operations that require transformers or containers like Set or Map.

Synopsis

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

joinLeft :: (Ord k, Monad m) => Stream m (k, a) -> Stream m (k, b) -> Stream m (k, a, Maybe b) Source #

A more efficient joinLeft using a hashmap for efficiency.

Space: O(n)

Time: O(m + n)

Pre-release

joinOuter :: (Ord k, MonadIO m) => Stream m (k, a) -> Stream m (k, b) -> Stream m (k, Maybe a, Maybe b) Source #

Like joinOuter but uses a Map for efficiency.

Space: O(m + n)

Time: O(m + n)

Pre-release