Skip to content

Commit 8649f6c

Browse files
Update console module docs
1 parent a134ad6 commit 8649f6c

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

core/src/Streamly/Console/Stdio.hs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,25 @@
77
-- Stability : released
88
-- Portability : GHC
99
--
10-
-- Combinators to work with standard input, output and error streams.
10+
-- Combinators to work with standard input, output, and error streams. This
11+
-- module supports reading and writing binary data or UTF-8 encoded text only.
12+
-- However, it is possible to use specific encoders and decoders to implement
13+
-- other encodings.
14+
--
15+
-- These streaming APIs use the stdin and stdout handles for reading from and
16+
-- writing to the console. The reads and writes are buffered, meaning each
17+
-- stream has its own buffer. Be cautious when switching between these APIs and
18+
-- handle-based APIs (e.g., readChars, getLine), between different stream APIs
19+
-- (e.g., readChars, readChunks), or even between different calls to the same
20+
-- API (e.g., readChars, readChars). If you switch from one stream to another,
21+
-- you should drain the first stream completely if you care about preserving
22+
-- any buffered data.
1123
--
1224
-- See also: "Streamly.Internal.Console.Stdio"
1325

26+
-- XXX put examples of repeatM getLine from stream module
27+
-- XXX put examples of using parseBreak or foldBreak.
28+
1429
module Streamly.Console.Stdio
1530
(
1631
-- * Streams (stdin)

core/src/Streamly/Internal/Console/Stdio.hs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,24 @@
99

1010
module Streamly.Internal.Console.Stdio
1111
(
12-
-- * Streams
12+
-- * Singleton APIs
13+
-- getChunk
14+
-- , putChunk
15+
16+
-- * Stream reads
1317
read
14-
, readChars
18+
-- , readWith -- buffer
1519
, readChunks
16-
-- , getChunksLn
17-
-- , getStringsWith -- get strings using the supplied decoding
18-
-- , getStrings -- get strings of complete chars,
19-
-- leave any partial chars for next string
20-
-- , getStringsLn -- get lines decoded as char strings
20+
-- , readChunksWith -- buffer
21+
-- , readChunksLn -- chunks with line buffering -- repeatM Text.getLine
22+
23+
-- -- ** Encoding specific
24+
-- , readCharsWith
25+
-- , readStringsLnWith
26+
27+
-- ** UTF-8 decoded
28+
, readChars
29+
-- , readStringsLn -- strings with line buffering -- repeatM getLine
2130

2231
-- * Unfolds
2332
, reader
@@ -31,11 +40,18 @@ module Streamly.Internal.Console.Stdio
3140

3241
-- * Stream writes
3342
, putBytes -- Buffered (32K)
34-
, putChars
3543
, putChunks -- Unbuffered
44+
45+
-- ** Encoding specific
46+
-- , putCharsWith
3647
, putStringsWith
48+
-- , putStringsLnWith
49+
50+
-- ** UTF-8 encoded
51+
, putChars
3752
, putStrings
3853
, putStringsLn
54+
-- , putChunksLn
3955
)
4056
where
4157

@@ -193,7 +209,7 @@ putChunks = Handle.putChunks stdout
193209
-- folds as well as unfolds/streams. Non-backtracking (one-to-one, one-to-many,
194210
-- filters, reducers) transformations may be easy so we can possibly start with
195211
-- those.
196-
--
212+
197213
-- | Write a stream of strings to standard output using the supplied encoding.
198214
-- Output is flushed to the device for each string.
199215
--

0 commit comments

Comments
 (0)