Ause clausetells Unison to allowidentifiersfrom a givennamespaceto be usedunqualifiedin thelexical scopewhere the use clause appears.
In this example, theuse base.List
clause allows the definition that follows it to refer tolib.base.List.take
as simplytake
:
oneTwo = List.take 2 [1, 2, 3]
The general form ofuse
clauses is as follows:
use namespace name_1 name_2 .. name_n
Wherenamespace
is the namespace from which we want to use names unqualified, andname_1
throughname_n
are the names we want to use. If no names are given in theuse
clause, Unison allows all the names from the namespace to be used unqualified. There's no performance penalty for this, asuse
clauses are purely a syntactic convenience. When rendering code as text, Unison will insert preciseuse
clauses that mention exactly the names it uses, even if the programmer omitted the list of names.
See the section onidentifiersfor more on namespaces as well as qualified and unqualified names.