2-- Module : Streamly.Internal.Unicode.Array.Prim.Pinned
3-- Copyright : (c) 2020 Composewell Technologies
5-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
7-- Stability : experimental
10module Streamly.Internal.Unicode.Array.Prim.Pinned
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.Stream.IsStream (IsStream)
24import Streamly.Internal.Data.Array.Prim.Pinned (Array)
26import qualified Streamly.Internal.Unicode.Stream as S
27import qualified Streamly.Internal.Data.Array.Prim.Pinned as A
31-- >>> :set -XOverloadedStrings
32-- >>> import qualified Streamly.Prelude as Stream
33-- >>> import qualified Streamly.Internal.Unicode.Array.Prim.Pinned as Unicode
35-- | Break a string up into a stream of strings at newline characters.
36-- The resulting strings do not contain newlines.
38-- > lines = S.lines A.write
40-- >>> Stream.toList $ Unicode.lines $ Stream.fromList "lines\nthis\nstring\n\n\n"
41-- [fromListN 5 "lines",fromListN 4 "this",fromListN 6 "string",fromListN 0 "",fromListN 0 ""]
44lines :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
45lines = S.lines A.write
47-- | Break a string up into a stream of strings, which were delimited
48-- by characters representing white space.
50-- > words = S.words A.write
52-- >>> Stream.toList $ Unicode.words $ Stream.fromList "A newline\nis considered white space?"
53-- [fromListN 1 "A",fromListN 7 "newline",fromListN 2 "is",fromListN 10 "considered",fromListN 5 "white",fromListN 6 "space?"]
56words :: (MonadIO m, IsStream t) => t m Char -> t m (Array Char)
57words = S.words A.write
59-- | Flattens the stream of @Array Char@, after appending a terminating
60-- newline to each string.
62-- 'unlines' is an inverse operation to 'lines'.
64-- >>> Stream.toList $ Unicode.unlines $ Stream.fromList ["lines", "this", "string"]
65-- "lines\nthis\nstring\n"
67-- > unlines = S.unlines A.read
69-- Note that, in general
71-- > unlines . lines /= id
73unlines :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
74unlines = S.unlines A.read
76-- | Flattens the stream of @Array Char@, after appending a separating
77-- space to each string.
79-- 'unwords' is an inverse operation to 'words'.
81-- >>> Stream.toList $ Unicode.unwords $ Stream.fromList ["unwords", "this", "string"]
82-- "unwords this string"
84-- > unwords = S.unwords A.read
86-- Note that, in general
88-- > unwords . words /= id
90unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
91unwords = 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