conduit-algorithms-0.0.8.0: Conduit-based algorithms

Copyright2013-2018 Luis Pedro Coelho
LicenseMIT
Maintainerluis@luispedro.org
Safe HaskellNone
LanguageHaskell2010

Data.Conduit.Algorithms

Description

Simple algorithms packaged as Conduits

Synopsis

Documentation

uniqueOnC :: (Ord b, Monad m) => (a -> b) -> Conduit a m a Source #

Unique conduit.

For each element, it checks its key (using the a -> b key function) and yields it if it has not seen it before.

Note that this conduit does not assume that the input is sorted. Instead it uses a Set to store previously seen elements. Thus, memory usage is O(N) and time is O(N log N). If the input is sorted, you can use removeRepeatsC

uniqueC :: (Ord a, Monad m) => Conduit a m a Source #

Unique conduit

See uniqueOnC and removeRepeatsC

removeRepeatsC :: (Eq a, Monad m) => Conduit a m a Source #

Removes repeated elements

 yieldMany [0, 0, 1, 1, 1, 2, 2, 0] .| removeRepeatsC .| consume

is equivalent to [0, 1, 2, 0]

See uniqueC and uniqueOnC

mergeC :: (Ord a, Monad m) => [Source m a] -> Source m a Source #

Merge a list of sorted sources to produce a single (sorted) source

This takes a list of sorted sources and produces a Source which outputs all elements in sorted order.

See mergeC2

mergeC2 :: (Ord a, Monad m) => Source m a -> Source m a -> Source m a Source #

Take two sorted sources and merge them.

See mergeC