kex docs Standard Library

IO

module IO

printLine

printLine(msg: Showable) -> Void

Writes each argument to stdout followed by a newline. Multiple arguments are printed consecutively with no separator.

Examples
IO.printLine("hello")      # prints: hello
IO.printLine("x = ", 42)   # prints: x = 42

print

print(msg: Showable) -> Void

Writes each argument to stdout without a trailing newline.

Examples
IO.print("hello ")
IO.print("world")   # stdout: hello world

inspect

inspect(val: A) -> A

Pretty-prints a colored inspect representation of val to stderr. Returns val unchanged so it can be inserted into any pipeline. Treated as pure by the type checker — purity checking ignores this call.

Examples
xs.map(~double).inspect.filter(~even?)   # `inspected` gives the String

getLine

getLine : String?

Reads one line from stdin. Returns None at end-of-input.

Examples

IO.getLine.or("")

get

get : String?

Reads a single character from stdin. Returns None at end-of-input.

printError

printError(msg: Showable) -> Void

Writes a line to stderr. Does not exit. Use for error messages that should not go to stdout.

Examples

IO.printError("config file not found")

warn

warn(msg: Showable) -> Void

Alias for printError — use when signalling a non-fatal condition.

warning

warning(msg: Showable) -> Void

Alias for printError — longer form of warn.