Kalandra

Learn

Types and records

A functional language for parallel and distributed programming. The next chapter of Clio.

Kalandra checks known types and infers many expression results. Ordinary unresolved or dynamic values can remain Any; they are not proof of type safety and are not accepted across a parallel boundary.

Declare structured data

A type declaration describes a record. Here Point has two Number fields. Calling Point constructs an instance, and a dot selects a field.

The params decorator declares the function parameter types. returns declares its result type. check adds runtime checks to the decorated function. Static analysis still checks known mismatches before execution.

main.kalandra

kalandra
type Point:
  Number x
  Number y

@params Point
@returns Number
@check
fn sum point: point.x + point.y

export fn main:
  point = Point 1.5 2.5
  sum point

Expected result:

text
4

Try in playground

Worker-safe types

Number retains floating-point behavior. When sent through Sia it uses an eight-byte float64 codec, preserving fractional values, negative zero, NaN and infinities.

The worker protocol also supports strings, booleans, null/void, recursively typed arrays, supported declared records, and finite supported unions. Arbitrary JavaScript objects, functions, unresolved promises and Any cannot cross the compiled parallel boundary. A return annotation cannot hide an unknown function body result.

Explicitly typed module data can be captured by a worker task as a snapshot. That does not serialize an arbitrary closure or make mutations shared.

Next: local modules