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
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.
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.
nullcan 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 whenTis 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.Next steps
Functions
Free functions, methods, async, and calling conventions.
Error handling
How
Result<T, E> and faults fit together.