HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulestreamly-core-0.3.1Haskell2010

Streamly.Internal.Unicode.Array

  • 4 values

Setup

0 declarations

To execute the code examples provided in this module in ghci, please run the following commands first.

Example6 expressions
:m:set -XOverloadedStringsimport Prelude hiding (String, lines, words, unlines, unwords)import qualified Streamly.Data.Stream as Streamimport qualified Streamly.Data.Fold as Foldimport qualified Streamly.Internal.Unicode.Array as Unicode

Streams of Strings

4 declarations
valuelines :: MonadIO m => Stream m Char -> Stream m (Array Char)
#

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

lines = S.lines A.write
Example1 expression
Stream.fold Fold.toList $ Unicode.lines $ Stream.fromList "lines\nthis\nstring\n\n\n"[fromList "lines",fromList "this",fromList "string",fromList "",fromList ""]
valuewords :: MonadIO m => Stream m Char -> Stream m (Array Char)
#

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

words = S.words A.write
Example1 expression
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?"]
valueunlines :: MonadIO m => Stream m (Array Char) -> Stream m Char
#

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

unlines is an inverse operation to lines.

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

Note that, in general

unlines . lines /= id
valueunwords :: MonadIO m => Stream m (Array Char) -> Stream m Char
#

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

unwords is an inverse operation to words.

Example1 expression
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