Skip to main content
Kairo’s type system is built around one central distinction: values model facts, objects model participants. Everything else, scalars, collections, nullability, generics, follows from that idea.

Values vs. objects

value

Immutable facts with no identity. Two values with equal fields are the same value. Used for IDs, amounts, dates, coordinates.

object

Identity-bearing participants. Two objects with equal fields are still distinct. Used for entities, workflows, stateful concepts.
A value’s members must be value-like. You cannot store an object inside a value. This keeps identity-bearing state from leaking into fact-shaped types.

Scalar types

Fractional literals default to Decimal because business math should be exact. Reach for Float64 only when you know you need IEEE semantics.

Collections

Collections are immutable in v0.1. A mutable collection model is deferred.

List<T>

Immutable ordered collection.

Set<T>

Immutable unique collection.

Map<K, V>

Immutable key-value collection.
A collection is value-like only when its element (or key and value) types are value-like. Map<CustomerId, Customer> is not value-like if Customer is an object.

Nullability

Nullability is part of the type, not a hidden runtime state. Customer and Customer? are different types.
Rules:
  • null can only be assigned where the target type ends in ?.
  • Nested nullables like T?? are not part of v0.1.
  • T? in a value member is only allowed when T is value-like.

Domain types

Kairo encourages naming your domain concepts as small value types instead of primitives. This makes signatures self-documenting.

Result and outcomes

Result<T, E> is a value-like type from the Kairo Core prelude for representing expected outcomes. See Error Handling for the full model.

Contracts and generics

Contracts declare capabilities. Generic type parameters let types and contracts work over other types.
See Declarations reference for the full syntax.

Next steps

Functions

Free functions, methods, async, and calling conventions.

Error handling

How Result<T, E> and faults fit together.