unison/unison-src/transcripts/fix1334.md

39 lines
1.2 KiB
Markdown
Raw Normal View History

Previously, the `alias.term` and `alias.type` would fail if the source argument was hash-only, and there was no way to create an alias for a definition that didn't already have a name. Also, the `replace.term` and `replace.type` _only_ worked on hashes, and they had to be _full_ hashes.
2020-03-11 23:44:09 +03:00
With this PR, the source of an alias can be a short hash (even of a definition that doesn't currently have a name in the namespace) along with a name or hash-qualified name from the current namespace as usual, and the arguments to `replace.term` and `replace.type` can be a short hash, a name, or a hash-qualified name.
2020-03-11 23:44:09 +03:00
2021-06-23 00:14:18 +03:00
Note: `replace.term` and `replace.type` have since been replaced with just `replace`.
Let's make some hash-only aliases, now that we can. :mad-with-power-emoji:
2020-03-11 23:44:09 +03:00
```ucm
.> alias.type ##Nat Cat
.> alias.term ##Nat.+ please_fix_763.+
```
And some functions that use them:
```unison
f = 3
g = 4
h = f + 1
2020-03-11 23:44:09 +03:00
> h
```
```ucm
.> add
```
2021-06-23 00:14:18 +03:00
We used to have to know the full hash for a definition to be able to use the `replace` commands, but now we don't:
2020-03-11 23:44:09 +03:00
```ucm
.> names g
2021-06-23 00:14:18 +03:00
.> replace f g
2020-03-11 23:44:09 +03:00
.> names g
.> view.patch
```
The value of `h` should have been updated too:
```unison
> h
```