2-- Module : Streamly.Internal.Unicode.Array.Char
3-- Copyright : (c) 2018 Composewell Technologies
5-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
7-- Stability : experimental
10module Streamly.Internal.Unicode.Array.Char
12 -- * Streams of Strings
20import Control.Monad.IO.Class (MonadIO)
21import Streamly.Data.Array.Unboxed (Array)
22import Streamly.Internal.Data.Stream.IsStream (IsStream)
23import Streamly.Prelude (MonadAsync)
25import qualified Streamly.Data.Array.Unboxed as A
26import qualified Streamly.Internal.Unicode.Stream as S
28import Prelude hiding (String, lines, words, unlines, unwords)
32-- >>> :set -XOverloadedStrings
33-- >>> import Prelude hiding (String, lines, words, unlines, unwords)
34-- >>> import qualified Streamly.Prelude as Stream
35-- >>> import qualified Streamly.Internal.Unicode.Array.Char as Unicode
37-- | Break a string up into a stream of strings at newline characters.
38-- The resulting strings do not contain newlines.
40-- > lines = S.lines A.write
42-- >>> Stream.toList $ Unicode.lines $ Stream.fromList "lines\nthis\nstring\n\n\n"
43-- ["lines","this","string","",""]
46lines :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
47lines = S.lines A.write
49-- | Break a string up into a stream of strings, which were delimited
50-- by characters representing white space.
52-- > words = S.words A.write
54-- >>> Stream.toList $ Unicode.words $ Stream.fromList "A newline\nis considered white space?"
55-- ["A","newline","is","considered","white","space?"]
58words :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
59words = S.words A.write
61-- | Flattens the stream of @Array Char@, after appending a terminating
62-- newline to each string.
64-- 'unlines' is an inverse operation to 'lines'.
66-- >>> Stream.toList $ Unicode.unlines $ Stream.fromList ["lines", "this", "string"]
67-- "lines\nthis\nstring\n"
69-- > unlines = S.unlines A.read
71-- Note that, in general
73-- > unlines . lines /= id
75unlines :: (MonadIO m, IsStream t) => t m (Array Char) -> t m Char
76unlines = S.unlines A.read
78-- | Flattens the stream of @Array Char@, after appending a separating
79-- space to each string.
81-- 'unwords' is an inverse operation to 'words'.
83-- >>> Stream.toList $ Unicode.unwords $ Stream.fromList ["unwords", "this", "string"]
84-- "unwords this string"
86-- > unwords = S.unwords A.read
88-- Note that, in general
90-- > unwords . words /= id
92unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
93unwords = S.unwords A.read
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list