Primitive Types

✅ bool

  • When to use it: When you need to represent a simple true/false condition.
  • Syntax: bool

✅ int

  • When to use it: When you want numeric values
  • Syntax: int

✅ float

  • When to use it: When dealing with numerical values that require precision (like measurements or monetary values).
  • Syntax: float

✅ string

  • Syntax: string

✅ char

  • When to use it: When you need to represent a single letter, digit, or other symbols.
  • Syntax: char

✅ null

  • Syntax: null

⚠️ bytes

  • Not yet supported. Use a string[] or int[] instead.

⚠️ any/json

  • Not supported.

    We don’t want to encourage its use as it defeats the purpose of having a type system. if you really need it, for now use string and call json.parse yourself. Also, message us on discord so we can understand your use case and consider supporting it.

Dates/Times

⚠️ datetime

  • Not yet supported. Use a string or int (milliseconds since epoch) instead.

⚠️ datetime interval

  • Not yet supported. Use a string or int (milliseconds since epoch) instead.

⚠️ Unit Values (currency, temperature, etc)

Many times you may want to represent a number with a unit. For example, a temperature of 32 degrees Fahrenheit or cost of $100.00.

  • Not yet supported. We recommend using a number (int or float) and having the unit be part of the variable name. For example, temperature_fahrenheit and cost_usd (see @alias).

❌ Images

  • Not yet supported. Reach out to us on discord if you need this.

❌ Tensors

  • Not yet supported. Reach out to us on discord if you need this.

Composite/Structured Types

✅ enum

See also: Enum

A user-defined type consisting of a set of named constants.

  • When to use it: Use it when you need a model to choose from a known set of values, like in classification problems
  • Syntax:
enum Name {
  Value1
  Value2
}
  • Example:
enum Color {
  Red
  Green
  Blue
}

✅ class

See also: Class

  • What it is: User-defined complex data structures.
  • When to use it: When you need an LLM to call another function (e.g. OpenAI’s function calling), you can model the function’s parameters as a class. You can also get models to return complex structured data by using a class.
  • Syntax:
class ClassName {
  ...
}
  • Example:
class Car {
  model string
  year int
}

✅ Optional (?)

  • What it is: A type that represents a value that might or might not be present.
  • When to use it: When a variable might not have a value and you want to explicitly handle its absence.
  • Syntax: <type>?
  • Example: int? or (MyClass | int)?

✅ Union (|)

  • What it is: A type that can hold one of several specified types.

  • When to use it: When a variable can legitimately be of more than one type. This can be helpful with function calling, where you want to return different types of data depending on which function should be called.

  • Syntax: <type>|<type>

  • Example: int | string or (int | string) | MyClass or string | MyClass | int[]

    Order is important. int | string is not the same as string | int.


    For example, if you have a "1" string, it will be parsed as an int if you use int | string, but as a string if you use string | int.

✅ List/Array ([])

  • What it is: A collection of elements of the same type.
  • When to use it: When you need to store a list of items of the same type.
  • Syntax: <type>[]
  • Example: string[] or (int | string)[] or int[][]
  • Array types can be nested to create multi-dimensional arrays
  • An array type cannot be optional

❌ Dictionary

  • Not yet supported. Use a class instead.

❌ Set

  • Not yet supported. Use a List instead.

❌ Tuple

  • Not yet supported. Use a class instead.

Examples and Equivalents

Here are some examples and what their equivalents are in different languages.

Example 1

int?|string[]|MyClass

Example 2

string[]

Example 3

(int|float)[]

Example 4

(int? | string[] | MyClass)[]