Symbols
A symbol is an identifier-like value written :name — no space between the colon and the name. Symbols are used for tags, enum-like choices, and any time you want a typed name rather than a string.
shade = :amber
accent = :cyan
edge = :uses
The symbol type
A free-form field accepting any symbol has type symbol. There's no validation on which symbols may appear — anything that lexes as :name is valid.
type Tag {
name: utf8
kind: symbol
}
t = Tag { name: "release", kind: :stable }
Symbol sets
A symbol_set names a closed vocabulary of symbols. A field typed by the symbol set is restricted to exactly those members, giving you an enum-like type without the weight of a union.
symbol_set Color {
red
green
blue
}
type Paint {
shade: Color // only :red, :green, or :blue
}
cream = Paint { shade: :red }
Use a symbol set wherever you'd reach for an enum in another language: severity levels, edge kinds, named layout modes, the eight chart palette hues, …
When to use which
WCL has three closely-related tools for "a value that is one of a set of names". The right pick depends on whether the vocabulary is open and whether each variant carries data.
| Need | Use |
|---|---|
| Closed vocabulary, no payload | symbol_set |
| Closed vocabulary with data per variant | union |
| Open string-typed tag | plain utf8 |
| Free-form symbol (any :name) | symbol |