Copyright | 2013-2018 Luis Pedro Coelho |
---|---|
License | MIT |
Maintainer | luis@luispedro.org |
Safe Haskell | None |
Language | Haskell2010 |
Higher level async processing interfaces.
- conduitPossiblyCompressedFile :: (MonadUnliftIO m, MonadResource m, MonadThrow m) => FilePath -> Source m ByteString
- conduitPossiblyCompressedToFile :: (MonadUnliftIO m, MonadResource m) => FilePath -> Sink ByteString m ()
- asyncMapC :: forall a m b. (MonadIO m, NFData b) => Int -> (a -> b) -> Conduit a m b
- asyncMapEitherC :: forall a m b e. (MonadIO m, NFData b, NFData e, MonadError e m) => Int -> (a -> Either e b) -> Conduit a m b
- asyncGzipTo :: forall m. (MonadIO m, MonadUnliftIO m) => Handle -> Sink ByteString m ()
- asyncGzipToFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Sink ByteString m ()
- asyncGzipFrom :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m) => Handle -> Source m ByteString
- asyncGzipFromFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Source m ByteString
- asyncBzip2To :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m) => Handle -> Sink ByteString m ()
- asyncBzip2ToFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Sink ByteString m ()
- asyncBzip2From :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m) => Handle -> Source m ByteString
- asyncBzip2FromFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Source m ByteString
- asyncXzTo :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m) => Handle -> Sink ByteString m ()
- asyncXzToFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Sink ByteString m ()
- asyncXzFrom :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m, MonadThrow m) => Handle -> Source m ByteString
- asyncXzFromFile :: forall m. (MonadResource m, MonadUnliftIO m, MonadThrow m) => FilePath -> Source m ByteString
- unorderedAsyncMapC :: forall a m b. (MonadIO m, NFData b) => Int -> (a -> b) -> Conduit a m b
Documentation
conduitPossiblyCompressedFile :: (MonadUnliftIO m, MonadResource m, MonadThrow m) => FilePath -> Source m ByteString Source #
If the filename indicates a gzipped file (or, on Unix, also a bz2 file), then it reads it and uncompresses it.
On Windows, attempting to read from a bzip2 file, results in error
.
For the case of gzip, asyncGzipFromFile
is used.
conduitPossiblyCompressedToFile :: (MonadUnliftIO m, MonadResource m) => FilePath -> Sink ByteString m () Source #
:: (MonadIO m, NFData b) | |
=> Int | Maximum number of worker threads |
-> (a -> b) | Function to execute |
-> Conduit a m b |
This is like map
, except that each element is processed
in a separate thread (up to maxThreads
can be queued up at any one time).
Results are evaluated to normal form (not weak-head normal form!, i.e., the
structure is deeply evaluated) to ensure that the computation is fully
evaluated in the worker thread.
Note that there is some overhead in threading. It is often a good idea to
build larger chunks of input before passing it to asyncMapC
to amortize
the costs. That is, when f
is not a lot of work, instead of asyncMapC f
,
it is sometimes better to do
CC.conduitVector 4096 .| asyncMapC (V.map f) .| CC.concat
where CC
refers to Combinators
asyncMapEitherC :: forall a m b e. (MonadIO m, NFData b, NFData e, MonadError e m) => Int -> (a -> Either e b) -> Conduit a m b Source #
asyncMapC
with error handling. The inner function can now return an
error (as a Left
). When the first error is seen, it throwError
s 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).
See asyncMapC
asyncGzipTo :: forall m. (MonadIO m, MonadUnliftIO m) => Handle -> Sink ByteString m () Source #
A simple sink which performs gzip compression in a separate thread and
writes the results to h
.
See also asyncGzipToFile
asyncGzipToFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Sink ByteString m () Source #
Compresses the output and writes to the given file with compression being performed in a separate thread.
See also asyncGzipTo
asyncGzipFrom :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m) => Handle -> Source m ByteString Source #
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
asyncGzipFromFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Source m ByteString Source #
Open and read a gzip file with the uncompression being performed in a separate thread.
See also asyncGzipFrom
asyncBzip2To :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m) => Handle -> Sink ByteString m () Source #
A simple sink which performs bzip2 compression in a separate thread and
writes the results to h
.
See also asyncGzipToFile
asyncBzip2ToFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Sink ByteString m () Source #
Compresses the output and writes to the given file with compression being performed in a separate thread.
See also asyncGzipTo
asyncBzip2From :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m) => Handle -> Source m ByteString Source #
A source which produces the bzipped2 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
asyncBzip2FromFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Source m ByteString Source #
Open and read a bzip2 file with the uncompression being performed in a separate thread.
See also asyncGzipFrom
asyncXzTo :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m) => Handle -> Sink ByteString m () Source #
A simple sink which performs lzma/xz compression in a separate thread and
writes the results to h
.
See also asyncGzipToFile
asyncXzToFile :: forall m. (MonadResource m, MonadUnliftIO m) => FilePath -> Sink ByteString m () Source #
Compresses the output and writes to the given file with compression being performed in a separate thread.
See also asyncGzipTo
asyncXzFrom :: forall m. (MonadIO m, MonadResource m, MonadUnliftIO m, MonadThrow m) => Handle -> Source m ByteString Source #
A source which produces the unxzipped 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
asyncXzFromFile :: forall m. (MonadResource m, MonadUnliftIO m, MonadThrow m) => FilePath -> Source m ByteString Source #
Open and read a lzma/xz file with the uncompression being performed in a separate thread.
See also asyncXzFrom