Skip to main content

Data types

Snapi supports the following data types.

Numbers

Snapi supports the following number types.

byte

Minimum value of -128 and a maximum value of 127.

short

Minimum value of -32768 and a maximum value of 32767.

int

Minimum value of -2ˆ31 and a maximum value of (2ˆ31)-1.

long

Minimum value of -32768 and a maximum value of 32767.

float

As per IEEE 754.

double

As per IEEE 754.

decimal

Lossless number representation.

NOTE: Using decimal leads to exact - but very slow - mathematical operations.

Boolean

bool

Holds true or false boolean values.

Characters

string

Variable length character data.

Temporals

date

Calendar date (year, month, day).

Example: 2001-08-22

time

Time of day (hour, minute, second, millisecond) without a time zone.

Example: 01:02:03.456

timestamp

Instant in time that includes the date and time of day without a time zone.

Example: 2001-08-22 03:04:05.321

interval

Span of years, months, weeks, days, minutes, hours, seconds and milliseconds.

Record

record

A structure holding multiple named inner types. For example:

{ age: 35, name: "Jane Doe" } // type is record(age: int, name: string)

Collections

collection

A structure holding a sequence of items of the same type. The elements are not computed until its contents are consumed.

list

Similar to collection, but its elements are computed when the list is constructured. Also provides additional operations such as accessing an item by its position/index on the list.

Binary Types

binary

A sequence of bytes.

Function

The function type.

Unknown

null

Represents the null type, i.e. an unknown data type.

All values may be nullable. Refer to the section on null handling.