Skip to content

Quickstart

This walkthrough gets you from an installed runtime to a real .kel file with functions, locals, and output. If kelvra --version does not work yet, follow Install Kelvra first.

Create a file named hello.kel:

fn applyTwice(f fn(i32) i32, value i32) i32 {
return f(f(value))
}
var addOne = fn(x i32) => x + 1
print(applyTwice(addOne, 40))

Run it:

Terminal window
kelvra run hello.kel
  • Named function declarations
  • Function types in parameter position
  • Local type inference with var
  • Expression-bodied lambdas
  • print(...) output through the runtime

Kelvra already supports structs, methods, and inferred locals:

type Counter struct {
value i32
fn reset() {
this.value = 0
}
}
fn buildCounter() Counter {
var counter = Counter()
counter.reset()
return counter
}
var current = buildCounter()
print(current.value)
  1. Read Values and Bindings and Control Flow for the core language model.
  2. Read Collections, Functions and Closures, and Types and Inheritance for the day-to-day language surface.
  3. Read Modules and Imports and Using Native Packages when the program stops being single-file.
  4. Read CLI and Debug Flags and VS Code and LSP when you want the surrounding tooling.