Skip to content

Quick Start

Run a one-liner:

Terminal window
cargo run -- --eval 'perform IO.print("Hello, Nulang!")'
Hello, Nulang!

Or start the REPL for an interactive session:

Terminal window
cargo run -- --repl
let x = 42
let y = x + 8
fn greet(name: String) -> String {
"Hello, " + name
}
perform IO.print(greet("World"))
type Person = { name: String, age: Int }
fn describe(p: Person) -> String {
match p {
{ name: n, age: a } if a < 18 => n + " is young",
{ name: n, age: a } => n + " is " + perform Int.to_string(a)
}
}
let alice = { name: "Alice", age: 30 }
perform IO.print(describe(alice))
actor Counter {
state count: Int = 0
behavior inc() {
self.count = self.count + 1
}
behavior get() { self.count }
}
let c = spawn Counter {} in {
ask c inc()
ask c inc()
ask c get()
}

Use spawn to create an actor, ask to call a behavior and wait for its return value, and send to fire-and-forget a message (useful in the full runtime where actors process messages concurrently).

effect Logger {
log: (String) -> Unit
}
fn greet_with_log(name: String) {
perform Logger.log("Greeting " + name)
perform IO.print("Hello, " + name)
}
handle greet_with_log("World") {
| Logger.log(msg) resume => {
perform IO.print("[LOG] " + msg)
}
}