| @@ -46,9 +46,9 @@ pub fn main :: -> () / <io> { |
| 46 | 46 | **The prelude** (`std/prelude`) is always in scope. It provides the basic types (`Int`, `Float`, `String`, `Bytes`, `Bool`, `List`, `Option`, `Result`, `Order`, `Never`), the core traits (`Eq`, `Ord`, `Num`, `Semigroup`, `Show`, `Debug`, `Hash`, `Default`), and `panic`. |
| 47 | 47 | |
| 48 | 48 | **Attributes** go before an item. These exist; any other, a malformed one, or one on the wrong item is an error (`E0114`): |
| 49 | | −- `@extern(c, "symbol")`, with the options `blocking` (or `blocking(cpu)`, `blocking(io)`) and `owned`: a function without a body, implemented in C ([below](#foreign-functions-and-native-dependencies)). Every other function, apart from trait methods, has a body (`E0115`). |
| 50 | | −- `@test` and `@should_panic("text")`, on functions: [tests](#tests). |
| 51 | | −- `@derive(Trait, ...)` on a type and `@derivable` or `@derivable(f)` on a trait: [deriving](#traits). |
| 49 | +- `@extern c "symbol"`, with the options `blocking` (or `blocking cpu`, `blocking io`) and `owned`: a function without a body, implemented in C ([below](#foreign-functions-and-native-dependencies)). Every other function, apart from trait methods, has a body (`E0115`). |
| 50 | +- `@test` and `@should_panic "text"`, on functions: [tests](#tests). |
| 51 | +- `@derive Trait ...` on a type and `@derivable` or `@derivable f` on a trait: [deriving](#traits). |
| 52 | 52 | - `@thread_safe` on a type: a `Resource` of that kind may be sent to another actor. |
| 53 | 53 | - `@fip` on a function: it must update in place ([below](#functions-and-inference)). |
| 54 | 54 | - `@builtin`, only in the standard library: an abstract type (without a body) the runtime implements. |
| @@ -118,26 +118,27 @@ fn describe :: s: Showable -> String { |
| 118 | 118 | } |
| 119 | 119 | ``` |
| 120 | 120 | |
| 121 | | −- **Building** one is a call, as for any constructor: `IntLit(1) : Expr<Int>`, `Showable(42)` (it needs `Show<Int>`). As a function value (`list.map(xs, Showable)`), it takes its dictionaries along. |
| 121 | +- **Building** one is a call, as for any constructor: `IntLit(1) : Expr<Int>`, `Showable(42)` (it needs `Show<Int>`). As a function value (`list.map xs Showable`), it takes its dictionaries along. |
| 122 | 122 | - **In a `match` arm**, what the constructor says holds in that arm only: in the `IntLit` arm of `eval`, `a` is `Int`, so `n` is an `a`. A hidden type is known only by name (`b` above), with the traits of its `where`; it can't leave the arm (E0705). Match on a value whose type is known (annotate the function): `a` must be a type variable of the signature, or a known type, for the arm to tell anything about it. |
| 123 | 123 | - **Exhaustiveness** knows which constructors a type rules out: a `match` on an `Expr<Int>` needs no `BoolLit` arm (and can't have one: E0202). |
| 124 | 124 | - **Only in a `match` arm of its own** (E0215): not in a `let`, a parameter or an alternative of `|`. Neither `.field` nor `..base` work on such a constructor, and its type can't `@derive` (write the impl). The type's parameters must all be types (not effect rows or type constructors: E0214). |
| 125 | | −- **Use it for** typed syntax trees, values that carry their traits (`List<Showable>`), and actor protocols whose requests say the type of their reply: `Ask(Request<r>, Subject<r>) -> Msg`, so `ask(server, GetAge(id))` returns an `Int` (`tests/run/gadts.lse`). |
| 125 | +- **Use it for** typed syntax trees, values that carry their traits (`List<Showable>`), and actor protocols whose requests say the type of their reply: `Ask(Request<r>, Subject<r>) -> Msg`, so `ask server (GetAge id)` returns an `Int` (`tests/run/gadts.lse`). |
| 126 | 126 | |
| 127 | 127 | **Values are immutable.** Mutable state lives in a `region` (below) or in an actor. |
| 128 | 128 | |
| 129 | 129 | ## Functions and inference |
| 130 | 130 | |
| 131 | 131 | **Signatures:** |
| 132 | +- A definition's parameters follow `::` ([ADR 0061](../adr/0061-parens-free-functions.md)): `fn add :: a: Int b: Int -> Int { a + b }`. A lambda has no name and no `::`: `fn x { x + 1 }`. A parameterless function is `fn main :: -> () / <io>`, and `fn() -> T` is `fn(()) -> T`: calling it is `f ()`. |
| 132 | 133 | - A `pub fn` must have a complete signature: parameter types, result type, and effect row. |
| 133 | 134 | - Private functions and lambdas are inferred (Hindley–Milner). Hover and inlay hints in the editor show the result. |
| 134 | 135 | - Local `let`s are not generalized. |
| 135 | 136 | |
| 136 | | −**Calls** may label their arguments: `area(width: 2.0, height: 3.0)`. Labelled arguments take their named slots first, in any order, and unlabelled ones fill the remaining slots in order (Gleam's rule), so `use`'s trailing callback lands after the labelled arguments: `use <- guard(when: cond, value: v)`. |
| 137 | +**Calls** may pass arguments by label ([ADR 0061](../adr/0061-parens-free-functions.md)): a parameter declared `~width` at the definition is filled by `~width: 2.0` (or the `~width` pun) at the call, in any order; unlabelled arguments fill the unlabelled slots in order. A function is curried: applying it to fewer arguments than its arrow takes is the function of the rest. `use`'s callback is the final, unlabelled argument: `use v <- f ~when: cond x` is `f ~when: cond x (fn v { rest })`. |
| 137 | 138 | |
| 138 | 139 | **Tail calls are guaranteed** to run in constant stack, whether the callee is the function itself, another function, or a closure. Recursion is the way to loop. |
| 139 | 140 | |
| 140 | | −**Tail recursion modulo cons** ([ADR 0039](../adr/0039-trmc.md)): a function whose recursive call's result goes straight into a constructor or tuple it returns, as `[f(x), ..map(rest, f)]` does, also runs in constant stack. The constructor is built first, with a hole that the recursive call fills. That covers std's `map`, `filter`, `append`, `zip` and `zip_with`, and functions of your own of that shape: one or more constructors around the call, each in a field of the next, with nothing else between the call and the return. It needs the recursive result in the same field everywhere in the function; mutual recursion and `n + f(x)` still use the stack. |
| 141 | +**Tail recursion modulo cons** ([ADR 0039](../adr/0039-trmc.md)): a function whose recursive call's result goes straight into a constructor or tuple it returns, as `[f x, ..map rest f]` does, also runs in constant stack. The constructor is built first, with a hole that the recursive call fills. That covers std's `map`, `filter`, `append`, `zip` and `zip_with`, and functions of your own of that shape: one or more constructors around the call, each in a field of the next, with nothing else between the call and the return. It needs the recursive result in the same field everywhere in the function; mutual recursion and `n + f x` still use the stack. |
| 141 | 142 | |
| 142 | 143 | **In-place updates** ([ADR 0040](../adr/0040-perceus-v2.md)): when a function matches a value it holds the only reference to, the native backend reuses the value's cells for the cells the function builds, instead of freeing one and allocating another. That works for constructors, tuples and record updates (`State(..s, count: n)` updates `s`'s cell), and a function may hand a cell to a function it calls that builds one of the same size. Shared values are copied, so this never changes results. |
| 143 | 144 | |
| @@ -168,8 +169,8 @@ fn sum_to :: n: Int acc: Int -> Int { |
| 168 | 169 | - `e` must have the function's result type. `return e` itself never produces a value (its type is `Never`), so it fits anywhere: `let x = if ok { 1 } else { return 0 }`. |
| 169 | 170 | - It works from the function's blocks, `if`s and `match` arms, and from inside a `use` callback or a `defer`, `handle` or `region` body. From those, it leaves through the code in between: `defer` cleanups run, and a `handle`'s `return` clause doesn't. |
| 170 | 171 | - A `use` callback can `return` only if the function given it accepts the callback's effects (`fn(a) -> b / <e>`), so the return can pass through it. Like a handler (ADR 0010), the callback can't outlive the `use`: returning or storing it is an error. |
| 171 | | −- It can't leave from a lambda, a capture (`f(_)`), a handler clause or a `defer` cleanup (E0119): those may run after the function returned. |
| 172 | | −- `return f(x)` is a tail call. |
| 172 | +- It can't leave from a lambda, a capture (`f _`), a handler clause or a `defer` cleanup (E0119): those may run after the function returned. |
| 173 | +- `return f x` is a tail call. |
| 173 | 174 | |
| 174 | 175 | ```louise |
| 175 | 176 | fn first_admin :: users: List<User> -> Option<User> { |
| @@ -182,9 +183,9 @@ fn first_admin :: users: List<User> -> Option<User> { |
| 182 | 183 | ``` |
| 183 | 184 | |
| 184 | 185 | **Sugar for calls**, as in Gleam ([ADR 0023](../adr/0023-pipe-placeholders-and-capture.md)): |
| 185 | | −- **Pipes:** `x |> f(y)` is `f(x, y)`, and `x |> f` is `f(x)`. To pipe into another argument, mark it with `_`: `x |> f(y, _)` is `f(y, x)`, and `x |> f(label: _)` works too. The left side is evaluated first. |
| 186 | | −- **Captures:** a call with a `_` argument is a function of that argument: `add(1, _)` is `fn(v) { add(1, v) }`, as in `list.map(xs, add(1, _))`. The callee and the other arguments are evaluated each time the function is called. A call has at most one `_` (`E0116`). |
| 187 | | −- **`use`:** `use a <- f(x)` passes the rest of the block to `f` as a callback: `f(x, fn(a) { rest })`. |
| 186 | +- **Pipes:** `x |> f y` is `f x y`, and `x |> f` is `f x`. To pipe into another argument, mark it with `_`: `x |> f y _` is `f y x`, and `x |> f ~label: _` works too. The left side is evaluated first. |
| 187 | +- **Captures:** a call with a `_` argument is a function of that argument: `add 1 _` is `fn v { add 1 v }`, as in `list.map xs (add 1 _)`. The callee and the other arguments are evaluated each time the function is called. A call has at most one `_` (`E0116`). |
| 188 | +- **`use`:** `use a <- f x` passes the rest of the block to `f` as its last argument: `f x (fn a { rest })`. |
| 188 | 189 | |
| 189 | 190 | ## Pattern matching |
| 190 | 191 | |
| @@ -215,9 +216,9 @@ fn describe :: xs: List<Int> -> String { |
| 215 | 216 | - **A panic:** a bug. It stops the actor, and it is not part of the function's type. |
| 216 | 217 | - **An effect:** when the handler, chosen by the caller, decides what failing means. |
| 217 | 218 | |
| 218 | | −**Chaining:** `use v <- result.try(r)` continues with `v` on `Ok`, and returns the `Error` otherwise. `std/result` also has `map`, `map_error`, `replace_error`, `flatten`, `unwrap_or`, `unwrap_or_else`, `expect`, `to_option`, `all` and `values`, and `option.to_result` turns absence into an error. |
| 219 | +**Chaining:** `use v <- result.try r` continues with `v` on `Ok`, and returns the `Error` otherwise. `std/result` also has `map`, `map_error`, `replace_error`, `flatten`, `unwrap_or`, `unwrap_or_else`, `expect`, `to_option`, `all` and `values`, and `option.to_result` turns absence into an error. |
| 219 | 220 | |
| 220 | | −**Combining:** `list.try_map(xs, f)` maps while `f` succeeds and stops at the first `Error`. `result.map2(a, b, f)` and `option.map2` combine two values, `result.or(a, b)` and `option.or` take the first that worked (`lazy_or` computes the fallback only if needed), and `list.flat_map`, `zip`, `unzip` and `zip_with` work on lists. |
| 221 | +**Combining:** `list.try_map xs f` maps while `f` succeeds and stops at the first `Error`. `result.map2 a b f` and `option.map2` combine two values, `result.or a b` and `option.or` take the first that worked (`lazy_or` computes the fallback only if needed), and `list.flat_map`, `zip`, `unzip` and `zip_with` work on lists. |
| 221 | 222 | |
| 222 | 223 | **No monad hierarchy, no symbolic operators** ([ADR 0026](../adr/0026-functors-and-monads-in-std.md)). The standard library has no `Functor` or `Monad` trait, and no `<$>`, `>>=` or `<|>`. Effects cover what Haskell does with monads (state, configuration, logging, early exit, nondeterminism), `use` replaces `do`, and each type has named functions. |
| 223 | 224 | |
| @@ -254,9 +255,9 @@ fn twice :: x: a -> String where Describe<a> { |
| 254 | 255 | } |
| 255 | 256 | ``` |
| 256 | 257 | |
| 257 | | −**Operators are trait methods:** `==` and `!=` use `Eq`; `<`, `>`, `<=` and `>=` use `Ord`; `+`, `-`, `*`, `/`, `%` and unary `-` use `Num`; `<>` uses `Semigroup` ([ADR 0027](../adr/0027-semigroup.md)), whose method is `append`. The prelude implements `Semigroup` for `String`, `List` and `Bytes` (one value, then the other) and for `Order`, where `<>` breaks ties: `compare(a.last, b.last) <> compare(a.first, b.first)` compares by last name, then first name. Both sides of `<>` have one type, so `"total: " <> 3` is an error: write `"total: {3}"`. |
| 258 | +**Operators are trait methods:** `==` and `!=` use `Eq`; `<`, `>`, `<=` and `>=` use `Ord`; `+`, `-`, `*`, `/`, `%` and unary `-` use `Num`; `<>` uses `Semigroup` ([ADR 0027](../adr/0027-semigroup.md)), whose method is `append`. The prelude implements `Semigroup` for `String`, `List` and `Bytes` (one value, then the other) and for `Order`, where `<>` breaks ties: `compare a.last b.last <> compare a.first b.first` compares by last name, then first name. Both sides of `<>` have one type, so `"total: " <> 3` is an error: write `"total: {3}"`. |
| 258 | 259 | |
| 259 | | −**String interpolation** ([ADR 0034](../adr/0034-string-interpolation.md)): in a string literal, `{e}` is `show(e)` and `{e:?}` is `debug(e)`, with the prelude's `Show` and `Debug`. A hole holds any expression; the parts are joined in one allocation. `\{` and `\}` are literal braces. |
| 260 | +**String interpolation** ([ADR 0034](../adr/0034-string-interpolation.md)): in a string literal, `{e}` is `show e` and `{e:?}` is `debug e`, with the prelude's `Show` and `Debug`. A hole holds any expression; the parts are joined in one allocation. `\{` and `\}` are literal braces. |
| 260 | 261 | |
| 261 | 262 | ```louise |
| 262 | 263 | fn summary :: name: String xs: List<Int> -> String { |
| @@ -344,13 +345,13 @@ fn describe :: c: c -> String where Container<c>, Show<Elem<c>> { |
| 344 | 345 | |
| 345 | 346 | - **Defining.** Every impl defines each associated type of its trait exactly once (E0406, E0407), and the trait defines none (E0120). A definition uses the impl's type variables (and its own parameters), and may itself be a projection on them: `type Elem = Elem<c>` in `impl Container<Nested<c>> where Container<c>`. A projection on anything else could be computed forever (E0415). |
| 346 | 347 | - **Using.** `Elem<List<Int>>` is `Int`: a projection on a named type is computed from its impl. A projection on a type variable needs the trait in the `where` clause (E0402), and stays as it is: `Elem<c>` is a type of its own, like a type variable. It does not tell what `c` is, so a variable that appears only inside projections is an error (E0403). |
| 347 | | −- **Bindings** say what a projection is, in a `where` clause: `fn total(c: c) -> Int where Container<c, Elem = Int>`. In the body `Elem<c>` is `Int`, and every call must agree. A binding may be to a type variable (`Container<c, Elem = e>, Show<e>`), which `c` then determines. A constructor's bindings hold in the arms that match it (ADR 0041). Bindings that contradict each other, refer to themselves, or contradict an impl are errors (E0416). |
| 348 | | −- **Inference** waits for a projection's arguments: in `let x: Option<Int> = first(c)`, `Elem<c> = Int` is decided once `c` is known. An unannotated function keeps what is left as part of its type: `fn(a) -> Option<Int> where Container<a, Elem = Int>`. A `match` arm's knowledge of a type (ADR 0041) is used only in that arm. What nothing decides needs an annotation (E0403). |
| 348 | +- **Bindings** say what a projection is, in a `where` clause: `fn total :: c: c -> Int where Container<c, Elem = Int>`. In the body `Elem<c>` is `Int`, and every call must agree. A binding may be to a type variable (`Container<c, Elem = e>, Show<e>`), which `c` then determines. A constructor's bindings hold in the arms that match it (ADR 0041). Bindings that contradict each other, refer to themselves, or contradict an impl are errors (E0416). |
| 349 | +- **Inference** waits for a projection's arguments: in `let x: Option<Int> = first c`, `Elem<c> = Int` is decided once `c` is known. An unannotated function keeps what is left as part of its type: `fn(a) -> Option<Int> where Container<a, Elem = Int>`. A `match` arm's knowledge of a type (ADR 0041) is used only in that arm. What nothing decides needs an annotation (E0403). |
| 349 | 350 | - **Own parameters.** `type Mapped<x>` takes parameters of its own, written after the trait's: `Mapped<c, x>`. They are types (not type constructors), and a projection is always fully applied. A binding of one quantifies them: `where Mappable<c, Mapped<y> = List<y>>` says mapping `c` gives a list whatever `y` is. Every call must satisfy it for every `y`, and its parameters may not reuse the signature's names (E0416). |
| 350 | 351 | - **Not allowed:** as a constructor's index (E0214, ADR 0041), and in `@derivable` traits (E0412). |
| 351 | 352 | - **`Send`** looks through projections: `Subject<Elem<c>>` needs `where Send<Elem<c>>` unless `c` is known. |
| 352 | 353 | |
| 353 | | −**Deriving:** `@derive(Trait, ...)` on a type implements traits marked `@derivable`. The prelude's are `Eq`, `Ord`, `Show` (for display), `Debug` (Rust-like, with quoted strings), `Hash` and `Default`. A derived impl requires the trait of the type's parameters, and every field's type must implement it. |
| 354 | +**Deriving:** `@derive Trait ...` on a type implements traits marked `@derivable`. The prelude's are `Eq`, `Ord`, `Show` (for display), `Debug` (Rust-like, with quoted strings), `Hash` and `Default`. A derived impl requires the trait of the type's parameters, and every field's type must implement it. |
| 354 | 355 | |
| 355 | 356 | **Your own derivable traits** ([ADR 0019](../adr/0019-user-defined-derives.md)) name a **derive function**. It receives the value seen through its constructor, with each field already converted by the trait's method: |
| 356 | 357 | |
| @@ -378,9 +379,9 @@ pub type Tree |
| 378 | 379 | ``` |
| 379 | 380 | |
| 380 | 381 | - `Constructor(name, index, fields)` and `Field(label, value)` come from the prelude. `label` is `""` for positional fields. |
| 381 | | −- **The trait** has one parameter and one method `fn m(x: a) -> R`, where `R` has no type variables and the method has no effects. |
| 382 | +- **The trait** has one parameter and one method `fn m :: x: a -> R`, where `R` has no type variables and the method has no effects. |
| 382 | 383 | - **The derive function** has type `fn(Constructor<R>) -> R`, is total, and is in scope where the trait is declared. |
| 383 | | −- **Elsewhere:** derive a trait of another module with `@derive(module.Trait)`. |
| 384 | +- **Elsewhere:** derive a trait of another module with `@derive module.Trait`. |
| 384 | 385 | |
| 385 | 386 | ## Effects |
| 386 | 387 | |
| @@ -519,7 +520,7 @@ An expression starting with `<tag` is an HTML literal of type `Element<msg>`; `H |
| 519 | 520 | |
| 520 | 521 | **Attributes** are strings, Ints, Bools (boolean attributes, present iff true), or `Option<String>`s (`None` leaves the attribute out). |
| 521 | 522 | |
| 522 | | −**Components:** an Uppercase or dotted tag calls a function: `<Card title="x">...</Card>` is `card(title: "x", children: [...])`. |
| 523 | +**Components:** an Uppercase or dotted tag calls a function: `<Card title="x">...</Card>` is `card(title: "x", children: [...])` — a component call is constructor-like: its props fill the component's parameters by name (ADR 0061). |
| 523 | 524 | |
| 524 | 525 | **Rendering:** `html.render` produces the markup. |
| 525 | 526 | |
| @@ -584,7 +585,7 @@ fn relay :: to: Subject<m> message: m -> () / <proc> where Send<m> { |
| 584 | 585 | ``` |
| 585 | 586 | |
| 586 | 587 | **Functions** say whether they can be sent: `send fn(a) -> b` is a function whose captures can be. |
| 587 | | −- A closure that is sent (spawned, passed as a `send fn`, sent as a message) may capture only sendable values, and no handler of where it was written: `process.spawn(fn() { process.send(reply, n) })` is fine, a closure capturing a `Ref` is an error (E0704). |
| 588 | +- A closure that is sent (spawned, passed as a `send fn`, sent as a message) may capture only sendable values, and no handler of where it was written: `process.spawn fn { process.send reply n }` is fine, a closure capturing a `Ref` is an error (E0704). |
| 588 | 589 | - `spawn`'s body, `actor.start`'s handler, `supervisor.Child`'s start function and `std/http`'s handler are `send fn`. |
| 589 | 590 | - A plain `fn` parameter accepts any function, so the body cannot send it: write `send fn` to. A plain `fn` in a result or a field holds any function, so a type with one is not `Send`. |
| 590 | 591 | - What `@extern` code hides is still refused by the runtime when sent: the sender crashes. |
| @@ -595,7 +596,7 @@ fn relay :: to: Subject<m> message: m -> () / <proc> where Send<m> { |
| 595 | 596 | |
| 596 | 597 | **Panics:** a panic crashes only its actor ("let it crash"). Recoverable errors use `Result` or an effect. |
| 597 | 598 | |
| 598 | | −For the optimiser ([ADR 0043](../adr/0043-a-core-optimiser.md)), a crash is observable — a monitor sees its message — so a pipeline stage that can panic is never fused, and a run that finishes normally computes the same value with or without optimisation, on both back ends. *Divergence* is imprecise, though: a pure stage that loops forever hangs fused or not, and `length(map(xs, f))` never runs `f` — a stage that is pure, cannot panic, and is only dropped. |
| 599 | +For the optimiser ([ADR 0043](../adr/0043-a-core-optimiser.md)), a crash is observable — a monitor sees its message — so a pipeline stage that can panic is never fused, and a run that finishes normally computes the same value with or without optimisation, on both back ends. *Divergence* is imprecise, though: a pure stage that loops forever hangs fused or not, and `length (map xs f)` never runs `f` — a stage that is pure, cannot panic, and is only dropped. |
| 599 | 600 | |
| 600 | 601 | ```louise |
| 601 | 602 | import std/process.{type proc} |
| @@ -609,9 +610,9 @@ pub fn main :: -> () / <io, proc> { |
| 609 | 610 | |
| 610 | 611 | ## Foreign functions and native dependencies |
| 611 | 612 | |
| 612 | | −An `@extern(c, "symbol")` function without a body calls C ([ADR 0005](../adr/0005-ffi.md)): |
| 613 | +An `@extern c "symbol"` function without a body calls C ([ADR 0005](../adr/0005-ffi.md)): |
| 613 | 614 | - the C side uses `louise_rt.h`'s convention: borrowed arguments, an owned result; |
| 614 | | −- `blocking` runs the call on a thread pool while the actor waits: `blocking(cpu)` (what plain `blocking` means) for calls that keep a core busy, such as hashing, on a small pool (`LOUISE_BLOCKING_CPU_THREADS`, default half the cores, at most 4); `blocking(io)` for calls that mostly wait, on a larger one (`LOUISE_BLOCKING_IO_THREADS`, default 16). `std/runtime.blocking_stats()` tells how many calls run and wait on each ([ADR 0005, Revision 2](../adr/0005-ffi.md#revision-2--2026-10-23-blocking-pools-issue-305)); |
| 615 | +- `blocking` runs the call on a thread pool while the actor waits: `blocking cpu` (what plain `blocking` means) for calls that keep a core busy, such as hashing, on a small pool (`LOUISE_BLOCKING_CPU_THREADS`, default half the cores, at most 4); `blocking io` for calls that mostly wait, on a larger one (`LOUISE_BLOCKING_IO_THREADS`, default 16). `std/runtime.blocking_stats ()` tells how many calls run and wait on each ([ADR 0005, Revision 2](../adr/0005-ffi.md#revision-2--2026-10-23-blocking-pools-issue-305)); |
| 615 | 616 | - `Resource<t>` (`std/ffi`) wraps a foreign pointer with a finalizer. Mark the kind type `t` with `@thread_safe` when the C side may be used from any thread; only then may the resource be sent to another actor (the C side must also create it with `thread_safe`). |
| 616 | 617 | - A parameter of function type is a *callback* C may call during the call ([ADR 0015](../adr/0015-c-callbacks-and-bindings.md)). It runs in the calling actor, may perform `<ffi>` at most, and a `blocking` extern cannot take one (`E0113`). If it panics, the actor stops once the C call returns. |
| 617 | 618 | - `louise bindgen header.h --lse src/lib.lse --c csrc/bindings.c` generates the declarations and their C shim for a header's simple functions, and reports what it skips. `examples/qsort` binds a C library this way, with a comparator. |
| @@ -703,7 +704,7 @@ A compiler that does not satisfy it stops with an error naming the package, the |
| 703 | 704 | |
| 704 | 705 | ## Tests |
| 705 | 706 | |
| 706 | | −`@test` marks a test function, next to the code or under `test/`. `@should_panic("text")` expects a panic. |
| 707 | +`@test` marks a test function, next to the code or under `test/`. `@should_panic "text"` expects a panic. |
| 707 | 708 | - `louise test` runs them in the interpreter, each in isolation. In a package it runs the package's own tests, in `src/` and `test/`, and not its dependencies'. |
| 708 | 709 | - `louise test --native` compiles them; packages with native dependencies need it. |
| 709 | 710 | - `louise test src/util.lse` runs the tests of one module only. |
| @@ -724,7 +725,7 @@ fn sums :: { |
| 724 | 725 | | `std/string` | `length`, `join`, `concat`, `split`, `chars`, `trim`, `to_lower`, `to_int` (a `Result`), `starts_with`, ... | |
| 725 | 726 | | `std/bytes` | `Bytes`: `length`, `get`, `slice`, `concat`, UTF-8 conversions, and a `Builder` that appends in place when unique ([ADR 0012](../adr/0012-bytes-and-http.md)) | |
| 726 | 727 | | `std/list`, `std/option`, `std/result` | Lists, optional values and results, and their combinators ([Errors](#errors)) | |
| 727 | | −| `std/iter` | Lazy iterators (`iter.range(1, n) |> iter.map(f) |> iter.fold(0, add)` compiles to one loop; [ADR 0043](../adr/0043-a-core-optimiser.md), issue #199) | |
| 728 | +| `std/iter` | Lazy iterators (`iter.range 1 n |> iter.map f |> iter.fold 0 add` compiles to one loop; [ADR 0043](../adr/0043-a-core-optimiser.md), issue #199) | |
| 728 | 729 | | `std/array` | `Array<a>`: `from_list`, `to_list`, `length`, `get`, `set`, `push`, `slice`, `map`, `fold`; `set` and `push` update a unique array in place ([ADR 0014](../adr/0014-arrays-and-bigint.md)) | |
| 729 | 730 | | `std/dict` | Persistent ordered maps | |
| 730 | 731 | | `std/collection` | `Collection<c>`, with the element type `Elem<c>` ([ADR 0047](../adr/0047-associated-types.md)), for `List`, `Array`, `Dict` (`(k, v)`) and `Bytes` (`Int`): `size`, `fold`, `to_list`, `iter`, and the generic `is_empty`, `count`, `contains` and `sum` | |
| @@ -732,7 +733,7 @@ fn sums :: { |
| 732 | 733 | | `std/html` | `Element`, `Html`, `text`, `raw`, `render`, `escape` | |
| 733 | 734 | | `std/template` | Tagged templates ([ADR 0048](../adr/0048-tagged-templates.md)): `Template` and `Hole` for user-defined templaters, and the compiled `pug`, `html` and `xml` tags ([ADR 0057](../adr/0057-compiled-std-templaters.md)) | |
| 734 | 735 | | `std/process`, `std/actor`, `std/supervisor` | Actors and OTP: `process.stop` and the `Shutdown` reason; supervisors with a restart window (`Spec`), child kinds (`Permanent`, `Transient`, `Temporary`) and an ordered shutdown; `supervisor.application`, which `[application]` uses ([ADR 0060](../adr/0060-signals-and-applications.md)) | |
| 735 | | −| `std/net`, `std/http` | TCP on `Bytes`, and an HTTP/1.1 server with keep-alive and chunked request bodies (native programs). `http.serve_with` takes `Settings`: idle, head and write timeouts, a request body limit (413 beyond it), and a limit on open connections; start from `Settings(..http.defaults(), ...)`. `net.peer(conn)` and `http.peer(req)` give the client's address, `http.client_address(req, trusted)` the client's through trusted proxies ([ADR 0012, Revision 4](../adr/0012-bytes-and-http.md#revision-4--2026-10-23-the-clients-address)) | |
| 736 | +| `std/net`, `std/http` | TCP on `Bytes`, and an HTTP/1.1 server with keep-alive and chunked request bodies (native programs). `http.serve_with` takes `Settings`: idle, head and write timeouts, a request body limit (413 beyond it), and a limit on open connections; start from `Settings(..http.defaults (), ...)`. `net.peer conn` and `http.peer req` give the client's address, `http.client_address req trusted` the client's through trusted proxies ([ADR 0012, Revision 4](../adr/0012-bytes-and-http.md#revision-4--2026-10-23-the-clients-address)) | |
| 736 | 737 | | `std/http/cookie` | Cookies (RFC 6265): `cookies` and `cookie` read a request's `Cookie` headers; `SetCookie` (`new`'s defaults are `Path=/`, `Secure`, `HttpOnly`, `SameSite=Lax`), `to_header`, `set_cookie` and `expire` build `Set-Cookie` ones | |
| 737 | 738 | | `std/int`, `std/float`, `std/u64` | Bit operations on `Int`; `Float` conversions and IEEE 754 bits; `U64`, unsigned 64-bit integers that wrap ([ADR 0035](../adr/0035-numbers-bits-and-u64.md)) | |
| 738 | 739 | | `std/time` | The `clock` effect, `Timestamp`, `Duration`, the UTC calendar, RFC 3339 ([ADR 0036](../adr/0036-clock-and-random-effects.md)) | |
| @@ -741,6 +742,6 @@ fn sums :: { |
| 741 | 742 | | `std/runtime` | The runtime's state: `blocking_stats`, the blocking pools' sizes, running and queued calls, for back-pressure | |
| 742 | 743 | | `std/file` | Whole-file reads and writes (`read`, `write`, `exists`, `size`, `list_dir`), on the blocking pool ([ADR 0049](../adr/0049-std-file.md)) | |
| 743 | 744 | | `std/crypto`, `std/base64` | SHA-256, HMAC-SHA-256, PBKDF2-HMAC-SHA-256 (over `ring`), and base64 ([ADR 0050](../adr/0050-scram-primitives.md)) — what SCRAM needs | |
| 744 | | −| `std/msgpack` | MessagePack: `Value`, `write`/`read`, and the `ToMsgPack`/`FromMsgPack` traits with impls for the std types; `@derive(ToMsgPack)` works, the decoder derive is [ADR 0051](../adr/0051-msgpack.md) | |
| 745 | +| `std/msgpack` | MessagePack: `Value`, `write`/`read`, and the `ToMsgPack`/`FromMsgPack` traits with impls for the std types; `@derive ToMsgPack` works, the decoder derive is [ADR 0051](../adr/0051-msgpack.md) | |
| 745 | 746 | | `std/tls` | TLS clients, verified by default ([ADR 0038](../adr/0038-tls-client.md)); `std/io`'s `Stream` trait covers TCP and TLS streams | |
| 746 | 747 | | `std/test` | Assertions | |