TOC Prev Next

Types and are Values


Disjunctions, or sum types, define a new type that is one of several things.

In the example, conn defines a protocol field that must be one of two values: "tcp" or "udp". It is an error for a concrete conn to define anything else than these two values.


conn: {
    address:  string
    port:     int
    protocol: "tcp" | "udp"

lossy: conn & {
    address:  ""
    port:     8888
    protocol: "udp"