Rail Examples
Twenty-two runnable programs, each verified end-to-end. Pick one and read the source — that is the fastest way to learn Rail.
- apollo2_blink — GPIO toggle on a real chip —
apollo2_blink - calculator — expression evaluator with ADTs —
calculator - closures — lambdas and higher-order functions —
closures - concurrency — fibers and channels —
concurrency - error_test — what a Rail error looks like —
error_test - fibonacci — recursion, range, map —
fibonacci - file_processor — read, write, transform files —
file_processor - fizzbuzz — the classic interview question —
fizzbuzz - hello — first Rail program —
hello - lists — cons, map, fold, filter, range —
lists - m4_fib_print — bare-metal Cortex-M4 —
m4_fib_print - m4_uart_hello — "Hi!" over UART on Cortex-M4 —
m4_uart_hello - pattern_matching — ADTs and `match` —
pattern_matching - pipes — the `|>` operator —
pipes - quicksort — functional quicksort on lists —
quicksort - string_processing — split, join, reverse, append, shell —
string_processing - tco_test — tail call optimization —
tco_test - wasm/adt — ADTs and pattern matching in WebAssembly —
wasm_adt - wasm/closure — captured locals in WASM —
wasm_closure - wasm/fib — recursive Fibonacci in WebAssembly —
wasm_fib - wasm/hello — Rail to WebAssembly —
wasm_hello - wasm/loop — GC stress test in 1 MB heap —
wasm_loop