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.Prelude (MonadAsync)
22import Prelude hiding (String, lines, words, unlines, unwords)
23import Streamly.Internal.Data.Array.Unboxed (Array)
24import Streamly.Internal.Data.Stream.IsStream (IsStream)
26import qualified Streamly.Internal.Data.Array.Unboxed as A
29import qualified Streamly.Internal.Unicode.Stream as S
33-- >>> :set -XOverloadedStrings
34-- >>> import Prelude hiding (String, lines, words, unlines, unwords)
35-- >>> import qualified Streamly.Prelude as Stream
36-- >>> import qualified Streamly.Internal.Unicode.Array.Char as Unicode
38-- | Break a string up into a stream of strings at newline characters.
39-- The resulting strings do not contain newlines.
41-- > lines = S.lines A.write
43-- >>> Stream.toList $ Unicode.lines $ Stream.fromList "lines\nthis\nstring\n\n\n"
44-- ["lines","this","string","",""]
47lines :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
48lines = S.lines A.write
50-- | Break a string up into a stream of strings, which were delimited
51-- by characters representing white space.
53-- > words = S.words A.write
55-- >>> Stream.toList $ Unicode.words $ Stream.fromList "A newline\nis considered white space?"
56-- ["A","newline","is","considered","white","space?"]
59words :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
60words = S.words A.write
62-- | Flattens the stream of @Array Char@, after appending a terminating
63-- newline to each string.
65-- 'unlines' is an inverse operation to 'lines'.
67-- >>> Stream.toList $ Unicode.unlines $ Stream.fromList ["lines", "this", "string"]
68-- "lines\nthis\nstring\n"
70-- > unlines = S.unlines A.read
72-- Note that, in general
74-- > unlines . lines /= id
76unlines :: (MonadIO m, IsStream t) => t m (Array Char) -> t m Char
77unlines = S.unlines A.read
79-- | Flattens the stream of @Array Char@, after appending a separating
80-- space to each string.
82-- 'unwords' is an inverse operation to 'words'.
84-- >>> Stream.toList $ Unicode.unwords $ Stream.fromList ["unwords", "this", "string"]
85-- "unwords this string"
87-- > unwords = S.unwords A.read
89-- Note that, in general
91-- > unwords . words /= id
93unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
94unwords = 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