2020-02-26 00:15:36 +03:00
# Adds and updates
Let's set up some definitions to start:
2024-10-08 23:23:34 +03:00
``` ucm :hide
2024-06-12 01:22:09 +03:00
scratch/main> builtins.merge
2020-02-26 00:15:36 +03:00
```
2024-10-08 23:23:34 +03:00
``` unison
2020-02-26 00:15:36 +03:00
x = 1
y = 2
2021-08-24 00:09:27 +03:00
structural type X = One Nat
structural type Y = Two Nat Nat
2020-02-26 00:15:36 +03:00
```
Expected: `x` and `y` , `X` , and `Y` exist as above. UCM tells you this.
2024-10-08 23:23:34 +03:00
``` ucm
2024-06-12 01:22:09 +03:00
scratch/main> add
2020-02-26 00:15:36 +03:00
```
Let's add an alias for `1` and `One` :
2024-10-08 23:23:34 +03:00
``` unison
2020-02-26 00:15:36 +03:00
z = 1
2021-08-24 00:09:27 +03:00
structural type Z = One Nat
2020-02-26 00:15:36 +03:00
```
Expected: `z` is now `1` . UCM tells you that this definition is also called `x` .
Also, `Z` is an alias for `X` .
2024-10-08 23:23:34 +03:00
``` ucm
2024-06-12 01:22:09 +03:00
scratch/main> add
2020-02-26 00:15:36 +03:00
```
Let's update something that has an alias (to a value that doesn't have a name already):
2024-10-08 23:23:34 +03:00
``` unison
2020-02-26 00:15:36 +03:00
x = 3
2021-08-24 00:09:27 +03:00
structural type X = Three Nat Nat Nat
2020-02-26 00:15:36 +03:00
```
Expected: `x` is now `3` and `X` has constructor `Three` . UCM tells you the old definitions were also called `z` and `Z` and these names have also been updated.
2024-10-08 23:23:34 +03:00
``` ucm
2024-06-12 01:22:09 +03:00
scratch/main> update
2020-02-26 00:15:36 +03:00
```
Update it to something that already exists with a different name:
2024-10-08 23:23:34 +03:00
``` unison
2020-02-26 00:15:36 +03:00
x = 2
2021-08-24 00:09:27 +03:00
structural type X = Two Nat Nat
2020-02-26 00:15:36 +03:00
```
2022-04-07 00:12:07 +03:00
Expected: `x` is now `2` and `X` is `Two` . UCM says the old definition was also named `z/Z` , and was also updated. And it says the new definition is also named `y/Y` .
2020-02-26 00:15:36 +03:00
2024-10-08 23:23:34 +03:00
``` ucm
2024-06-12 01:22:09 +03:00
scratch/main> update
2020-02-26 00:15:36 +03:00
```