# Makori > Site: https://mako-lang.com > Longer reference: https://mako-lang.com/llms-full.txt > Repo: https://github.com/loreste/mako Version **0.2.1**. Compiled language, `.mko` sources, C backend + clang, no GC. Write new code with: `fn`, `let`, `on Type {}`, `pack` / `pull` / `export`, `hold` / `share` / `arena`, `crew` / `kick` / `join` / `fan`, `match`, `switch` / `case`. Older dual forms (`func`, `:=`, `import`, `package`) still parse; do not prefer them. See docs/IDENTITY.md if you care about the style bar. Short facts: - Generics: `fn id[T](x: T) -> T`, `struct Pair[T]`, `enum Box[T]`, bounds `fn f[T: Iface](x: T)` — all monomorphized. Write `Pair[int] { … }`. - `mut self` on methods: `fn push(mut self, v: int)` — mutations persist in caller - Multi-statement lambdas: `fn(x) { let a = x + 1; return a }` — full control flow - Stdlib in Makori: `pull "io"`, `pull "encoding/json"`, `pull "context"`, `pull "net/http"`, `pull "database/sql"`, `pull "collections"` - Tuples / multi-return: `let a, b = f()` (incl. struct elements) - Methods: `on Type { fn m(self) -> T { ... } }` - Modules: `pack name`, `pull "path"`, always qualify: `pkg.fn`, `eng.Table`, `eng.Point { x: 1 }`, `eng.Red` / `eng.Color.Green(n)` - Maps: keys `int|string|float|bool|Struct|Enum`; values same, `[]T`/`[][]T`, nested maps depth ≤3, bags `Option`/`Result` (incl. nests, channels), tuples `(T,U[,…])` (bag/chan fields), `chan[T]`; `[]Option`/`[]Result`; `maps_*`. Map monomorph C helpers are demand-driven (only used shapes). - Struct/enum `==` `!=` structural (strings by content) - Channels: `make(chan[T], n)` / `chan_open[T](n)` for int/bool/float/string/struct/enum/tuple - `chan_len` / `chan_cap` work on any `chan[T]` (not only int rings) - Kick Send: Copy, string, deep-POD structs, Option/Result/tuple of sendables, chan handles (not maps/arrays/non-POD). Prefer `chan[Struct]` for multi-field worker results. - Loops: `for i, v in range s` / `for k, v in range m` / C-style `for` - F-strings: `f"hello {name}, age {age}"` — stack-based builder, zero malloc for short strings - Format: `fmt_sprintf*` / `fmt_sprint*` for printf-style verbs - Dispatch: `match` on strings/ints/enums; `switch`/`case` on values - Parallel work: `fan(xs, fn(x) { x * x })` - Concurrency: `crew` / `kick` / `join`, channels, `select`, `actor` - `+= -= *= /= ++ --`, `a, b = b, a`, `let x = if c { a } else { b }` - `if init; cond { }` - Ownership: hold, share, arena — no GC - Errors: `Result` / `Option`, `?`, unused Result is an error - Checked math: `checked_add` / `sub` / `mul`, `would_overflow_*` - Const fn: `const fn f(n: int) -> int` with match/while/for/break/continue/strings - First-class functions: `fn` values, closures capture POD + string + struct by value - Iterator protocol: struct with `fn next(self) -> Option[T]` usable in for-range - Shutdown helpers, tracing, leak checks, crash reporting in the runtime - Release: `-O3 -flto`. WASM: `wasm32-wasip1` - Stdlib: HTTP (incl. HTTP/2), TLS, SQL, crypto, regex, UUID/ULID, channels, SIP signaling, SMTP, templates, domain storage (BTree/LSM/WAL/Bloom), … - Speed: wyhash maps, zero-copy string comparisons, compile-time constant folding, stack-based f-strings, condvar channel select, atomic HTTP conn tracking HTTP/2 note: DATA frames larger than 16384 are split automatically. Empty string `""` is a singleton — do not raw-free it. ## Install ```bash curl -fsSL https://github.com/loreste/mako/releases/latest/download/install-release.sh | bash ``` From source: `make install` → `~/.local/bin/mako` ## Quick start ```bash mako init hello --name hello cd hello mako run main.mko mako build main.mko ``` ## Hello world ```mko fn main() { print("hello from mako") print(fib(10)) } fn fib(n: int) -> int { if n <= 1 { return n } return fib(n - 1) + fib(n - 2) } ``` ## Example style ```mko pull "strings" export struct Point { x: int y: int } on Point { fn distance(self) -> int { return self.x + self.y } } fn divmod(a: int, b: int) -> (int, int) { return (a / b, a % b) } fn main() { let p = Point { x: 3, y: 4 } print(p.distance()) let q, r = divmod(17, 5) let xs = [1, 2, 3, 4] let ys = fan(xs, fn(x) { x * x }) crew t { let job = t.kick(work()) print(job.join()) } } ``` ## Core - Types: int, int8, int32, int64, uint64, float, bool, string, byte, void - Composite: []T, map[K]V (see maps above), chan[T], Option[T], Result[T, E], (T, U) - Decl: fn, struct, enum, actor, interface, const, export - Control: if/else, if-expr, if-init, while, for/in/range, switch, match, defer - Ownership: hold, share, arena - Concurrency: crew, kick, join, go, fan, channels, select - Errors: Result, Ok/Err, Option, ?, match - Units: pack, pull, export (always qualify: pkg.fn / pkg.Type) - Equality: `==`/`!=` on strings, structs, enums (structural) - Tests: `fn TestFoo() { assert_eq(1, 1) }` in `*_test.mko` ## Commands ```bash mako build file.mko mako build --release file.mko mako run file.mko mako test path/ mako fmt file.mko -w mako check file.mko mako build --target wasm32-wasip1 file.mko -o out.wasm ``` ## Stdlib (rough map) Output, strings, math, files, HTTP server/client, HTTP/2, TLS, JSON, SQLite / Postgres / MySQL / Redis, crypto (SHA/HMAC/bcrypt/scram/SRTP), base64/hex/gzip/tar/zip, regex, UUID/ULID, cookies/sessions/auth, channels (int/float/string/struct/ptr), mutex/atomics/cmap/rwmutex, event loop (epoll/kqueue), game net (UDP), SIP signaling, SMTP mail, text/html templates, domain storage (BTree/LSM/WAL/ Bloom/PageManager/SST), signals, fs watch, rate limit / circuit breaker, checked arithmetic, overflow detection, shutdown, tracing, leak checks, crash reporting, testing (assert/fuzz/property/snapshot/mock/fixture/coverage). ## Docs - https://mako-lang.com - https://mako-lang.com/docs/guide - https://mako-lang.com/docs/stdlib - https://mako-lang.com/docs/book - https://mako-lang.com/llms-full.txt