streamly-0.8.3: Dataflow programming and declarative concurrency
Copyright(c) 2019 Composewell Technologies
LicenseBSD3-3-Clause
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell2010

Streamly.Internal.Data.Array.Stream.Mut.Foreign

Description

Combinators to efficiently manipulate streams of mutable arrays.

Synopsis

Generation

arraysOf :: (MonadIO m, Storable a) => Int -> SerialT m a -> SerialT 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 may be more efficient:

arraysOf n = Stream.foldMany (MArray.writeN n)

Pre-release

Compaction

packArraysChunksOf :: (MonadIO m, Storable a) => Int -> Stream m (Array a) -> Stream m (Array a) Source #

This mutates the first array (if it has space) to append values from the second one. This would work for immutable arrays as well because an immutable array never has space so a new array is allocated instead of mutating it.

| Coalesce adjacent arrays in incoming stream to form bigger arrays of a maximum specified size. Note that if a single array is bigger than the specified size we do not split it to fit. When we coalesce multiple arrays if the size would exceed the specified size we do not coalesce therefore the actual array size may be less than the specified chunk size.

Since: 0.7.0

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.

Internal

compactLE :: (MonadThrow m, 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.

Internal

compactEQ :: Int -> SerialT m (Array a) -> SerialT m (Array a) Source #

Like compactLE but generates arrays of exactly equal to the size specified except for the last array in the stream which could be shorter.

Unimplemented

compactGE :: (MonadIO m, Storable a) => Int -> SerialT m (Array a) -> SerialT m (Array a) Source #

Like compactLE but generates arrays of size greater than or equal to the specified except for the last array in the stream which could be shorter.

Internal