words package:streamly-core

Break a string up into a stream of strings, which were delimited by characters representing white space.
words = S.words A.write
>>> Stream.fold Fold.toList $ Unicode.words $ Stream.fromList "A  newline\nis considered white space?"
[fromList "A",fromList "newline",fromList "is",fromList "considered",fromList "white",fromList "space?"]
Fold each word of the stream using the supplied Fold. Definition:
>>> words = Stream.wordsBy Char.isSpace
Usage:
>>> Stream.toList $ Unicode.words Fold.toList (Stream.fromList " ab  cd   ef ")
["ab","cd","ef"]
Pre-release
Split the stream after stripping leading, trailing, and repeated separators determined by the predicate supplied. The tokens after splitting are collected by the supplied fold. In other words, the tokens are parsed in the same way as words are parsed from whitespace separated text.
>>> f x = Stream.toList $ Stream.wordsBy (== '.') Fold.toList $ Stream.fromList x

>>> f "a.b"
["a","b"]

>>> f "a..b"
["a","b"]

>>> f ".a..b."
["a","b"]
Flattens the stream of Array Char, after appending a separating space to each string. unwords is an inverse operation to words.
>>> Stream.fold Fold.toList $ Unicode.unwords $ Stream.fromList ["unwords", "this", "string"]
"unwords this string"
unwords = S.unwords A.read
Note that, in general
unwords . words /= id
Unfold the elements of a stream to character streams using the supplied Unfold and concat the results with a whitespace character infixed between the streams.
>>> unwords = Stream.unfoldEachSepBy ' '

>>> unwords = Stream.unfoldEachSepBySeq " " Unfold.fromList
Pre-release