March Docs

IO

IO module: explicit I/O operations separate from Process.

Wraps the core print/read builtins under a clean IO namespace. All functions in this module operate on the standard streams (stdin, stdout, stderr) of the current OS process.

Usage: IO.puts("Hello!") -- write to stdout with newline IO.write("no newline") -- write to stdout, no newline IO.warn("something went wrong") -- write to stderr with newline let line = IO.read_line() -- read a line from stdin let x = IO.inspect(some_value) -- pretty-print and return value let line = IO.gets("Name: ") -- print prompt then read line

Functions

fnwritewrite(s : String) : Unit#

Write a string to stdout without a trailing newline.

fnputsputs(s : String) : Unit#

Write a string to stdout with a trailing newline.

fnwarnwarn(s : String) : Unit#

Write a string to stderr with a trailing newline.

fnread_lineread_line() : String#

Read a line from stdin and return it (without the trailing newline). Returns empty string on EOF.

fngetsgets(prompt : String) : String#

Print prompt to stdout (no newline) then read and return a line from stdin. Equivalent to Elixir's IO.gets/1.

let name = IO.gets("What is your name? ")

fninspectinspect(value : a) : a#

Pretty-print value to stdout (with newline) and return the value unchanged. Useful for mid-pipeline debugging, like Elixir's IO.inspect/2.

some_list |> IO.inspect() |> Enum.map(fn x -> x + 1)

fniodata_to_stringiodata_to_string(iodata) : String#

Convert an IOList to a String by flattening all segments. Delegates to IOList.to_string/1.

IO.iodata_to_string(IOList.from_string("hello")) -- "hello"