Skip to content

Hello World

Create a file called hello.almd:

Almide
main.almd
effect fn main() -> Result[Unit, String] = {
  println("Hello, world!")
  ok(())
}
Press Run to compile and execute this in your browser

No installation needed to try it: Run in your browser compiles this with the real Almide compiler — the same one you install locally, shipped to this page as WebAssembly — and runs the result. Edit the code and press Run again.

To run it on your machine instead:

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 ()
Almide
main.almd
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(())
}
Press Run to compile and execute this in your browser

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