Skip to main content
Version: 1.3.0


If we want to access a field, we use the selection operator ".", like so:

type user = {
login : string,
name : string
type account = {
user : user,
id : int,
is_admin : bool
const user : user = {login: "al", name: "Alice"};
const alice : account = {user, id: 5, is_admin: true};
const is_alice_admin = alice.is_admin; // == true

We can also access fields of a record using the destructuring syntax, known as pattern matching, which allows accessing multiple fields of a record in parallel, like so:

function userToTuple (a : account) {
const {user, id, is_admin} = a;
return [user, id, is_admin];

We can ignore some fields by calling the predefined function ignore on them, like so:

function getId (a : account) {
let {user, id, is_admin} = a;
ignore([user, is_admin]); // To avoid a warning
return id;