Module
pooka/io
src/pooka/io.pookaLet the terminal speak, and listen carefully when it falls silent.
Use Erlang standard_io for ordinary output and standard_error for error output. Readers distinguish EOF from an empty line and retain line endings. read_char reads a Unicode code point; read_all preserves every received line.
import pooka/io
let assert Ok(_) = io.println("Good evening")
API reference
class IoError(message: String)
A io failure carrying the details needed by its caller. Keep this value in Result until a boundary can explain it.
message: String
String
fn(String) -> pooka/io.IoErrorprint(text: String) -> Result(Nil, IoError)
fn(String) -> Result(Nil, pooka/io.IoError)Write text to stdout without adding a newline.
import pooka/io
let assert Ok(_) = io.print("oak")
println(text: String) -> Result(Nil, IoError)
fn(String) -> Result(Nil, pooka/io.IoError)Write text to stdout followed by a newline.
import pooka/io
let assert Ok(_) = io.println("oak")
eprint(text: String) -> Result(Nil, IoError)
fn(String) -> Result(Nil, pooka/io.IoError)Write text to standard_error without adding a newline.
import pooka/io
let assert Ok(_) = io.eprint("missing file")
eprintln(text: String) -> Result(Nil, IoError)
fn(String) -> Result(Nil, pooka/io.IoError)Write text to standard_error followed by a newline.
import pooka/io
let assert Ok(_) = io.eprintln("missing file")
read_line() -> Result(Option(String), IoError)
fn() -> Result(Option(String), pooka/io.IoError)Read one line with its terminator. EOF is Ok(None), not an empty line.
import pooka/io
let assert Ok(line) = io.read_line()
prompt(text: String) -> Result(Option(String), IoError)
fn(String) -> Result(Option(String), pooka/io.IoError)Write the prompt before requesting a line. Preserve EOF and input errors.
import pooka/io
let assert Ok(answer) = io.prompt("Name: ")
read_char() -> Result(Option(String), IoError)
fn() -> Result(Option(String), pooka/io.IoError)Read one Unicode code point, returning None at EOF.
import pooka/io
let assert Ok(character) = io.read_char()
read_all() -> Result(String, IoError)
fn() -> Result(String, pooka/io.IoError)Read until EOF, preserving line endings. Immediate EOF returns an empty string.
import pooka/io
let assert Ok(text) = io.read_all()
flush() -> Result(Nil, IoError)
fn() -> Result(Nil, pooka/io.IoError)Issue an ordered empty write to the output device.
import pooka/io
let assert Ok(_) = io.flush()
is_terminal() -> Bool
fn() -> BoolAsk whether stdout is attached to a terminal.
import pooka/io
let terminal = io.is_terminal()
is_error_terminal() -> Bool
fn() -> BoolAsk whether standard_error is attached to a terminal.
import pooka/io
let terminal = io.is_error_terminal()