unison/unison-src/transcripts/fix845.md
2024-06-25 11:11:07 -07:00

1.0 KiB

scratch/main> builtins.merge

Add List.zonk to the codebase:

List.zonk : [a] -> [a]
List.zonk xs = xs

Text.zonk : Text -> Text
Text.zonk txt = txt ++ "!! "
scratch/main> add

Now, typecheck a file with a reference to Blah.zonk (which doesn't exist in the codebase). This should fail:

-- should not typecheck as there's no `Blah.zonk` in the codebase
> Blah.zonk [1,2,3]

Here's another example, just checking that TDNR works for definitions in the same file:

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:

ex = zonk "hi"

> ex

Last example, showing that TDNR works when there are multiple matching names in both the file and the codebase:

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