Skip to content

io

The io module provides console input/output functions. Requires import io. All functions are effect fn.

FunctionSignatureDescription
read_line() -> StringRead a single line from stdin
print(String) -> UnitPrint to stdout without trailing newline
read_all() -> StringRead all of stdin as a single string
import io
effect fn prompt(msg: String) -> Result[String, String] = {
io.print(msg)
let answer = io.read_line()
ok(answer)
}
effect fn main(args: List[String]) -> Result[Unit, String] = {
io.print("Enter your name: ")
let name = io.read_line()
println("Hello, " + name + "!")
ok(())
}

Note: println is a built-in function (no import needed) and always appends a newline. Use io.print when you need output without a trailing newline, such as prompts.