Unison identifiers come in two flavors:
- Regular identifiersstart with an alphabetic unicode character, emoji (which is any unicode character between 1F400 and 1FAFF inclusive), or underscore (''_''), followed by any number of alphanumeric characters, emoji, or the characters
_
,!
,or\
'.For example,foo
,_bar4
,qux
',andset!
are valid regular identifiers. - Operatorsconsist entirely of the characters
!$%^&*-=+<>~\\/|:
.For example,+
,*
,<>
,and>>=
are valid operators.
Namespace-qualified identifiers
Thegeneral reference for identifiersdescribesunqualifiedidentifiers. An identifier can also be qualified. A qualified identifier consists of a qualifier or namespace, followed by a.
,followed by either a regular identifier or an operator. The qualifier is one or more regular identifiers separated by.
For exampleFoo.Bar.baz
is a qualified identifier whereFoo.Bar
is the qualifier.
Absolutely qualified identifiers
Note that absolutely qualified identifiers are much less prevalent with the advent of Unison projects. They refer to a term from the root of the entire codebase, not the root of a particular project, so their usage is limited to legacy support of a pre-project era.
Namespace-qualified identifiersare relative to a “current” namespace, which the programmer can set (and defaults to the root of the current project). To ignore the current namespace, an identifier can have anabsolute qualifier.An absolutely qualified name begins with a.
.For example, the name.base.List
always refers to the name.base.List
,regardless of the current project or namespace, whereas the namebase.List
will refer tolib.base.List
if the current namespace contains thebase
library in itslib
namespace.
Hash-qualified identifiers
Any identifier, including a namespace-qualified one, can appearhash-qualified.A hash-qualified identifier has the formx#h
wherex
is an identifier and#h
is ahash literal.The hash disambiguates names that may refer to more than one thing.
Reserved words
The following names are reserved by Unison and cannot be used as identifiers:=
,:
,->
,'
,do
,|
,!
,`
,if
,then
,else
,forall
,handle
,unique
,structural
,where
,use
,&&
,||
,true
,false
,type
,ability
,alias
,let
,namespace
,cases
,match
,with
,termLink
,typeLink
.