streamly-0.7.1: Beautiful Streaming, Concurrent and Reactive Composition

Copyright(c) 2019 Composewell Technologies
LicenseBSD3
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.Memory.ArrayStream

Contents

Description

Combinators to efficiently manipulate streams of arrays.

Synopsis

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.

Same as the following but more efficient:

arraysOf n = S.chunksOf n (A.writeN n)

Since: 0.7.0

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 = S.concatMap A.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.

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.

Internal

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 #

Transformation

splitOn :: (IsStream t, MonadIO m) => Word8 -> t m (Array Word8) -> t m (Array Word8) Source #

Split a stream of arrays on a given separator byte, dropping the separator and coalescing all the arrays between two separators into a single array.

Since: 0.7.0

splitOnSuffix :: (IsStream t, MonadIO m) => Word8 -> t m (Array Word8) -> t m (Array Word8) 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

Elimination

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