1{-# OPTIONS_HADDOCK hide #-}
2{-# LANGUAGE FlexibleContexts #-}
5-- Module : Streamly.Memory.Internal.Unicode.Array
6-- Copyright : (c) 2018 Composewell Technologies
9-- Maintainer : streamly@composewell.com
10-- Stability : experimental
13module Streamly.Internal.Memory.Unicode.Array
15 -- * Streams of Strings
23import Control.Monad.IO.Class (MonadIO)
24import Streamly (IsStream, MonadAsync)
25import Prelude hiding (String, lines, words, unlines, unwords)
26import Streamly.Memory.Array (Array)
28import qualified Streamly.Internal.Data.Unicode.Stream as S
29import qualified Streamly.Memory.Array as A
31-- | Break a string up into a stream of strings at newline characters.
32-- The resulting strings do not contain newlines.
34-- > lines = S.lines A.write
36-- >>> S.toList $ lines $ S.fromList "lines\nthis\nstring\n\n\n"
37-- ["lines","this","string","",""]
40lines :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
41lines = S.lines A.write
43-- | Break a string up into a stream of strings, which were delimited
44-- by characters representing white space.
46-- > words = S.words A.write
48-- >>> S.toList $ words $ S.fromList "A newline\nis considered white space?"
49-- ["A", "newline", "is", "considered", "white", "space?"]
52words :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
53words = S.words A.write
55-- | Flattens the stream of @Array Char@, after appending a terminating
56-- newline to each string.
58-- 'unlines' is an inverse operation to 'lines'.
60-- >>> S.toList $ unlines $ S.fromList ["lines", "this", "string"]
61-- "lines\nthis\nstring\n"
63-- > unlines = S.unlines A.read
65-- Note that, in general
67-- > unlines . lines /= id
69unlines :: (MonadIO m, IsStream t) => t m (Array Char) -> t m Char
70unlines = S.unlines A.read
72-- | Flattens the stream of @Array Char@, after appending a separating
73-- space to each string.
75-- 'unwords' is an inverse operation to 'words'.
77-- >>> S.toList $ unwords $ S.fromList ["unwords", "this", "string"]
78-- "unwords this string"
80-- > unwords = S.unwords A.read
82-- Note that, in general
84-- > unwords . words /= id
86unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
87unwords = 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