Hoogle Search
Within LTS Haskell 24.45 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
foldMany :: forall (m :: Type -> Type) a b . Monad m => Fold m a b -> Stream m a -> Stream m bstreamly-core Streamly.Data.Stream Apply a Fold repeatedly on a stream and emit the results in the output stream. Definition:
>>> foldMany f = Stream.parseMany (Parser.fromFold f)
Example, empty stream:>>> f = Fold.take 2 Fold.sum >>> fmany = Stream.fold Fold.toList . Stream.foldMany f >>> fmany $ Stream.fromList [] []
Example, last fold empty:>>> fmany $ Stream.fromList [1..4] [3,7]
Example, last fold non-empty:>>> fmany $ Stream.fromList [1..5] [3,7,5]
Note that using a closed fold e.g. Fold.take 0, would result in an infinite stream on a non-empty input stream.-
streamly-core Streamly.Data.Stream Apply a Parser repeatedly on a stream and emit the parsed values in the output stream. Example:
>>> s = Stream.fromList [1..10] >>> parser = Parser.takeBetween 0 2 Fold.sum >>> Stream.fold Fold.toList $ Stream.parseMany parser s [Right 3,Right 7,Right 11,Right 15,Right 19]
This is the streaming equivalent of the many parse combinator. Known Issues: When the parser fails there is no way to get the remaining stream. unfoldMany :: forall (m :: Type -> Type) a b . Monad m => Unfold m a b -> Stream m a -> Stream m bstreamly-core Streamly.Data.Stream unfoldMany unfold stream uses unfold to map the input stream elements to streams and then flattens the generated streams into a single output stream. Like concatMap but uses an Unfold for stream generation. Unlike concatMap this can fuse the Unfold code with the inner loop and therefore provide many times better performance.
many :: forall (m :: Type -> Type) b c a . Monad m => Unfold m b c -> Unfold m a b -> Unfold m a cstreamly-core Streamly.Data.Unfold Apply the first unfold to each output element of the second unfold and flatten the output in a single stream.
>>> many u = Unfold.many2 (Unfold.lmap snd u)
-
streamly-core Streamly.Internal.Data.Array.Stream Apply an ChunkFold repeatedly on an array stream and emit the fold outputs in the output stream. See "Streamly.Data.Stream.foldMany" for more details. Pre-release
-
streamly-core Streamly.Internal.Data.Fold No documentation available.
many :: forall (m :: Type -> Type) a b c . Monad m => Fold m a b -> Fold m b c -> Fold m a cstreamly-core Streamly.Internal.Data.Fold Collect zero or more applications of a fold. many first second applies the first fold repeatedly on the input stream and accumulates it's results using the second fold.
>>> two = Fold.take 2 Fold.toList >>> twos = Fold.many two Fold.toList >>> Stream.fold twos $ Stream.fromList [1..10] [[1,2],[3,4],[5,6],[7,8],[9,10]]
Stops when second fold stops. See also: concatMap, foldManymanyPost :: forall (m :: Type -> Type) a b c . Monad m => Fold m a b -> Fold m b c -> Fold m a cstreamly-core Streamly.Internal.Data.Fold Like many, but the "first" fold emits an output at the end even if no input is received. Internal See also: concatMap, foldMany
-
streamly-core Streamly.Internal.Data.Fold -
streamly-core Streamly.Internal.Data.Fold