Primitive Types

Flix supports the primitive types:

Unit()The unit value.
Booltrue, falseA boolean value.
Char'a', 'b', 'c'A character value.
Float320.0f32, 21.42f32, -21.42f32A 32-bit floating point integer.
Float640.0f64, 21.42f64, -21.42f64A 64-bit floating point integer.
Int80i8, 1i8, -1i8, 127i8, -128i8A signed 8-bit integer.
Int160i16, 123i16, -123i16A signed 16-bit integer.
Int320i32, 123i32, -123i32A signed 32-bit integer.
Int640i64, 123i64, -123i64A signed 64-bit integer.
String"hello", "world"A string value.
BigInt0ii, 123ii, -123iiAn arbitrary precision integer.
BigDecimal0.0ff, 123.45ff, -123.45ffAn arbitrary precision decimal.

Float64 and Int32 values can be written without suffix, i.e. 123.0f64 can simply be written as 123.0 and 123i32 can be written as 123.

Built-in Literals

Flix has built-in syntactic sugar for lists, sets, and maps.

List Literals

A list literal is written using the infix :: constructor. For example:

1 :: 2 :: 3 :: Nil

which is syntactic sugar for:

Cons(1, Cons(2, Cons(3, Nil)))

Alternatively, the same list can also be written as:

List#{1, 2, 3}

Set Literals

A set literal is written using the notation Set#{v1, v2, ...}. For example:

Set#{1, 2, 3}

which is syntactic sugar for:

Set.insert(3, Set.insert(2, Set.insert(1, Set.empty())))

Note that the elements are inserted from left to right, thus 1 is inserted first.

Map Literals

A map literal is written using the notion Map#{k1 => v1, k2 => v2, ...}. For example:

Map#{1 => "Hello", 2 => "World"}

which is syntactic sugar for:

Map.insert(2, "World", Map.insert(1, "Hello", Map.empty()))

Note that similar to sets above, the entries are inserted left to right. In particular, if multiple entries share the same key, the rightmost one overwrites the previous values.