Skip to content

Hello World

Create a file called hello.almd:

effect fn main() -> Result[Unit, String] = {
println("Hello, world!")
ok(())
}

Run it:

almide run hello.almd

Output:

Hello, world!
  • effect fn — this function has side effects (printing to stdout)
  • main() — the entry point of the program
  • -> Result[Unit, String] — returns Unit on success, or a String error
  • println(...) — print a line to stdout
  • ok(()) — return success with the Unit value ()
fn greet(name: String) -> String =
"Hello, ${name}!"
effect fn main() -> Result[Unit, String] = {
let names = ["Alice", "Bob", "Charlie"]
for name in names {
println(greet(name))
}
ok(())
}
Hello, Alice!
Hello, Bob!
Hello, Charlie!

Add a test block anywhere in your .almd file:

fn add(a: Int, b: Int) -> Int = a + b
test "addition" {
assert_eq(add(1, 2), 3)
assert_eq(add(0, 0), 0)
assert_eq(add(-1, 1), 0)
}

Run tests:

almide test hello.almd
almide build hello.almd -o hello
./hello