Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (39 sloc) 954 Bytes
title permalink sidebar folder
Records
/records
docs_sidebar
docs
  • Record Types are combining several values into a structured value similar to a struct in C. An example record definition is given by
.type Connection = [
    from : Place,
    to : Place
]

defining values of ordered pairs of places. Each record type enumerates a list of nested, named fields and their types. Records may be nested as in

.type Cargo = [
    flight : Connection,
    mass : weight
]

as well as recursive, as in

.type Path = [
    first : Connection,
    rest : Path
]

Thus, a record may contain (directly or indirectly) fields of its own type. As a base case for recursive records, every record type contains the value nil, so we can represent lists as

.type List = [
    head : number
    tail : List
]
.decl A(x : List)
A(nil).
A([1,nil]).
A([2,[3,nil]]).

Union types involving records are currently not supported.

You can’t perform that action at this time.