Skip to content

Commit

Permalink
add links to documentation for data types
Browse files Browse the repository at this point in the history
  • Loading branch information
fricklerhandwerk committed Dec 23, 2022
1 parent 71c2b68 commit d1e2575
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions doc/manual/src/language/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

> *attrset* `.` *attrpath* \[ `or` *value* \]
Select the attribute denoted by attribute path *attrpath* from attribute set *attrset*.
Select the attribute denoted by attribute path *attrpath* from [attribute set] *attrset*.
An attribute path is a dot-separated list of attribute names.
If the attribute doesn’t exist, return *value* if provided, otherwise abort evaluation.

Expand All @@ -16,7 +16,7 @@ Precedence: 1

> *f* *a*
Call function *f* with argument *a*.
Call [function] *f* with argument *a*.

Associativity: left

Expand All @@ -26,7 +26,7 @@ Precedence: 2

> `-` *n*
Flip the sign of the number *n*.
Flip the sign of the [number] *n*.

Associativity: none

Expand All @@ -36,7 +36,7 @@ Precedence: 3

> *attrset* `?` *attrpath*
Test whether attribute set *attrset* contains the attribute denoted by *attrpath*; return `true` or `false`.
Test whether [attribute set] *attrset* contains the attribute denoted by *attrpath*; return `true` or `false`.

Associativity: none

Expand All @@ -46,7 +46,7 @@ Precedence: 4

> *list1* `++` *list2*
Concatenate lists *list1* and *list2*.
Concatenate [list]s *list1* and *list2*.

Associativity: right

Expand All @@ -56,7 +56,7 @@ Precedence: 5

> *n1* `*` *n2*,
Multiply numbers *n1* and *n2*.
Multiply [number]s *n1* and *n2*.

Associativity: left

Expand All @@ -66,7 +66,7 @@ Precedence: 6

> *n1* `/` *n2*
Divide numbers *n1* and *n2*.
Divide [number]s *n1* and *n2*.

Associativity: left

Expand All @@ -76,7 +76,7 @@ Precedence: 6

> *n1* `-` *n2*
Subtract numbers *n2* from *n1*.
Subtract [number] *n2* from *n1*.

Associativity: left

Expand All @@ -86,7 +86,7 @@ Precedence: 7

> *n1* `+` *n2*
Add numbers *n1* and *n2*.
Add [number]s *n1* and *n2*.

Associativity: left

Expand All @@ -96,7 +96,7 @@ Precedence: 7

> *string1* `+` *string2*
Concatenate *string1* and *string1* and merge their string contexts.
Concatenate two [string]s and merge their string contexts.

Associativity: left

Expand All @@ -106,19 +106,19 @@ Precedence: 7

> *path1* `+` *path2*
Concatenate two paths.
Concatenate two [path]s.
The result is a path.

## Path and string concatenation

> *path* `+` *string*
Concatenate *path* with *string*.
Concatenate *[path]* with *[string]*.
The result is a path.

> **Note**
>
> The string must not have a string context that refers to a store path.
> The string must not have a string context that refers to a [store path].
Associativity: left

Expand All @@ -128,13 +128,13 @@ Precedence: 7

> *string* `+` *path*
Concatenate *string* with *path*.
Concatenate *[string]* with *[path]*.
The result is a string.

> **Important**
>
> The file or directory at *path* must exist and is copied to the store
> The path appears in the result as the corresponding store path.
> The file or directory at *path* must exist and is copied to the [store].
> The path appears in the result as the corresponding [store path].
Associativity: left

Expand All @@ -144,7 +144,7 @@ Precedence: 7

> `!` *b*
Negate the Boolean value *b*.
Negate the [Boolean] value *b*.

Associativity: none

Expand All @@ -154,7 +154,7 @@ Precedence: 8

> *attrset1* `//` *attrset1*
Update attribute set *attrset1* with names and values from *attrset2*.
Update [attribute set] *attrset1* with names and values from *attrset2*.

The returned attribute set will have of all the attributes in *e1* and *e2*.
If an attribute name is present in both, the attribute value from the former is taken.
Expand All @@ -165,9 +165,9 @@ Precedence: 9

## Comparison

- Arithmetic comparison for numbers
- Lexicographic comparison for strings and paths
- Lexicographic comparison for lists:
- Arithmetic comparison for [number]s
- Lexicographic comparison for [string]s and [path]s
- Lexicographic comparison for [list]s:
Elements at the same index in both lists are compared according to their type and skipped if they are equal.

Associativity: none
Expand Down Expand Up @@ -196,8 +196,8 @@ Precedence: 10
Check expressions *e1* and *e2* for value equality.

- Attribute sets and lists are compared recursively, and therefore are fully evaluated.
- Comparison of functions always returns `false`.
- [Attribute sets][attribute set] and [list]s are compared recursively, and therefore are fully evaluated.
- Comparison of [function]s always returns `false`.
- Integers are coerced to floating point numbers if compared to floating point numbers.
- Floating point numbers only differ up to a limited precision.

Expand Down Expand Up @@ -246,3 +246,13 @@ Equivalent to `!`*b1* `||` *b2*.
Associativity: none

Precedence: 14

[string]: ./values.md#type-string
[path]: ./values.md#type-path
[number]: ./values.md#type-number
[Boolean]: ./values.md#type-boolean
[list]: ./values.md#list
[attribute set]: ./values.md#attribute-set
[function]: ./constructs.md#functions
[store path]: ../glossary.md#gloss-store-path
[store]: ../glossary.md#gloss-store

0 comments on commit d1e2575

Please sign in to comment.