Copyright | (c) 2019 Composewell Technologies |
---|---|
License | BSD3-3-Clause |
Maintainer | streamly@composewell.com |
Stability | pre-release |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Combinators to efficiently manipulate streams of immutable arrays.
Synopsis
- arraysOf :: (IsStream t, MonadIO m, Storable a) => Int -> t m a -> t m (Array a)
- concat :: (IsStream t, MonadIO m, Storable a) => t m (Array a) -> t m a
- concatRev :: (IsStream t, MonadIO m, Storable a) => t m (Array a) -> t m a
- interpose :: (MonadIO m, IsStream t, Storable a) => a -> t m (Array a) -> t m a
- interposeSuffix :: (MonadIO m, IsStream t, Storable a) => a -> t m (Array a) -> t m a
- intercalateSuffix :: (MonadIO m, IsStream t, Storable a) => Array a -> t m (Array a) -> t m a
- unlines :: forall m a. (MonadIO m, Storable a) => a -> Stream m (Array a) -> Stream m a
- fold :: (MonadIO m, MonadThrow m, Storable a) => Fold m a b -> SerialT m (Array a) -> m b
- fold_ :: (MonadIO m, MonadThrow m, Storable a) => Fold m a b -> SerialT m (Array a) -> m (b, SerialT m (Array a))
- parseD :: forall m a b. (MonadIO m, MonadThrow m, Storable a) => Parser m (Array a) b -> Stream m (Array a) -> m (b, Stream m (Array a))
- foldMany :: (IsStream t, MonadThrow m, Storable a) => Fold m a b -> t m (Array a) -> t m b
- toArray :: (MonadIO m, Storable a) => SerialT m (Array a) -> m (Array a)
- lpackArraysChunksOf :: (MonadIO m, Storable a) => Int -> Fold m (Array a) () -> Fold m (Array a) ()
- groupIOVecsOf :: MonadIO m => Int -> Int -> Stream m (Array a) -> Stream m (Array IOVec)
- compact :: (MonadIO m, Storable a) => Int -> SerialT m (Array a) -> SerialT m (Array a)
- splitOn :: (IsStream t, MonadIO m) => Word8 -> t m (Array Word8) -> t m (Array Word8)
- splitOnSuffix :: (IsStream t, MonadIO m) => Word8 -> t m (Array Word8) -> t m (Array Word8)
Creation
arraysOf :: (IsStream t, MonadIO m, Storable a) => Int -> t m a -> t m (Array a) Source #
arraysOf n stream
groups the elements in the input stream into arrays of
n
elements each.
arraysOf n = Stream.chunksOf n (Array.writeN n)
Pre-release
Flattening to elements
concat :: (IsStream t, MonadIO m, Storable a) => t m (Array a) -> t m a Source #
Convert a stream of arrays into a stream of their elements.
Same as the following but more efficient:
concat = Stream.unfoldMany Array.read
Since: 0.7.0
concatRev :: (IsStream t, MonadIO m, Storable a) => t m (Array a) -> t m a Source #
Convert a stream of arrays into a stream of their elements reversing the contents of each array before flattening.
concatRev = Stream.unfoldMany Array.readRev
Since: 0.7.0
interpose :: (MonadIO m, IsStream t, Storable a) => a -> t m (Array a) -> t m a Source #
Flatten a stream of arrays after inserting the given element between arrays.
Pre-release
interposeSuffix :: (MonadIO m, IsStream t, Storable a) => a -> t m (Array a) -> t m a Source #
Flatten a stream of arrays appending the given element after each array.
Since: 0.7.0
intercalateSuffix :: (MonadIO m, IsStream t, Storable a) => Array a -> t m (Array a) -> t m a Source #
Elimination
fold :: (MonadIO m, MonadThrow m, Storable a) => Fold m a b -> SerialT m (Array a) -> m b Source #
Fold an array stream using the supplied array stream Fold
.
Pre-release
fold_ :: (MonadIO m, MonadThrow m, Storable a) => Fold m a b -> SerialT m (Array a) -> m (b, SerialT m (Array a)) Source #
Like fold
but also returns the remaining stream.
Pre-release
parseD :: forall m a b. (MonadIO m, MonadThrow m, Storable a) => Parser m (Array a) b -> Stream m (Array a) -> m (b, Stream m (Array a)) Source #
foldMany :: (IsStream t, MonadThrow m, Storable a) => Fold m a b -> t m (Array a) -> t m b Source #
Apply an array stream Fold
repeatedly on an array stream and emit the
fold outputs in the output stream.
See "Streamly.Prelude.foldMany" for more details.
Pre-release
toArray :: (MonadIO m, Storable a) => SerialT m (Array a) -> m (Array a) Source #
Given a stream of arrays, splice them all together to generate a single array. The stream must be finite.
Since: 0.7.0
Compaction
lpackArraysChunksOf :: (MonadIO m, Storable a) => Int -> Fold m (Array a) () -> Fold m (Array a) () Source #
groupIOVecsOf :: MonadIO m => Int -> Int -> Stream m (Array a) -> Stream m (Array IOVec) Source #
groupIOVecsOf maxBytes maxEntries
groups arrays in the incoming stream
to create a stream of IOVec
arrays with a maximum of maxBytes
bytes in
each array and a maximum of maxEntries
entries in each array.
Since: 0.7.0
compact :: (MonadIO m, Storable a) => Int -> SerialT m (Array a) -> SerialT m (Array a) Source #
Coalesce adjacent arrays in incoming stream to form bigger arrays of a maximum specified size in bytes.
Since: 0.7.0