Std. Io
(Cure Standard Library v0.37.2)
View Source
Standard I/O operations for printing to stdout.
Wall-clock stdout primitives. Every entry that actually writes
carries the ! Io effect so callers are forced to declare it
in their own signatures.
Examples
use Std.Io
println("Hello, Cure!") # Hello, Cure!
print_int(42) # 42
print_float(3.14) # 3.14use Std.Io
fn greet(name: String) -> Unit ! Io =
println("Hello, " <> name <> "!")
Summary
Functions
Render an atom as its name (:erlang.atom_to_list/1).
Render an atom as a String (its name, without the leading colon).
Render a float as its decimal string (:erlang.float_to_list/1).
Render a float as a String.
An @extern is a direct Erlang remote call with no marshalling, so the
types written here are claims about the ERASED shape that crosses the
boundary. String is nominal (rec String { characters: List(Char) }) and
erases to the tagged pair {String, chars}, which no OTP function knows how
to read or produce; List(Char) erases to a bare charlist, which they do.
So the externs below are declared at List(Char) and the public functions
wrap -- the same convention Std.String documents and follows.
Render an integer as a String.
Print a string to stdout without a trailing newline. Alias for
put_chars/1; kept for readability at call sites.
Print a float followed by a newline.
Print an integer followed by a newline.
Print a string to stdout with a trailing newline.
Write text to stdout, no trailing newline.
Group tag consumed by Cure.Stdlib.Preload.
Print a string to stdout without a trailing newline.
Wraps :io.put_chars/1.
Functions
fn atom_to_charlist(a: Atom) -> List(Char)
Render an atom as its name (:erlang.atom_to_list/1).
fn atom_to_string(a: Atom) -> String
Render an atom as a String (its name, without the leading colon).
fn float_to_charlist(f: Float) -> List(Char)
Render a float as its decimal string (:erlang.float_to_list/1).
fn float_to_string(f: Float) -> String
Render a float as a String.
fn int_to_charlist(n: Int) -> List(Char)
An @extern is a direct Erlang remote call with no marshalling, so the
types written here are claims about the ERASED shape that crosses the
boundary. String is nominal (rec String { characters: List(Char) }) and
erases to the tagged pair {String, chars}, which no OTP function knows how
to read or produce; List(Char) erases to a bare charlist, which they do.
So the externs below are declared at List(Char) and the public functions
wrap -- the same convention Std.String documents and follows.
Render an integer as its decimal string (:erlang.integer_to_list/1).
fn int_to_string(n: Int) -> String
Render an integer as a String.
fn print(text: String) -> Unit
Print a string to stdout without a trailing newline. Alias for
put_chars/1; kept for readability at call sites.
fn print_float(f: Float) -> Unit
Print a float followed by a newline.
fn print_int(n: Int) -> Unit
Print an integer followed by a newline.
fn println(text: String) -> Unit
Print a string to stdout with a trailing newline.
fn put_chars(text: String) -> Unit
Write text to stdout, no trailing newline.
The typed wrapper over :io.put_chars/1: converts the nominal String to
the bare charlist OTP expects and discards the atom result.
fn raw_put_chars(text: List(Char)) -> Atom
Group tag consumed by Cure.Stdlib.Preload.
Print a string to stdout without a trailing newline.
Wraps :io.put_chars/1.