streamly-core-0.2.2: Streaming, parsers, arrays, serialization and more
Copyright(c) 2018 Composewell Technologies
LicenseBSD-3-Clause
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell2010

Streamly.Internal.Console.Stdio

Description

 
Synopsis

Streams

read :: MonadIO m => Stream m Word8 Source #

Read a byte stream from standard input.

read = Handle.read stdin
read = Stream.unfold Stdio.reader ()

Pre-release

readChars :: MonadIO m => Stream m Char Source #

Read a character stream from Utf8 encoded standard input.

readChars = Unicode.decodeUtf8 Stdio.read

Pre-release

readChunks :: MonadIO m => Stream m (Array Word8) Source #

Read a stream of chunks from standard input. The maximum size of a single chunk is limited to defaultChunkSize. The actual size read may be less than defaultChunkSize.

readChunks = Handle.readChunks stdin
readChunks = Stream.unfold Stdio.chunkReader ()

Pre-release

Unfolds

reader :: MonadIO m => Unfold m () Word8 Source #

Unfold standard input into a stream of Word8.

chunkReader :: MonadIO m => Unfold m () (Array Word8) Source #

Unfolds standard input into a stream of Word8 arrays.

Folds

write :: MonadIO m => Fold m Word8 () Source #

Fold a stream of Word8 to standard output.

writeChunks :: MonadIO m => Fold m (Array Word8) () Source #

Fold a stream of Array Word8 to standard output.

writeErr :: MonadIO m => Fold m Word8 () Source #

Fold a stream of Word8 to standard error.

writeErrChunks :: MonadIO m => Fold m (Array Word8) () Source #

Fold a stream of Array Word8 to standard error.

Stream writes

putBytes :: MonadIO m => Stream m Word8 -> m () Source #

Write a stream of bytes to standard output.

putBytes = Handle.putBytes stdout
putBytes = Stream.fold Stdio.write

Pre-release

putChars :: MonadIO m => Stream m Char -> m () Source #

Encode a character stream to Utf8 and write it to standard output.

putChars = Stdio.putBytes . Unicode.encodeUtf8

Pre-release

putChunks :: MonadIO m => Stream m (Array Word8) -> m () Source #

Write a stream of chunks to standard output.

putChunks = Handle.putChunks stdout
putChunks = Stream.fold Stdio.writeChunks

Pre-release

putStringsWith :: MonadIO m => (Stream m Char -> Stream m Word8) -> Stream m String -> m () Source #

Write a stream of strings to standard output using the supplied encoding. Output is flushed to the device for each string.

Pre-release

putStrings :: MonadIO m => Stream m String -> m () Source #

Write a stream of strings to standard output using UTF8 encoding. Output is flushed to the device for each string.

Pre-release

putStringsLn :: MonadIO m => Stream m String -> m () Source #

Like putStrings but adds a newline at the end of each string.

XXX This is not portable, on Windows we need to use "rn" instead.

Pre-release