Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Type Syntax Sugar

Even though types such as array, choice, function types, are mapped to Fuzion features, it could improve readability and usability a lot to have special syntax for declaration of these types and their instances.

Feature Type Declaration value syntax sugar comment
verbose syntax sugar
sequence, list or array Sequence Sequence A [T] [a,b,c]
A value [a,b,c] is an instance of array T (that can be assigned to type Sequence T), while type [A] is equivalent to Sequence T. The type of a sequence value is inferred from the target it is assigned to, or, if the target does not have a declared type, from the first element in the sequence ([void] for an empty sequence).
dictionary, map Map Map A B [A => B] [a1 => b1,
 a2 => b2,
 a3 => b3]
A map value is of type ordered_map, the elements must inherit ordered.
function or lambda Function Function R A B
Function R A
Function R
(A,B) -> R
A,B -> R
(A) -> R
A -> R
() -> R
(a,b) -> f a b
a,b -> f a b
(a) -> f a
a -> f a
() -> f const
A lambda value must be assigned to a field of a function type.
tagged union choice choice A B C A | B | C a A value a of type A will be converted to a choice type A | B | C implicitly in an assignment to a field whose type is the choice type.
tuple tuple tuple A B C (A, B, C) (a, b, c)
Note that (a) is _not_ a one-tuple. The type of () is unit, which is an heir of tuple.
Tuple syntax is also used for destructuring as in (x, y) := point.