Results for “clause”

30 results, best first

  1. definitionReference › Glossary clause One case of a function. Instead of one body full of ifs, you can write a function several times, each with a pattern for the arguments it handles. The compiler checks that together the clauses cover…
  2. The language › Functions, clauses and patterns Clauses A function can be written as several clauses, each matching its arguments against patterns. Clauses are tried top to bottom, and the compiler rejects the function unless they cover every possible…
  3. Reference › Cheat sheet Clauses and patterns A clause group is a contiguous run of fns with the same name, parameter count and first-parameter type. Clauses are tried in order and must cover every case. fn fib(0): int = 0 fn fib(1): int = 1 fn…
  4. error codeError codes E0031: function header line without clauses …no body is a header line (docs, pub, contracts) for the clauses that follow it. Here no clauses follow, or the body-less fn comes after its clauses.
  5. error codeError codes E0108: clauses disagree on a parameter type The clauses of one function are tried top to bottom, so each parameter must have the same type in every clause. Here one clause declares a parameter with a different type than an earlier one.
  6. error codeError codes E0110: clauses disagree on the return type All clauses of a function return the same type. Here one clause declares a different return type than an earlier one.
  7. error codeError codes E0111: function defined twice (non-contiguous clauses or duplicate overload) …number of parameters and the same first-parameter type. Clauses of one function must be contiguous, and overloads must differ in the number of parameters or the type of the first one.
  8. error codeError codes E0401: unreachable clause or arm Arms and clauses are tried top to bottom, and the earlier ones already match every value this one could, so it can never run. That usually means the order is wrong; the fix removes it.
  9. The language › Functions, clauses and patterns Patterns The same patterns work in clauses, in match, in let, in for, and with is. pattern matches 0 "GET" 'c' true that literal _ anything x anything, bound to x Circle(r) that enum variant, binding its…
  10. definitionReference › Glossary pattern A description of the form a value can take, used to take it apart: Circle(r), [first, ..rest], (a, b), some(v). Patterns appear in match, in clauses and in let. More: Functions, clauses and patterns.
  11. The language › Functions, clauses and patterns Functions fn add(a: int, b: int): int = a + b // a one-expression body fn greet(name: str) { // no result: the return type is left out print("hi {name}") } fn classify(n: int): str { // the last expression is…
  12. Start here › Getting started A program with something to check …16.00 Circle(1.0) has area 3.14 What the program shows: Clauses. area is written as one clause per case. Delete the Rect clause and auk check reports area(Rect(_, _)) is not handled, with the clause…
  13. The language › Basics Control flow …than match numbers. They are covered with functions and clauses.
  14. The language › Basics Operators, tightest first …on your structs, enums and tuples. Next: Functions, clauses and patterns.
  15. The language › Structs, enums and shapes Enums …// Rect(2.0, 3.0) } Add a variant and every match and clause group that doesn't handle it stops compiling, each with a message naming the missing case. That is the main reason to model a closed set…
  16. Start here › A tour of Auk 2. Choices, and functions by cases …// the same, read left to right } advice is written as clauses, one per case. The compiler checks that the clauses cover every Level. Add a variant to the enum and this function stops compiling until…
  17. Tools Auk with AI coding agents …hard. The language does most of that work (exhaustive clauses, errors and effects in the types, contracts, no imports). The toolchain adds a machine-readable interface to everything.
  18. error codeError codes › E0031: function header line without clauses Common causes …forgotten = expr or { ... }. The header written after the clauses: move it above them.
  19. error codeError codes › E0108: clauses disagree on a parameter type Common causes A typo in one clause's annotation. Two different functions that happen to share a name: give them different names, or put the differing type first (overloads differ by their first parameter's type).
  20. error codeError codes › E0110: clauses disagree on the return type Common causes A typo in one clause's return type. A clause that should convert its result (str(n), float(n)). Write the return type once in a header line (fn name(n: int): str) above the clauses.
  21. error codeError codes › E0111: function defined twice (non-contiguous clauses or duplicate overload) Common causes Clauses of one function split by another function: keep them together. A function pasted twice. Overloads that differ only in a later parameter: make the first parameter differ, or rename.
  22. error codeError codes › E0401: unreachable clause or arm Common causes …specific patterns. A duplicated arm after a copy-paste. A clause fn f(n: int) placed above fn f(0).
  23. packagePackages http …handles one request per connection, and routes with Auk's clause patterns. Effects: net. Dependencies: json and url (which brings in encoding); none of them use effects. To call json.* yourself, as…
  24. Working on Auk › Compiler architecture Source layout …lexer jobs compiler/src/ast.auk the full AST: items (fn clause, struct, enum, shape, test, top-level let/imprint), patterns, expressions, types; every node has a Span compiler/src/parser.auk…
  25. Working on Auk › Compiler architecture Back end as built (compiler/src/mir/, backend.auk) …(debug builds): the function becomes a wrapper around the clause group's body. The wrapper finds the clause that matches (pattern tests and pure guards, in order), binds its names, captures the…
  26. Working on Auk › Low-level Auk (raw) 7a. As implemented (Phase 7a): what differs, and the details the sections above leave open …is an intrinsic and needs it (E0410). export fn: one clause, no type parameters, raw types only (E0419); C's calling convention as mir/layout.auk classifies it (below); external linkage under its own…
  27. Reference › Package catalog Programs and services …net A complete HTTP server, with routes written as clauses: fn route("GET", "/", _: http.server.Req): http.Resp = http.server.text(200, "hello from auk\n") fn route("GET", "/hello/" + name, r:…
  28. Tools › Auk with AI agents What an agent should use …a missing ?, a missing &, an undeclared effect, a missing clause. An agent can apply them mechanically instead of re-deriving the fix.
  29. Tools › Auk with AI agents Why the language suits generated code …type arguments at call sites, inference inside functions, clauses instead of nested conditionals. Mistakes become compile errors. A missed case, an ignored error, an unhandled none, a unit mix-up and…
  30. Tools › Editors VS Code …? or &, an undeclared effect, a misspelled name, a missing clause. Hover for the type of any expression, and signatures with their /// docs. Go to definition across modules and dependencies. Format…