OPTION | Language | Program

Keywords · TYPE · OPTION

An OPTION is one named variant of a union TYPE , together with the payload it carries.

The grammar of a single OPTION line:

An OPTION keyword can only live inside a TYPE keyword.

Names one variant of the union, together with the payload type that variant carries.

Each option is one indented line under a type header, naming a variant of that union and the payload type it carries. A type built from options is a union; a type holds fields or options, never both.

Nothing. An OPTION is a leaf: a payload type and a name. It has no body and opens no indented lines — it only names one variant of the union it sits in.

The same example, rendered to each target. A union becomes that target's idiomatic sum type, and each OPTION becomes one variant carrying its payload type.

A type built from options is a union; the record counterpart of an option is a FIELD — where a union is exactly one of its options, a record is every field at once, and both are declared with TYPE . Projecting an option yields an Optional , itself just the built-in union with some and none options, which is why reading a variant returns one. Back to the language .

Recommended articles