Structs

A struct in Helios is a named grouping of types (sometimes called a product type). They are similar to structs in other languages (e.g. C, Go and Rust):

// example of a Rational (fractional type)
struct Rational {
    top:    Int
    bottom: Int
}

Note: a struct can't be empty must have at least one field.

Instantiating a struct

A struct can be instantiated using the following literal syntax:

const x = Rational { 1, 3 } // type of 'x' is inferred

The fields can also be named:

const x = Rational { bottom: 3, top: 1 }