stdio-0.2.0.0: A simple and high performance IO toolkit for Haskell

Copyright(c) Dong Han 2018~2019
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Std.IO.StdStream

Contents

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

Standard input & output streams

data StdStream Source #

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.

Instances
Output StdStream Source # 
Instance details

Defined in Std.IO.StdStream

Methods

writeOutput :: StdStream -> Ptr Word8 -> Int -> IO () Source #

Input StdStream Source # 
Instance details

Defined in Std.IO.StdStream

data UVTTYMode where 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
Eq UVTTYMode Source # 
Instance details

Defined in Std.IO.UV.FFI

Num UVTTYMode Source # 
Instance details

Defined in Std.IO.UV.FFI

Ord UVTTYMode Source # 
Instance details

Defined in Std.IO.UV.FFI

Read UVTTYMode Source # 
Instance details

Defined in Std.IO.UV.FFI

Show UVTTYMode Source # 
Instance details

Defined in Std.IO.UV.FFI

Storable UVTTYMode Source # 
Instance details

Defined in Std.IO.UV.FFI

Bits UVTTYMode Source # 
Instance details

Defined in Std.IO.UV.FFI

FiniteBits UVTTYMode Source # 
Instance details

Defined in Std.IO.UV.FFI

setStdinTTYMode :: UVTTYMode -> IO () Source #

Change terminal's mode if stdin is connected to a terminal.

stderr :: StdStream Source #

Don't use stderr directly, use Logger instead.

utils

printStd :: ToText a => a -> IO () Source #

print a ToText to stdout

readLineStd :: IO Bytes Source #

read a line from stdin

putStd :: Builder a -> IO () Source #

print a Builder and flush to stdout.

putLineStd :: Builder a -> IO () Source #

print a Builder and flush to stdout stdout, with a linefeed.