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, Storable a) => Fold m a b -> SerialT m (Array a) -> m (b, SerialT m (Array a))
- parse :: (MonadIO m, MonadThrow m, Storable a) => Parser 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 a b -> Stream m (Array a) -> m (b, Stream m (Array a))
- foldArr :: (MonadIO m, MonadThrow m, Storable a) => Fold m a b -> SerialT m (Array a) -> m b
- foldArr_ :: (MonadIO m, MonadThrow m, Storable a) => Fold m a b -> SerialT m (Array a) -> m (b, SerialT m (Array a))
- parseArrD :: 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))
- foldArrMany :: (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) ()
- 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
Element Folds
fold :: (MonadIO m, Storable a) => Fold m a b -> SerialT m (Array a) -> m (b, SerialT m (Array a)) Source #
Fold an array stream using the supplied Fold
. Returns the fold result
and the unconsumed stream.
Internal
parse :: (MonadIO m, MonadThrow m, Storable a) => Parser m a b -> SerialT m (Array a) -> m (b, SerialT m (Array a)) Source #
Parse an array stream using the supplied Parser
. Returns the parse
result and the unconsumed stream. Throws ParseError
if the parse fails.
Internal
parseD :: forall m a b. (MonadIO m, MonadThrow m, Storable a) => Parser m a b -> Stream m (Array a) -> m (b, Stream m (Array a)) Source #
Array Folds
foldArr :: (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
foldArr_ :: (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
parseArrD :: 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 #
foldArrMany :: (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 #
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