2024-10-08 23:23:34 +03:00
|
|
|
``` ucm :hide
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> builtins.merge
|
2020-10-22 23:58:33 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
Add `List.zonk` to the codebase:
|
|
|
|
|
2024-10-08 23:23:34 +03:00
|
|
|
``` unison
|
2020-10-22 23:58:33 +03:00
|
|
|
List.zonk : [a] -> [a]
|
|
|
|
List.zonk xs = xs
|
2020-10-23 17:01:18 +03:00
|
|
|
|
|
|
|
Text.zonk : Text -> Text
|
|
|
|
Text.zonk txt = txt ++ "!! "
|
2020-10-22 23:58:33 +03:00
|
|
|
```
|
|
|
|
|
2024-10-08 23:23:34 +03:00
|
|
|
``` ucm :hide
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> add
|
2020-10-22 23:58:33 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
Now, typecheck a file with a reference to `Blah.zonk` (which doesn't exist in the codebase). This should fail:
|
|
|
|
|
2024-10-08 23:23:34 +03:00
|
|
|
``` unison :error
|
2020-10-22 23:58:33 +03:00
|
|
|
-- should not typecheck as there's no `Blah.zonk` in the codebase
|
|
|
|
> Blah.zonk [1,2,3]
|
|
|
|
```
|
2020-10-23 17:01:18 +03:00
|
|
|
|
|
|
|
Here's another example, just checking that TDNR works for definitions in the same file:
|
|
|
|
|
2024-10-08 23:23:34 +03:00
|
|
|
``` unison
|
2020-10-23 17:01:18 +03:00
|
|
|
foo.bar.baz = 42
|
|
|
|
|
|
|
|
qux.baz = "hello"
|
|
|
|
|
|
|
|
ex = baz ++ ", world!"
|
|
|
|
|
|
|
|
> ex
|
|
|
|
```
|
|
|
|
|
|
|
|
Here's another example, checking that TDNR works when multiple codebase definitions have matching names:
|
|
|
|
|
2024-10-08 23:23:34 +03:00
|
|
|
``` unison
|
2020-10-23 17:01:18 +03:00
|
|
|
ex = zonk "hi"
|
|
|
|
|
|
|
|
> ex
|
|
|
|
```
|
|
|
|
|
|
|
|
Last example, showing that TDNR works when there are multiple matching names in both the file and the codebase:
|
|
|
|
|
2024-10-08 23:23:34 +03:00
|
|
|
``` unison
|
2020-10-23 17:01:18 +03:00
|
|
|
woot.zonk = "woot"
|
|
|
|
woot2.zonk = 9384
|
|
|
|
|
|
|
|
ex = zonk "hi" -- should resolve to Text.zonk, from the codebase
|
|
|
|
++ zonk -- should resolve to the local `woot.zonk` from this file
|
|
|
|
|
|
|
|
> ex
|
|
|
|
```
|