Examples
hello.mul
Hello, world (RFC-010): print is an io operation, so main is io. mul run prints the line and exits with the value of main, here 0.
Source
examples/hello.mul is stored in the compact layout, as AI agents write it: a space only between two words, no other whitespace. The page lays it out for reading; the Compact button shows the stored text, and Copy always copies it.
// Hello, world (RFC-010): `print` is an `io` operation, so `main` is `io`.
// `mul run` prints the line and exits with the value of `main`, here 0.
module demo pub fn main()->i32 io{print("Hello, world!")return 0}
Verified IR
What mul ir prints after the verifier has accepted the program.
module demo
fn @main() -> i32 io {
b0:
%0 = const.string "Hello, world!"
print %0
%1 = const.i32 0
return %1
}
Run
The value main returns is the exit code of the process.
$ mul run examples/hello.mul; echo "exit code $?"
Hello, world!
exit code 0