-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Conduit-based algorithms -- -- Algorithms on Conduits, including higher level asynchronous processing -- and some other utilities. @package conduit-algorithms @version 0.0.2.0 -- | A few miscellaneous set of conduit utilities module Data.Conduit.Algorithms.Utils -- | This is a simple utility adapted from -- http://neilmitchell.blogspot.de/2015/07/thoughts-on-conduits.html awaitJust :: Monad m => (a -> Conduit a m b) -> Conduit a m b -- | groupC yields the input as groups of n elements. If the input -- is not a multiple of n, the last element will be incomplete groupC :: (Monad m) => Int -> Conduit a m [a] -- | Higher level async processing interfaces. module Data.Conduit.Algorithms.Async -- | If the filename indicates a gzipped file (or, on Unix, also a bz2 -- file), then it reads it and uncompresses it. -- -- For the case of gzip, asyncGzipFromFile is used. conduitPossiblyCompressedFile :: (MonadBaseControl IO m, MonadResource m) => FilePath -> Source m ByteString -- | This is like Data.Conduit.List.map, except that each element is -- processed in a separate thread (up to maxSize can be queued up at any -- one time). Results are evaluated to normal form (not WHNF!) to ensure -- that the computation is fully evaluated before being yielded to the -- next conduit. asyncMapC :: forall a m b. (MonadIO m, NFData b) => Int -> (a -> b) -> Conduit a m b -- | asyncMapC with error handling. The inner function can now return an -- error (as a Left). When the first error is seen, it -- throwErrors in the main monad. Note that f may be -- evaluated for arguments beyond the first error (as some threads may be -- running in the background and already processing elements after the -- first error). asyncMapEitherC :: forall a m b e. (MonadIO m, NFData b, NFData e, MonadError e m) => Int -> (a -> Either e b) -> Conduit a m b -- | A simple sink which performs gzip in a separate thread and writes the -- results to h. -- -- See also asyncGzipToFile asyncGzipTo :: forall m. (MonadIO m, MonadBaseControl IO m) => Handle -> Sink ByteString m () -- | Compresses the output and writes to the given file with compression -- being performed in a separate thread. -- -- See also asyncGzipTo asyncGzipToFile :: forall m. (MonadResource m, MonadBaseControl IO m) => FilePath -> Sink ByteString m () -- | A source which produces the ungzipped content from the the given -- handle. Note that this "reads ahead" so if you do not use all the -- input, the Handle will probably be left at an undefined position in -- the file. -- -- See also asyncGzipFromFile asyncGzipFrom :: forall m. (MonadIO m, MonadResource m, MonadBaseControl IO m) => Handle -> Source m ByteString -- | Open and read a gzip file with the uncompression being performed in a -- separate thread. -- -- See also asyncGzipFrom asyncGzipFromFile :: forall m. (MonadResource m, MonadBaseControl IO m) => FilePath -> Source m ByteString -- | Simple algorithms packaged as Conduits module Data.Conduit.Algorithms -- | Unique conduit. -- -- 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). uniqueOnC :: (Ord b, Monad m) => (a -> b) -> Conduit a m a -- | See uniqueOnC uniqueC :: (Ord a, Monad m) => Conduit a m a -- | Merge a list of sorted sources -- -- See mergeC2 mergeC :: (Ord a, Monad m) => [Source m a] -> Source m a -- | Take two sorted sources and merge them. -- -- See mergeC mergeC2 :: (Ord a, Monad m) => Source m a -> Source m a -> Source m a