Values and types

This page lists every kind of value Garo has, and the rule that decides which operations a value accepts. The syntax page shows how each one is written. Here we look at what each one is.

The base types

A base type is the type of one element: one number, one label, one date. Garo has eight.

TypeExamplesWhat it is
Int42, -7a whole number of any size
Float3.5, ∞a 64-bit floating-point number
Booltrue, falsea truth value, not a number
Sym`easta label: compared, sorted, grouped, never taken apart
Text"hello"a piece of text, as one element
DateDate [2026, 11, 27]a calendar day
DurationDays 30a number of days
an enum`s, after declaring Sizea label from a closed set you declare

Besides these, any element can be absent: `none, a missing value. Absence is covered below.

Int

An Int is a whole number with no size limit. It never overflows.

2 × 4611686018427387904 × 4
⇒ 36893488147419103232Try it

Float

A Float is a 64-bit floating-point number, the float64 of NumPy. It is written with a digit on both sides of the point. ∞ and -∞ are Floats too. Float arithmetic rounds, as it does everywhere:

0.1 + 0.2
⇒ 0.30000000000000004Try it

Garo has no NaN. An operation with no defined Float result is an error instead, of kind domain:

∞ - ∞
⇒ !domain: - has no defined Float result here (∞ - ∞, 0 × ∞): Garo has no NaNTry it

Ints and Floats together

Ints and Floats are the only two types that mix. When they meet, the result is a Float. An array with both is an array of Floats:

[1, 2.5]
⇒ [1.0, 2.5]Try it

÷ always gives a Float, even when both sides are Ints and the division is exact:

7 ÷ 7
⇒ 1.0Try it

A Float never becomes an Int on its own. Comparison is the one place they meet without converting: an Int and a Float are equal when their exact values are equal.

2 = 2.0
⇒ trueTry it

Bool

A Bool is true or false. It is not a number: there is no 0 or 1 behind it, so a Bool cannot be added or summed. Comparisons give Bools, and 깃 (flip) negates them.

깃 [true, false]
⇒ [false, true]Try it

To count the trues, select their positions first, then count: 담 닞 mask. The functions tutorial shows more.

Sym

A Sym is an atomic label: a backquote, then a name. Use it for categories, such as regions, statuses or product codes. A Sym can be compared for equality and sorted alphabetically, and nothing else. In NumPy terms it is a categorical value; in SQL, a short code you GROUP BY.

`a < `b
⇒ trueTry it

Two Syms cannot be added:

`a + `b
⇒ !type: + between Sym and Sym: no implicit conversion (D45)Try it

Text

Text is written in double quotes. A text is one element, however long, so an array of texts is a plain vector. Texts compare and sort by character code. Their sum is their concatenation:

닫 ["ab", "cd"]
⇒ "abcd"Try it

Text has no arithmetic otherwise. "a" + "b" is a type error: concatenation is 닫, not +. A Sym and a Text are different types, even when they spell the same word. Taking a text apart into characters is not available yet.

Date and Duration

A date is made by the function Date from a year, a month and a day. A span of days is made by Days. There are no date literals, because 2026-11-27 already reads as two subtractions.

(Date [2026, 12, 25]) - Date [2026, 11, 27]
⇒ Days 28Try it

A date minus a date is a Duration. A date plus a Duration is a date. Two dates cannot be added. Durations add, scale by an Int, and sum:

닫 [Days 1, Days 2]
⇒ Days 3Try it

A date that does not exist is a domain error, not the next valid day:

Date [2026, 2, 30]
⇒ !domain: there is no date 2026-2-30Try it

The mean of dates is a date, and the mean of Durations is a Duration. Both round down to a whole day.

Enums

An enum is a closed set of Syms that you declare at the top of a program. Its order is the order you wrote. The enum's name, used as a function, turns a position into a label:

enum Size = `s | `m | `l
[Size 0, Size 2]
⇒ [`s, `l]Try it

An enum's labels sort by declaration order, not alphabetically:

enum Size = `s | `m | `l
산 (Size기 [2, 0, 1])
⇒ [`s, `m, `l]Try it

An enum value is equal to the Sym of the same name. Two different enums do not mix. Grouping by an enum gives one group per declared label, in order, including empty ones:

enum Size = `s | `m | `l
첮 (Size기 [2, 2, 0]) [10, 20, 30]
⇒ Partition {`s: [2], `m: [], `l: [0, 1]}Try it

The enum's name must start with a capital letter. Its labels must be distinct, and `none cannot be one of them, since it already means absent.

Absence

`none marks a missing element. Any element type can be absent: an array of Ints with a hole is still an array of Ints.

[1, `none] + 10
⇒ [11, `none]Try it

Arithmetic with an absent value gives an absent value, and so does an aggregate over a lane with a hole. Asking for something that is not there, such as a position past the end, also gives `none rather than an error. 닢 skips absent values, and 깊 fills them. The tables and absence tutorial covers the details.

The mean, maximum and minimum of nothing are absent too. The sum of nothing is 0, and the product of nothing is 1:

닫 []
⇒ 0Try it

Arrays and rank

Every value in Garo is an array. A single number is an array with no axes, called a scalar. A vector has one axis, a matrix has two, and so on. The number of axes is the array's rank.

RankNameExample
0scalar5
1vector[1, 2, 3]
2matrix[[1, 2], [3, 4]]
33-tensor[[[1]], [[2]]]

All the elements of an array have one type. Arrays are rectangular: every row of a matrix has the same length. A ragged array is a type error:

[[1, 2], [3]]
⇒ !type: a ragged array: its items have different shapes, and Garo arrays are rectangular (D45)Try it

The shape of an array is its length along each axis. [[1, 2, 3], [4, 5, 6]] has shape 2 by 3. Rank is part of a value's type. Lengths are not: they are data. This difference decides which error you get when two arrays do not fit, as the type rule explains.

A sign between a scalar and an array applies the scalar to every element, as broadcasting does in NumPy:

[[1, 2], [3, 4]] + 10
⇒ [[11, 12], [13, 14]]Try it

Two arrays of the same shape pair element by element. No other shapes broadcast on their own. To align two different shapes, use the lift family ㅂ, which makes the alignment policy visible: extend, clip, tile or interpolate.

+박 [1, 2] [10]
⇒ [11, `none]Try it

[] is an empty array. It has no element type yet, and takes the type of whatever it meets.

Keyed-arm literals

A keyed-arm literal is a block whose arms are key ⇒ result. It is a function: given a value, it takes the arm whose key matches. It is Garo's only way to branch.

enum Size = `s | `m | `l
{ `s ⇒ 5, `m ⇒ 2, `l ⇒ 1 }기 (Size기 [0, 2, 1])
⇒ [5, 1, 2]Try it

The keys come from the value's type:

  • an enum's labels;
  • `true and `false for a Bool;
  • `ok and `err for a Try result;
  • `some and `none for any value that may be absent.

The arms must cover every key of that type. If they do not, the literal is a type error:

{ `true ⇒ 0 } false
⇒ !type: no arm for `false, and no else arm: the arms must cover Bool (D23.5)Try it

An arm whose left side is a lowercase name, such as other or _, is the else arm: it takes every key no other arm names. Open Syms, which have no declared set, always need one:

{ `a ⇒ `z, k ⇒ k } `b
⇒ `bTry it

More rules:

  • A key may appear only once, and there is at most one else arm.
  • `some v ⇒ v names the value the key carries. For a Try result, `ok v names the result and `err k the error's kind.
  • An absent value passes through unchanged, unless there is a `none arm.
  • Every arm's result must have one type. An arm that gives an Int and an arm that gives a Sym do not fit together.
{ `some v ⇒ v × 2, `none ⇒ 0 }기 [1, `none, 3]
⇒ [2, 0, 6]Try it

Try results

?F is Try: it runs F, and turns success or failure into a value. Success is `ok and the result. Failure is `err and the error's kind, as a Sym.

(?{1 ÷ x}) 0
⇒ `err `domainTry it
(?산) [3, 1, 2]
⇒ `ok [1, 2, 3]Try it

A Try result is consumed with a keyed-arm literal:

{ `ok v ⇒ v, `err k ⇒ 0 }기 ((?{1 ÷ x})기 [1, 0, 4])
⇒ [1.0, 0.0, 0.25]Try it

Try catches errors that depend on the data, which are domain errors. It does not catch mistakes in the program itself, such as a type error. The errors page explains why.

Tables and records

A table is a set of named columns, each an array of the same length. It is a DataFrame, or a SQL table. Each column has its own element type.

(Table {name: [`ann, `bo], age: [31, 27]}).age
⇒ [31, 27]Try it

A record is one row: a name for each value.

엄 0 (Table {name: [`ann, `bo], age: [31, 27]})
⇒ Record {name: `ann, age: 31}Try it

Columns of different lengths are an error. Since lengths are data, its kind is domain:

Table {a: [1, 2], b: [1]}
⇒ !domain: a table's columns must all have the same number of rowsTry it

A table works like a matrix whose rows are along the first axis. A column can hold absent cells. The tables tutorial shows tables at work.

Partitions and groups

Two more kinds of value come out of grouping.

  • A partition lists, for each key, the positions of its rows. 첮 makes one.
  • Groups hold the values themselves, per key. Indexing an array by a partition makes them.
[20, 35, 40][첮 [`east, `west, `east] [20, 35, 40]]
⇒ Groups {`east: [20, 40], `west: [35]}Try it

Only the grouped flow ㅔ takes groups. See groups.

Functions are not values

A block, a syllable with its operand, or a train is a function. A function is applied, not stored or printed. A line whose value would be a function is a type error:

{x × 2}
⇒ !type: a function is not a value; apply it, or glue it to a syllableTry it

The type rule

Every syllable has a type rule: from the types of its inputs and the values of its parameters, the rule gives the type of the result, or refuses. It never looks at the data itself. So an operation that is wrong is wrong on every input, not only on the input that happens to show it.

The rule draws one line through every value:

  • Types: an element type, a rank, the shape of a column's cells, an enum's labels.
  • Data: lengths, which elements are present, and the values themselves.

A mistake in the types is a type error. A mismatch in the data is a domain error. Two vectors of different lengths are a data mismatch:

[1, 2] + [1, 2, 3]
⇒ !domain: + on shapes [2] and [3]: only a scalar extends implicitly; align other shapes with lift (ㅂ, §3.1)Try it

A vector and a matrix differ in rank, which is a type. No lengths could make them fit:

[1, 2] + [[1, 2], [3, 4]]
⇒ !type: + between ranks 1 and 2: only a scalar extends implicitly; align other ranks with lift (ㅂ, §3.1)Try it

The checker refuses:

  • element types the operation does not accept, such as a sum of Syms or a mean of texts;
  • two element types that do not convert: only Int and Float meet;
  • ranks that cannot meet;
  • a wrong parameter, such as a negative count or a fill value of the wrong type, even when there is no data to apply it to;
  • a function operand with the wrong number of inputs, such as + where a one-input function belongs.

Which element types each operation accepts follows from its final. Sums need numbers, texts or Durations. Products need numbers. Max, min and sorting need an order, which every type but absence has. The operator reference gives the type of every syllable on arrays and on tables.

For each operation, the interpreter checks in a fixed order: parameters first, then the function operand, then the inputs' kinds and ranks, then element types, and only then lengths and values. So keys of the wrong type are a type error whatever their count, while the right type with the wrong count is a domain error.

There is no separate pass over the whole program yet. Each operation is checked when it runs, so a data error in an earlier step can still come out before a type error in a later one.