Synsema docsENES

Types & data

Core values: text, number, bool, list, map, and nothing. (Plus decimal, bytes, complex and numeric array for scientific work — see Stdlib.)

types.syn
-- Doc example: types, property access, custom types, intentional operations.
intent: "doc example: types and data"

type Point
    x: number
    y: number

let demo_p be Point(3, 4)
print("Point(3,4) → x=" + text(x of demo_p) + " y=" + text(y of demo_p))

test "values + property access (of / dot / index)"
    let cfg be {"host": "localhost", "port": 8080}
    assert_eq(port of cfg, 8080)
    assert_eq(cfg.host, "localhost")
    assert_eq(cfg["port"], 8080)
    assert_eq(length([1, 2, 3]), 3)

test "custom type + positional constructor"
    let p be Point(3, 4)
    assert_eq(x of p, 3)
    assert_eq(y of p, 4)

test "intentional ops replace loops"
    let nums be [1, 2, 3, 4]
    assert_eq(apply((n) => n * 2, nums), [2, 4, 6, 8])
    assert_eq(where(nums, (n) => n > 2), [3, 4])
    assert_eq(reduce(nums, (a, b) => a + b, 0), 10)
    assert_eq(sort_by([3, 1, 2], (v) => v), [1, 2, 3])

Property access — three ways

host of config       -- natural
config.host          -- dot
config["host"]       -- index

Custom types

A type declares named fields; the constructor is positional in field order:

type Customer
    name: text
    email: text
    balance: number

let c be Customer("Ada", "ada@x.com", 500)
let who be name of c

Intentional operations (instead of loops)

Express intent and let the runtime iterate:

This reads better than a loop and is what an LLM should reach for first.