on master help sign in
Expose wordsBy from Data.Stream module (#2379)
commit668f2ef124f0d779f52d9277f5b3f4119ca9eb89 authorRanjeet Ranjan <ranjeetr@composewell.com> dateTue 4 Jul 2023, 23:54 (3 years ago) parente697599
2 files changed+7
core/src/Streamly/Data/Stream.hs+1 core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+6
core/src/Streamly/Data/Stream.hs+1
@@ -200,6 +200,7 @@ module Streamly.Data.Stream
200200
201201 -- ** Parsing
202202 , parse
203+ , wordsBy
203204 -- , parseBreak
204205
205206 -- ** Lazy Right Folds
core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+6
@@ -2091,6 +2091,12 @@ data WordsByState st fs b
20912091 | WordsByDone
20922092 | WordsByYield !b (WordsByState st fs b)
20932093
2094+-- | Split the stream after stripping leading, trailing, and repeated separators
2095+-- as per the fold supplied.
2096+-- Therefore, @".a..b."@ with '.' as the separator would be parsed as
2097+-- @["a","b"]@. In other words, its like parsing words from whitespace
2098+-- separated text.
2099+
20942100{-# INLINE_NORMAL wordsBy #-}
20952101wordsBy :: Monad m => (a -> Bool) -> Fold m a b -> Stream m a -> Stream m b
20962102wordsBy predicate (Fold fstep initial done) (Stream step state) =