Result<T, E>, and generics.
Scalar types
Rules
- Integer literals default to
Int64. Assign toInt32explicitly to narrow. - Fractional literals default to
Decimal.Float64requires explicit typing or conversion. - Overflow is a compile-time error when a literal cannot fit the target type.
Literals
Nullable type T?
Represents either a value of T or null.
Rules
TandT?are different types.nullmay only be assigned where the target type is nullable.- Nested nullables like
T??are not part of v0.1. - Inside a
value,T?is allowed only whenTis value-like.
Collections
All collections are immutable in v0.1.List<T>
Immutable ordered collection.
Set<T>
Immutable collection of unique values.
Map<K, V>
Immutable key-value collection.
List<T>is value-like only whenTis value-like.Set<T>is value-like only whenTis value-like.Map<K, V>is value-like only when bothKandVare value-like.
Result<T, E>
Represents an expected outcome: success with a T or expected failure with an E.
Rules
- Part of the Kairo Core prelude; no import required.
Emust be value-like.- Constructed with
Result.success(value)orResult.failure(error). - Contextually typed as
Result<T, E>in v0.1.
See Error Handling for guidance and examples.
Generic type parameters
Declared in angle brackets on a type or contract.- Type argument arity must match the declaration.
- Generic values may not store unconstrained generic parameters in value members in v0.1.
Generic contract constraints
Constrain a type parameter to a contract withT: ContractName.
- Constraint target must resolve to a contract.
- Multiple constraints and non-contract constraints are deferred.
Deferred
- Custom equality rules
- Mutable collections
- Broad numeric promotion
- Additional temporal types
T: valueand other non-contract constraints
Related
Types (language guide)
The value/object model in prose.
Declarations reference
How types are declared.
