Skip to content

Getting started

Aleph needs a Rust toolchain (stable) and a C compiler (cc) for native builds.

Terminal window
git clone https://github.com/qursor-it/aleph
cd aleph
cargo install --path compiler

This installs the aleph binary. The C runtime is embedded in it, so aleph build works from any folder.

Create hello.aph:

fn main -> unit
print "hello"

Two rules show up at once: tokens are separated by exactly one space, and body lines start with exactly one space. There are no parentheses and no empty lines.

Terminal window
aleph check hello.aph # lex, parse, canonical form, types, capabilities, examples
aleph run hello.aph # interpreter
aleph build hello.aph -o hello && ./hello # native, through C
use fs.read "data"
fn words s:str -> i64
ex words "a b c" = 3
len split trim s " "
fn main -> res unit str
let text try read "data/in.txt"
do print show words text
ok nil
  • use fs.read "data" is the only file access this program has.
  • ex words "a b c" = 3 is an example: aleph check runs it and fails if it does not hold.
  • try unwraps the result of read or returns its error early.

Ask what the program can do without reading it:

Terminal window
aleph explain words.aph
capabilities: fs.read "data"
fn words s:str -> i64
effectful: no
examples: words "a b c" = 3
builtins: len split trim
fn main -> res unit str
effectful: yes
calls: words
builtins: print read show
entry: main

Remove the use line and aleph check --json answers with a diagnostic instead of guessing:

{"code":"C001","severity":"error","node":"n7","msg":"missing capability","expected":"fs.read"}