1{-# LANGUAGE FlexibleContexts #-}
4-- Module : Streamly.Memory.Internal.Unicode.Array
5-- Copyright : (c) 2018 Composewell Technologies
8-- Maintainer : streamly@composewell.com
9-- Stability : experimental
12module Streamly.Internal.Memory.Unicode.Array
14 -- * Streams of Strings
22import Control.Monad.IO.Class (MonadIO)
23import Streamly (IsStream, MonadAsync)
24import Prelude hiding (String, lines, words, unlines, unwords)
25import Streamly.Memory.Array (Array)
27import qualified Streamly.Internal.Data.Unicode.Stream as S
28import qualified Streamly.Memory.Array as A
30-- | Break a string up into a stream of strings at newline characters.
31-- The resulting strings do not contain newlines.
33-- > lines = S.lines A.write
35-- >>> S.toList $ lines $ S.fromList "lines\nthis\nstring\n\n\n"
36-- ["lines","this","string","",""]
39lines :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
40lines = S.lines A.write
42-- | Break a string up into a stream of strings, which were delimited
43-- by characters representing white space.
45-- > words = S.words A.write
47-- >>> S.toList $ words $ S.fromList "A newline\nis considered white space?"
48-- ["A", "newline", "is", "considered", "white", "space?"]
51words :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
52words = S.words A.write
54-- | Flattens the stream of @Array Char@, after appending a terminating
55-- newline to each string.
57-- 'unlines' is an inverse operation to 'lines'.
59-- >>> S.toList $ unlines $ S.fromList ["lines", "this", "string"]
60-- "lines\nthis\nstring\n"
62-- > unlines = S.unlines A.read
64-- Note that, in general
66-- > unlines . lines /= id
68unlines :: (MonadIO m, IsStream t) => t m (Array Char) -> t m Char
69unlines = S.unlines A.read
71-- | Flattens the stream of @Array Char@, after appending a separating
72-- space to each string.
74-- 'unwords' is an inverse operation to 'words'.
76-- >>> S.toList $ unwords $ S.fromList ["unwords", "this", "string"]
77-- "unwords this string"
79-- > unwords = S.unwords A.read
81-- Note that, in general
83-- > unwords . words /= id
85unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
86unwords = 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