# Linux / macOS
curl -fsSL https://raw.githubusercontent.com/refkinscallv/korr/main/install.sh | bash
# Windows (PowerShell)
irm https://raw.githubusercontent.com/refkinscallv/korr/main/install.ps1 | iex
Open a new terminal and check that it works with korr version. Other options
(installer files, archives, building from source), requirements and
troubleshooting are in Installation.
Create hello.krr:
let name = "world"
print("Hello, {name}!")
Run it:
korr hello.krr
Every Korr file ends in .krr. Code runs from top to bottom; there is no main
function to write.
if, for, fn, …) is
followed by lines indented by 4 spaces. No braces, no colons, no end.let x = 1 creates a variable, x = 2 changes it.
const values can never change. Using a name that does not exist is an error
before the program starts."age: " + 5 is an error. Write "age: {5}".tip: line.let items = ["apple", "banana"]
for item in items
if item.starts_with("a")
print("{item} starts with a")
else
print(item)
$ korr repl
>>> let xs = [1, 2, 3]
>>> xs.map(fn(x) => x * 10)
[10, 20, 30]
>>> fn square(n)
... return n * n
...
>>> square(12)
144
End a multi-line block with an empty line. Type exit to quit.
korr -e 'print(2 ** 10)' # run a one-liner
korr check app.krr # syntax + name check without running
korr new myapp
cd myapp
korr main.krr # open http://localhost:8080
korr test # 5 passing tests
korr build main.krr # ./main: one file, no Korr install needed to run it
The project contains:
| File | Purpose |
|---|---|
main.krr |
Routes, data model (struct Todo) and the server start |
views.krr |
HTML templates with automatic escaping |
app_test.krr |
Tests using app.request(): no network needed |
public/style.css |
Static files served at /public/... |
error[NameError]: Undefined variable 'totl'
--> shop.krr:12
|
12 | print(totl)
|
= in checkout() called from line 30
= tip: did you mean 'total'?
NameError is the error kind (you can catch errors by kind).--> shop.krr:12 is the location, followed by the source line.= in checkout() called from line 30 is the call trace.= tip: suggests a fix.| Previous: Installation | Docs index | Next: Language guide |