Hoogle Search
Within LTS Haskell 24.40 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
foldMany :: forall t (m :: Type -> Type) a b . (IsStream t, Monad m) => Fold m a b -> t m a -> t m bstreamly Streamly.Internal.Data.Stream.IsStream Apply a Fold repeatedly on a stream and emit the fold outputs in the output stream. To sum every two contiguous elements in a stream:
>>> f = Fold.take 2 Fold.sum >>> Stream.toList $ Stream.foldMany f $ Stream.fromList [1..10] [3,7,11,15,19]
On an empty stream the output is empty:>>> Stream.toList $ Stream.foldMany f $ Stream.fromList [] []
Note Stream.foldMany (Fold.take 0) would result in an infinite loop in a non-empty stream.-
streamly Streamly.Internal.Data.Stream.IsStream Like foldMany but appends empty fold output if the fold and stream termination aligns:
>>> f = Fold.take 2 Fold.sum >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [] [0] >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [1..9] [3,7,11,15,9] >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [1..10] [3,7,11,15,19,0]
Pre-release -
streamly Streamly.Internal.Data.Stream.IsStream Like foldMany but appends empty fold output if the fold and stream termination aligns:
>>> f = Fold.take 2 Fold.sum >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [] [0] >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [1..9] [3,7,11,15,9] >>> Stream.toList $ Stream.foldManyPost f $ Stream.fromList [1..10] [3,7,11,15,19,0]
Pre-release -
streamly Streamly.Internal.Data.Stream.IsStream Apply a Parser repeatedly on a stream and emit the parsed values in the output stream. This is the streaming equivalent of the many parse combinator.
>>> Stream.toList $ Stream.parseMany (Parser.takeBetween 0 2 Fold.sum) $ Stream.fromList [1..10] [Right 3,Right 7,Right 11,Right 15,Right 19]
> Stream.toList $ Stream.parseMany (Parser.line Fold.toList) $ Stream.fromList "hello\nworld" ["hello\n","world"]
foldMany f = parseMany (fromFold f)
Known Issues: When the parser fails there is no way to get the remaining stream. Pre-release -
streamly Streamly.Internal.Data.Stream.IsStream Same as parseMany but for StreamD streams. Internal
parseManyTill :: forall a (m :: Type -> Type) b x t . Parser a m b -> Parser a m x -> t m a -> t m bstreamly Streamly.Internal.Data.Stream.IsStream parseManyTill collect test stream tries the parser test on the input, if test fails it backtracks and tries collect, after collect succeeds test is tried again and so on. The parser stops when test succeeds. The output of test is discarded and the output of collect is emitted in the output stream. The parser fails if collect fails. Unimplemented
refoldMany :: (IsStream t, Monad m) => Refold m c a b -> m c -> t m a -> t m bstreamly Streamly.Internal.Data.Stream.IsStream Like foldMany but using the Refold type instead of Fold. Pre-release
scanMany :: forall t (m :: Type -> Type) a b . (IsStream t, Monad m) => Fold m a b -> t m a -> t m bstreamly Streamly.Internal.Data.Stream.IsStream Like scan but restarts scanning afresh when the scanning fold terminates. Pre-release
splitOnAny :: forall a (m :: Type -> Type) b t . [Array a] -> Fold m a b -> t m a -> t m bstreamly Streamly.Internal.Data.Stream.IsStream Split on any one of the given patterns. Unimplemented
splitOnSuffixSeqAny :: forall a (m :: Type -> Type) b t . [Array a] -> Fold m a b -> t m a -> t m bstreamly Streamly.Internal.Data.Stream.IsStream Split post any one of the given patterns. Unimplemented