Types
Karkain is statically typed. The compiler performs type inference, so type annotations are optional on variables, parameters, and return values.
Primitive types
int64-bit signed integer.
float6464-bit IEEE 754 double.
booltrueorfalse.stringUTF-8 byte string (length-prefixed).
Container types
arrayHomogeneous, dynamically-sized list:
[1, 2, 3].mapHomogeneous key→value table:
{"a": 1, "b": 2}.
Composite types
Language-provided carriers
These are part of the language itself, not standard-library modules. They are written bare, without type arguments:
OptionSome(v)orNone— presence/absence (no null). See Errors.ResultOk(v)orErr(e)— fallible operations (no exceptions). See Errors.int[]/string[]Element-typed arrays, used for parameter and return annotations (for example
func range(start: int, end: int) -> int[]). An unannotatedletinfers the element type from the literal.
Type annotations
Annotations are accepted but not required:
let x: int = 42
let y = 42 // inferred as int
func double(n: int): int {
return n * 2
}