on master help sign in
Expose wordsBy from Data.Stream module (#2379)
668f2efRanjeet Ranjan
core/src/Streamly/Data/Stream.hs+1
@@ -200,6 +200,7 @@ module Streamly.Data.Stream
200
200
201 -- ** Parsing
201 -- ** Parsing
202 , parse
202 , parse
203+ , wordsBy
203 -- , parseBreak
204 -- , parseBreak
204
205
205 -- ** Lazy Right Folds
206 -- ** Lazy Right Folds
core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+6
@@ -2091,6 +2091,12 @@ data WordsByState st fs b
2091 | WordsByDone
2091 | WordsByDone
2092 | WordsByYield !b (WordsByState st fs b)
2092 | WordsByYield !b (WordsByState st fs b)
2093
2093
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+
2094{-# INLINE_NORMAL wordsBy #-}
2100{-# INLINE_NORMAL wordsBy #-}
2095wordsBy :: Monad m => (a -> Bool) -> Fold m a b -> Stream m a -> Stream m b
2101wordsBy :: Monad m => (a -> Bool) -> Fold m a b -> Stream m a -> Stream m b
2096wordsBy predicate (Fold fstep initial done) (Stream step state) =
2102wordsBy predicate (Fold fstep initial done) (Stream step state) =