Skip to content

core.io — I/O

Import with << core.io. See the corelib index and examples/io.qn.

FunctionEffect
print(x) -> $Write x to stdout with a trailing newline. Any type, rendered through its ` render operator — a Bool prints True/False; records, sum types, and arrays use their default or overridden rendering. On output, text is rendered for a reader: an invalid UTF-8 byte shows as . Returns $.
eprint(x) -> $Same, to stderr. Returns $ (Unit).
write(content :: Text, fd :: Num) -> NumWrite raw bytes (no newline) to a file descriptor; returns bytes written. Byte-exact: the bytes as they are.
@readStdin() -> TextRead one line from stdin (without the trailing newline). A leaf IO primitive: it launches the read and returns a deferred Text forced on first strict use. Yields "" at end-of-input.
stdout, stderrThe standard file descriptors.

print, eprint, and write are overload sets — defining one with another signature adds a member rather than shadowing the built-in.

<< core.io
^ = () -> Num => <
print("hello") ~ stdout: hello\n
"raw" |> write(stdout) ~ stdout: raw (no newline)
eprint("oops") ~ stderr: oops\n
0
>

There is no printlnprint owns the newline; write is the raw form. (See examples/io.qn.)