⛅ Coming soon: create Unison Cloud clusters in minutes on your own infrastructure. Learn more

Literals

A literal expression is a basic form of Unison expressions. Unison has the following types of literals:

Literal typeCode exampleExplanation
Nat (64-bit unsigned integer)
0 Nat.+ 18446744073709551615

0x003 = 3

A 64-bit unsigned integer consisting of digits 0-9. Nat is short for "the natural numbers". Nat values range from 0 to 18446744073709551615. Can also be written in hex with the prefix 0x.
Int (64-bit signed integer)
-4 Int.+ +4 Int.+ +0
A 64-bit signed integer, prefixed by the + or - sign. Int values range from -9223372036854775808 to +9223372036854775807.
Float (64-bit floating point number)1.6777216, -4.567Floating point literals in Unison are IEEE 754-1985 double-precision numbers consisting of an optional sign (''+''/''-''), followed by two natural numbers separated by ..
Text

"Hello, world!"

"{\"aString\":\"withQuotes\"}"

multi =
  """
    This is a
    multiline text
  """
A sequence of Unicode characters enclosed in quotes. Multi-line text is supported with triple quotes """. Escape sequences are started with \.
Char?a, ?🔥, ?\tA single Unicode character prefixed by ?. The character may be an escape sequence.
Booleantrue, falseBoolean literal values are either true or false.
Bytes0xsdeadbeefA byte literal is an even number of hexadecimal digits preceded by 0xs.
Hash reference

#ko93h54ens is the hash literal form of List.map

#ko93h54ens increment [1,2]
A reference to a saved term or type in the codebase, beginning with #. All Unison terms and types are hashed, but they are seldom referred to in this way. See the section on hashes for details on the lexical form of hash literals.
List[], ["x"], [1, 2, 3]A comma-separated list of values enclosed in []. Elements must have the same type. If the type of the elements is t, then the type of the list literal is List t or [t].
Function literals/lambdasx y -> x + y + 1A function definition with the form p1 p2 … pn -> e. The arguments to the left of the arrow are local variables in the function body, e, and they are bound to any values passed as arguments to the function when it is called. The body of the lambda is the to right of the arrow and must be a Unison expression.
Tuple(1, "hello"), ()A grouping of values inside (). A tuple (A, B) has elements of type A and B. The unit tuple () has type Unit, (). See tuple types for details on these types and more ways of constructing tuples
termlink and typelink literals)termLink aUnisonTerm, typeLink OptionalA reference to a Unison term or type using termLink or typeLink. termLink produces a value of type Link.Term and typeLink produces a value of type Link.Type