- What does it do?
- How does it work?
- When would I use it?
How to use this page
Browsing?
Looking something up?
match, Result, type func).Learning the language?
Need the deep spec?
Project Structure
module - declare the module a file belongs to
module - declare the module a file belongs to
.ak source file.How it works. The module line must be the first non-comment declaration in the file. Module names are PascalCase and dot-separated (Astra.Customers.Models). The module name is authoritative; file paths should align with it, but paths do not define language meaning.When to use it. Every Kairo source file needs exactly one module declaration at the top.import - bring another module into scope
import - bring another module into scope
import Astra.Data imports the module named Astra.Data. Kairo does not do wildcard imports and does not guess whether the final segment is a type name.When to use it. Any time you need to reference something declared in a different module.import ... as - alias an imported module
import ... as - alias an imported module
import type - import a specific type
import type - import a specific type
.ak source file - the Kairo file extension
.ak source file - the Kairo file extension
src/ and tests under tests/. Every .ak file must declare a module.When to use it. Every time you create a new Kairo source file.kairo.toml - the package manifest
kairo.toml - the package manifest
Visibility
public - visible outside the package
public - visible outside the package
internal - visible inside the same package (default)
internal - visible inside the same package (default)
internal is the default when no visibility is written.When to use it. For helpers, drafts, and cross-file collaborators that should not leak out of the package.private - visible to the declaring type or file
private - visible to the declaring type or file
private appears. On a member, it is scoped to the type. On a top-level declaration, it is scoped to the file.When to use it. For type-internal helpers you want to hide from the rest of the package.Type Declarations
value - declare a value type
value - declare a value type
object - declare an identity-bearing object
object - declare an identity-bearing object
var members. Immutable members must be assigned during init and cannot change afterwards.When to use it. When the concept has identity, state, or lifecycle.contract - declare a capability
contract - declare a capability
: contract conformance
: contract conformance
value or object conforms to one or more contracts.How it works. Forge verifies that all required members are present with matching signatures.When to use it. Whenever a type must satisfy a contract.enum - declare a closed set of named cases
enum - declare a closed set of named cases
enum cases have no payload.When to use it. For status, mode, category, and workflow state.Members
member field - store data on a value or object
member field - store data on a value or object
name: Type is immutable. var name: Type is mutable. Value members must be value-like.When to use it. Any time a type needs to remember data.computed property - derived member with explicit get/set
computed property - derived member with explicit get/set
get block, and optionally a set(value: Type) block. There is no shorthand syntax in v0.1.When to use it. For derived views like fullName from firstName and lastName.Callables
func - declare a function
func - declare a function
: ReturnType means the function returns no value.When to use it. Any time you need reusable behavior.instance method - behavior owned by an instance
instance method - behavior owned by an instance
func keyword, but appears inside a type body. Value methods have an immutable receiver; object methods may mutate var members.When to use it. When the behavior depends on the receiver’s state.type func - function owned by the type itself
type func - function owned by the type itself
this receiver.How it works. Sits inside a value or object body but is invoked as TypeName.function(...). Kairo intentionally does not use static.When to use it. For named factories and type-owned helpers.init - construct an object
init - construct an object
object. Required immutable members must be assigned before init completes. init cannot return a value. Exactly one primary init per object in v0.1.When to use it. Every object with required members needs one.Local Bindings
let - immutable local binding
let - immutable local binding
var only when mutation is genuinely required.var - mutable local or mutable member
var - mutable local or mutable member
var requires an explicit type in v0.1. var on a type member declares a mutable field.When to use it. When the value must change over time.this - the current instance
this - the current instance
init.How it works. Only valid inside instance methods and object init. Not available in free functions or type func.When to use it. When you need to disambiguate a member from a parameter, or make the receiver explicit.Control Flow
return - exit the current callable
return - exit the current callable
if / else - conditional branching
if / else - conditional branching
Bool. Kairo has no truthy or falsy conversions.When to use it. For simple two-way branches.match - pattern-based branching
match - pattern-based branching
else. Supported patterns in v0.1: literals, enum cases, null, type names, and else. Destructuring and guards are deferred.When to use it. When choosing between named domain states, especially enums and nullable outcomes.for - reserved keyword
for - reserved keyword
for is part of the frozen keyword vocabulary, but v0.1 does not yet ratify executable loop semantics.When to use it. Not yet. Model iteration with recursion or upcoming iteration APIs.while - reserved keyword
while - reserved keyword
for: reserved keyword, deferred executable behavior.When to use it. Not yet.Async
async func - suspendable function
async func - suspendable function
init and type declarations. The runtime for async execution is deferred to a future Pulse release.When to use it. When the callable performs I/O or other work that may suspend.await - visible suspension point
await - visible suspension point
async func. await does not unwrap Result<T, E> and does not spawn background work.When to use it. At every call site where you consume an async callable.Type System
T? - nullable type
T? - nullable type
T or null.How it works. Only single-level nullables are supported in v0.1 (no T??). A value member typed Customer? is not allowed if Customer is an object.When to use it. When absence is a legitimate state.null - the absence value
null - the absence value
true / false - boolean literals
true / false - boolean literals
Bool literal values.How it works. Boolean contexts require a Bool. Kairo does not convert other types to boolean automatically.When to use it. Wherever you need a literal truth value.Text literal - core textual type
Text literal - core textual type
Text value.How it works. Delimited by double quotes. Kairo uses Text instead of String for the core textual type.When to use it. For any inline string.numeric literal - integer and decimal literals
numeric literal - integer and decimal literals
Int64. Fractional literals default to Decimal. Float64 requires explicit typing or conversion. Overflow at compile time is a compile error.When to use it. Any inline number. Prefer Decimal for money and business math.Operators
boolean operators - not, and, or
boolean operators - not, and, or
Bool. Kairo uses word operators instead of symbols to keep boolean logic readable.When to use it. In any boolean expression.equality operators - == and !=
equality operators - == and !=
comparison operators - <, <=, >, >=
comparison operators - <, <=, >, >=
arithmetic operators - +, -, *, /
arithmetic operators - +, -, *, /
+ also concatenates Text.How it works. Operands must be compatible numeric types. Kairo does not silently promote across numeric families.When to use it. Any numeric computation.= - assignment
= - assignment
var local or a var member. Immutable let bindings and immutable members cannot be reassigned.When to use it. Every time you update a mutable binding.Construction
value construction - TypeName { field: value }
value construction - TypeName { field: value }
object construction - TypeName(arg: value)
object construction - TypeName(arg: value)
init with named arguments.How it works. Arguments are named in v0.1. There is no hidden default constructor.When to use it. Anywhere you produce a new object.Error Handling
Result<T, E> - explicit outcome type
Result<T, E> - explicit outcome type
T payload or an expected failure with an E payload.How it works. Part of the Kairo Core prelude. E must be value-like. Unexpected runtime explosions become faults, not Result values.When to use it. Whenever a callable can fail in a way callers should handle.Result.success - construct a successful Result
Result.success - construct a successful Result
Result<T, E>.How it works. Must be contextually typed as a Result in v0.1.When to use it. On the success path of any function returning Result.Result.failure - construct a failed Result
Result.failure - construct a failed Result
Result<T, E>.How it works. Payload must be value-like. Must be contextually typed as a Result.When to use it. On the failure path of any function returning Result.Result inspection - isSuccess, isFailure, value, error
Result inspection - isSuccess, isFailure, value, error
Result without pattern destructuring.How it works. result.isSuccess and result.isFailure return Bool. result.value reads the success payload; result.error reads the failure payload. Reading the wrong one is a runtime fault.When to use it. When acting on the outcome of a Result in v0.1 (destructuring patterns are deferred).Collections
List<T> - immutable ordered collection
List<T> - immutable ordered collection
T.How it works. Value-like only when T is value-like. Requires one type argument.When to use it. Ordered sequences of data.Set<T> - immutable unique collection
Set<T> - immutable unique collection
T values.How it works. Value-like only when T is value-like.When to use it. Membership tests, tag collections, distinct sets.Map<K, V> - immutable key/value collection
Map<K, V> - immutable key/value collection
K to V.How it works. Value-like only when both K and V are value-like.When to use it. Lookup tables, dictionaries of facts.Generics
generic type parameter - TypeName<T>
generic type parameter - TypeName<T>
generic contract constraint - T: ContractName
generic contract constraint - T: ContractName
Runtime
application entrypoint - where execution starts
application entrypoint - where execution starts
[application] entry. The named function must return Int32 or Result<Int32, E>. main is conventional but not required.When to use it. In every application-kind package.Pulse.Console.out.write - write to stdout without a newline
Pulse.Console.out.write - write to stdout without a newline
import Pulse.Console.When to use it. To emit output in pieces without line breaks.Pulse.Console.out.writeLine - write a line to stdout
Pulse.Console.out.writeLine - write a line to stdout
write, with a newline at the end.When to use it. For normal line-based output.Pulse.Console.error.write - write to stderr without a newline
Pulse.Console.error.write - write to stderr without a newline
out.write, but routed to the standard error stream.When to use it. To emit diagnostics or warnings.Pulse.Console.error.writeLine - write a line to stderr
Pulse.Console.error.writeLine - write a line to stderr
out.writeLine, but routed to stderr.When to use it. For error messages that should be readable line-by-line.Deferred for v0.1
These commands and features are intentionally not yet ratified as production-ready:forandwhileexecutable loop semantics- Async runtime execution and task scheduling
- Fault catching and recovery syntax
- Destructuring match patterns and match guards
- Constructor overloading and delegation
- Extension methods
- Multiple generic constraints
- Mutable collection types
- Broad numeric promotion rules
