The built-in types for Alan are included in the root scope and never need to be explicitly defined. Built-in types divide into three categories: basic types, strings, and special types.
Basic types include integers (
int64), floating point numbers (
float64), booleans (
bool), and the
void (no value) type. The numbers refer to the number of bits consumed by the basic type. There are currently no unsigned variants of the integer types, though that may change if there is demand for it.
float64 types are special among the numeric types, as these are the types that any numeric constant will be represented as, depending on whether or not it has a decimal. They have been given aliases of
float respectively for that reason.
The four "main" basic types (
void) have constant representations that you can easily type. The non-64-bit numeric types are considered specialized types and are discouraged (the runtime does not take advantage of the potential space optimizations they provide to keep the internal memory addressing system simpler), so constants for those types must be explicitly casted using the
to<Type> functions discussed in the Type Coercion section.
The integers have basic base-10 integer form as well as hexadecimal form. Binary and Octal forms are not implemented but that may change if there is demand for it.
const base10 = 12345; const base16 = 0xabcde;
The floating point numbers have only basic base-10 with a decimal point form, no scientific notation form yet, but that may change if there is demand for it.
const floating = 1.2345;
Booleans are represented by the keywords
void has no representation beyond
void. It can't be assigned to, and is meant to represent functions that return nothing.
const boolean = true; const someVoid = void;
The basic types are included in the root scope and never need to be explicitly defined, they always exist.
string) are a bit beyond the basic type. From the perspective of the user of Alan they are
utf-8 byte arrays (multi-byte code points increase the string length by 2 or 3, not 1). If there is significant demand for it, string length checks and other operations will be switched to the codepoint model versus the byte array model.
Strings are defined by wrapping double or single quotes (
const myString = "My string's string"; const myOtherString = 'My other string\'s string';
Functions are covered in the Functions section.
Either<T, U> is a special type that can hold two values. Other special types are built on top of it.
Maybe<T> is equivalent to
Either<T, void> and
Result<T> is equivalent to
Result are more extensively covered in the Error Handling section.
HashMap<K, V> creates a mapping from
Array<V> in Alan can hold more than one
V at a time. Arrays can be defined with an explicit type or the compiler can infer the type for you:
const test = new Array<int> [ 1, 2, 3, 4, 5 ]; const count = [1, 2, 3, 4, 5];