Names & use

Partly built

Dotted definition names, duplicate-name checks, and per-file use.

A definition’s name may contain dots (acme.billing.tax). The dots are part of the label, not of the hash; the editor and the CLI group by them. Defining a name that already exists is a conflict by default (--allow-duplicate-names opts out), and defining a name that hides a name a use brought in produces a warning.

A use statement, as in Unison, makes some stored names usable by their short form in one file. It is never stored and never hashed: the stored text always has the full names.

use acme.billing invoiceTotal tax

let checkout = (n: int): int => tax(invoiceTotal(n))
Verified, after adding acme.billing.invoiceTotal and acme.billing.tax in an earlier file: checkout(4) is 10.

use acme.billing by itself brings in every name directly below the prefix. use acme.billing invoiceTotal tax brings in just those, and use lib.std List followed by List.map(...) reads a name below the one you brought in. Two uses offering the same short name are an error at the use, naming both full names. A local definition or a local variable wins over a use. It works for terms, types, constructors and abilities of an installed library alike (use lib.base.Either Right, then Right(1)).

Open: a directory tree derived from names, and use across the bring-your-own-bucket path.

What a name may contain

As in Unison, a name starts with a letter or _ and continues with letters, digits, _, ' and !, where a letter is any Unicode letter (café, 𝕖). A trailing ! belongs to the name (go!), so a!=b written without spaces reads as a! then =b. Terms, types and fields start lowercase; constructors and abilities start uppercase.

Naming a library term by hash

A term of an installed library can be written by its hash, as in Unison: #ur2tossvhr…(xs). This exists so that library code with no name of its own can be written out; it works for installed libraries only.