HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulestreamly-core-0.2.2Haskell2010

Streamly.Internal.Data.Fold.Chunked

Deprecated. Please use Streamly.Data.Parser instead.

Use Streamly.Data.Parser instead.

Fold a stream of foreign arrays. Fold m a b in this module works on a stream of "Array a" and produces an output of type b.

Though Fold m a b in this module works on a stream of Array a it is different from Data.Fold m (Array a) b. While the latter works on arrays as a whole treating them as atomic elements, the folds in this module can work on the stream of arrays as if it is an element stream with all the arrays coalesced together. This module allows adapting the element stream folds in Data.Fold to correctly work on an array stream as if it is an element stream. For example:

> import qualified Streamly.Data.Fold as Fold
> import qualified Streamly.Internal.Data.Array.Stream as ArrayStream
> import qualified Streamly.Internal.Data.Fold.Chunked as ChunkFold
> import qualified Streamly.Data.Stream as Stream
> import qualified Streamly.Data.StreamK as StreamK
> f = ChunkFold.fromFold (Fold.take 7 Fold.toList)
> s = Stream.chunksOf 5 $ Stream.fromList "hello world"
> ArrayStream.runArrayFold f (StreamK.fromStream s)

Right "hello w"

  • 1 type
  • 10 values
newtypenewtype ChunkFold (m :: Type -> Type) a b
#

Array stream fold.

An array stream fold is basically an array stream Parser that does not fail. In case of array stream folds the count in Partial, Continue and Done is a count of elements that includes the leftover element count in the array that is currently being processed by the parser. If none of the elements is consumed by the parser the count is at least the whole array length. If the whole array is consumed by the parser then the count will be 0.

Pre-release

Constructors

Instances3Monad, Functor, Applicative
  • Monad m => Monad (ChunkFold m a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Chunked

    Monad instance applies folds sequentially. Next fold can depend on the output of the previous fold. See concatMap.

    (>>=) = flip concatMap
  • Functor m => Functor (ChunkFold m a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Chunked

    Maps a function over the result of fold.

    Pre-release

  • Monad m => Applicative (ChunkFold m a)Defined in streamly-core-0.2.2 · Streamly.Internal.Data.Fold.Chunked

    Applicative form of splitWith. > (*) = splitWith id

Construction

4 declarations

Mapping

1 declaration

Applicative

3 declarations
valuefromPure :: Monad m => b -> ChunkFold m a b
#

A fold that always yields a pure value without consuming any input.

Pre-release

valuefromEffect :: Monad m => m b -> ChunkFold m a b
#

A fold that always yields the result of an effectful action without consuming any input.

Pre-release

valuesplitWith
  1. :: Monad m
  2. => a -> b -> c
  3. -> ChunkFold m x a
  4. -> ChunkFold m x b
  5. -> ChunkFold m x c
#

Applies two folds sequentially on the input stream and combines their results using the supplied function.

Pre-release

Monad

1 declaration
valueconcatMap
  1. :: Monad m
  2. => b -> ChunkFold m a c
  3. -> ChunkFold m a b
  4. -> ChunkFold m a c
#

Applies a fold on the input stream, generates the next fold from the output of the previously applied fold and then applies that fold.

Pre-release

Combinators

1 declaration