streamly-0.8.2: Dataflow programming and declarative concurrency
Copyright(c) 2020 Composewell Technologies
LicenseBSD-3-Clause
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.Unicode.Array.Prim.Pinned

Description

 
Synopsis

Streams of Strings

lines :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char) Source #

Break a string up into a stream of strings at newline characters. The resulting strings do not contain newlines.

lines = S.lines A.write
>>> Stream.toList $ Unicode.lines $ Stream.fromList "lines\nthis\nstring\n\n\n"
[fromListN 5 "lines",fromListN 4 "this",fromListN 6 "string",fromListN 0 "",fromListN 0 ""]

words :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char) Source #

Break a string up into a stream of strings, which were delimited by characters representing white space.

words = S.words A.write
>>> Stream.toList $ Unicode.words $ Stream.fromList "A  newline\nis considered white space?"
[fromListN 1 "A",fromListN 7 "newline",fromListN 2 "is",fromListN 10 "considered",fromListN 5 "white",fromListN 6 "space?"]

unlines :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char Source #

Flattens the stream of Array Char, after appending a terminating newline to each string.

unlines is an inverse operation to lines.

>>> Stream.toList $ Unicode.unlines $ Stream.fromList ["lines", "this", "string"]
"lines\nthis\nstring\n"
unlines = S.unlines A.read

Note that, in general

unlines . lines /= id

unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char Source #

Flattens the stream of Array Char, after appending a separating space to each string.

unwords is an inverse operation to words.

>>> Stream.toList $ Unicode.unwords $ Stream.fromList ["unwords", "this", "string"]
"unwords this string"
unwords = S.unwords A.read

Note that, in general

unwords . words /= id