Module

pooka/io

src/pooka/io.pooka

Let 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.

Pooka
import pooka/io

io.println("Good evening")

API reference

class

IoError

src/pooka/io.pooka:22
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.

field

message

src/pooka/io.pooka:22
message: String
INFERREDString
constructor

new

src/pooka/io.pooka:22
INFERREDfn(String) -> pooka/io.IoError
function

print

src/pooka/io.pooka:53
print(text: String) -> Nil
INFERREDfn(String) -> Nil

Write text to stdout without adding a newline. Use try_print to inspect a write failure.

Pooka
import pooka/io

io.print("oak")
function

println

src/pooka/io.pooka:63
println(text: String) -> Nil
INFERREDfn(String) -> Nil

Write text to stdout followed by a newline.

Pooka
io.println("oak")
function

eprint

src/pooka/io.pooka:68
eprint(text: String) -> Nil
INFERREDfn(String) -> Nil

Write text to stderr without adding a newline.

function

eprintln

src/pooka/io.pooka:74
eprintln(text: String) -> Nil
INFERREDfn(String) -> Nil

Write text to stderr followed by a newline.

function

try_print

src/pooka/io.pooka:79
try_print(text: String) -> Result(Nil, IoError)
INFERREDfn(String) -> Result(Nil, pooka/io.IoError)

Write text to stdout and return any error from the output device.

function

try_println

src/pooka/io.pooka:88
try_println(text: String) -> Result(Nil, IoError)
INFERREDfn(String) -> Result(Nil, pooka/io.IoError)

Write a line to stdout and return any error from the output device.

Pooka
let assert Ok(_) = io.try_println("oak")
function

try_eprint

src/pooka/io.pooka:93
try_eprint(text: String) -> Result(Nil, IoError)
INFERREDfn(String) -> Result(Nil, pooka/io.IoError)

Write text to stderr and return any error from the output device.

function

try_eprintln

src/pooka/io.pooka:98
try_eprintln(text: String) -> Result(Nil, IoError)
INFERREDfn(String) -> Result(Nil, pooka/io.IoError)

Write a line to stderr and return any error from the output device.

function

read_line

src/pooka/io.pooka:109
read_line() -> Result(Option(String), IoError)
INFERREDfn() -> Result(Option(String), pooka/io.IoError)

Read one line with its terminator. EOF is Ok(None), not an empty line.

Pooka
import pooka/io

let assert Ok(line) = io.read_line()
function

prompt

src/pooka/io.pooka:120
prompt(text: String) -> Result(Option(String), IoError)
INFERREDfn(String) -> Result(Option(String), pooka/io.IoError)

Write the prompt before requesting a line. Preserve EOF and input errors.

Pooka
import pooka/io

let assert Ok(answer) = io.prompt("Name: ")
function

read_char

src/pooka/io.pooka:132
read_char() -> Result(Option(String), IoError)
INFERREDfn() -> Result(Option(String), pooka/io.IoError)

Read one Unicode code point, returning None at EOF.

Pooka
import pooka/io

let assert Ok(character) = io.read_char()
function

read_all

src/pooka/io.pooka:144
read_all() -> Result(String, IoError)
INFERREDfn() -> Result(String, pooka/io.IoError)

Read until EOF, preserving line endings. Immediate EOF returns an empty string.

Pooka
import pooka/io

let assert Ok(text) = io.read_all()
function

flush

src/pooka/io.pooka:164
flush() -> Result(Nil, IoError)
INFERREDfn() -> Result(Nil, pooka/io.IoError)

Issue an ordered empty write to the output device.

Pooka
import pooka/io

let assert Ok(_) = io.flush()
function

is_terminal

src/pooka/io.pooka:175
is_terminal() -> Bool
INFERREDfn() -> Bool

Ask whether stdout is attached to a terminal.

Pooka
import pooka/io

let terminal = io.is_terminal()
function

is_error_terminal

src/pooka/io.pooka:186
is_error_terminal() -> Bool
INFERREDfn() -> Bool

Ask whether standard_error is attached to a terminal.

Pooka
import pooka/io

let terminal = io.is_error_terminal()