| Copyright | (c) Dong Han 2018~2019 |
|---|---|
| License | BSD |
| Maintainer | winterland1989@gmail.com |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Std.IO.StdStream
Description
This module provides stdin/stderr/stdout reading and writings. Usually you don't have to use stderr or stderrBuf directly, Logger provides more logging utilities through stderr. While stdinBuf and stdoutBuf is useful when you write interactive programs, Buffered module provide many reading and writing operations. Example:
import Std.IO.LowResTimer
import Std.IO.Buffered
import Std.IO.StdStream
main = do
-- read by '\n'
b1 <- readLineStd
-- read whatever user input in 3s, otherwise get Nothing
b2 <- timeoutLowRes 30 $ readBuffered stdinBuf
...
putStd "hello world!"
Synopsis
- data StdStream
- isStdStreamTTY :: StdStream -> Bool
- data UVTTYMode where
- pattern UV_TTY_MODE_NORMAL :: UVTTYMode
- pattern UV_TTY_MODE_RAW :: UVTTYMode
- setStdinTTYMode :: UVTTYMode -> IO ()
- stdin :: StdStream
- stdout :: StdStream
- stderr :: StdStream
- stdinBuf :: BufferedInput StdStream
- stdoutBuf :: BufferedOutput StdStream
- stderrBuf :: BufferedOutput StdStream
- printStd :: ToText a => a -> IO ()
- readLineStd :: IO Bytes
- putStd :: Builder a -> IO ()
- putLineStd :: Builder a -> IO ()
Standard input & output streams
Standard input and output streams
We support both regular file and TTY based streams, when initialized
uv_guess_handle is called to decide which type of devices are connected
to standard streams.
Note StdStream is not thread safe, you shouldn't use them without lock.
For the same reason you shouldn't use stderr directly, use Logger module instead.
isStdStreamTTY :: StdStream -> Bool Source #
Terminal mode.
When in UV_TTY_MODE_RAW mode, input is always available character-by-character,
not including modifiers. Additionally, all special processing of characters by the terminal is disabled,
including echoing input characters. Note that CTRL+C will no longer cause a SIGINT when in this mode.
Bundled Patterns
| pattern UV_TTY_MODE_NORMAL :: UVTTYMode | |
| pattern UV_TTY_MODE_RAW :: UVTTYMode |
Instances
setStdinTTYMode :: UVTTYMode -> IO () Source #
Change terminal's mode if stdin is connected to a terminal.
utils
readLineStd :: IO Bytes Source #
read a line from stdin