---
slug: 11-types
title: Types & data
description: Synsema values, property access (of / dot / index), custom types, and the intentional operations that replace loops.
example_ids: [types]
---

# Types & data

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

```synsema
-- 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

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

## Custom types

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

```synsema
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:

- `apply(fn, list)` — map each item.
- `where(list, predicate)` — filter.
- `reduce(list, fn, initial)` — fold to one value.
- `sort_by(list, key_fn)`, `collect(list, "field")`, `count_where(list, predicate)`.

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