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.Data.Array.Foreign (Array)
24import Streamly.Internal.Data.Stream.IsStream (IsStream)
26import qualified Streamly.Internal.Unicode.Stream as S
27import qualified Streamly.Data.Array.Foreign as A
31-- >>> :set -XOverloadedStrings
32-- >>> import Prelude hiding (String, lines, words, unlines, unwords)
33-- >>> import qualified Streamly.Prelude as Stream
34-- >>> import qualified Streamly.Internal.Unicode.Array.Char as Unicode
36-- | Break a string up into a stream of strings at newline characters.
37-- The resulting strings do not contain newlines.
39-- > lines = S.lines A.write
41-- >>> Stream.toList $ Unicode.lines $ Stream.fromList "lines\nthis\nstring\n\n\n"
42-- ["lines","this","string","",""]
45lines :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
46lines = S.lines A.write
48-- | Break a string up into a stream of strings, which were delimited
49-- by characters representing white space.
51-- > words = S.words A.write
53-- >>> Stream.toList $ Unicode.words $ Stream.fromList "A newline\nis considered white space?"
54-- ["A","newline","is","considered","white","space?"]
57words :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
58words = S.words A.write
60-- | Flattens the stream of @Array Char@, after appending a terminating
61-- newline to each string.
63-- 'unlines' is an inverse operation to 'lines'.
65-- >>> Stream.toList $ Unicode.unlines $ Stream.fromList ["lines", "this", "string"]
66-- "lines\nthis\nstring\n"
68-- > unlines = S.unlines A.read
70-- Note that, in general
72-- > unlines . lines /= id
74unlines :: (MonadIO m, IsStream t) => t m (Array Char) -> t m Char
75unlines = S.unlines A.read
77-- | Flattens the stream of @Array Char@, after appending a separating
78-- space to each string.
80-- 'unwords' is an inverse operation to 'words'.
82-- >>> Stream.toList $ Unicode.unwords $ Stream.fromList ["unwords", "this", "string"]
83-- "unwords this string"
85-- > unwords = S.unwords A.read
87-- Note that, in general
89-- > unwords . words /= id
91unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
92unwords = 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