2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-07 07:17:49 +03:00
|
|
|
test-5055/main> builtins.merge
|
2024-06-05 19:51:35 +03:00
|
|
|
|
|
|
|
Done.
|
|
|
|
|
2024-06-05 20:07:55 +03:00
|
|
|
```
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2024-06-05 20:07:55 +03:00
|
|
|
foo.add x y = x Int.+ y
|
|
|
|
|
|
|
|
foo.subtract x y = x Int.- y
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-05 20:07:55 +03:00
|
|
|
|
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
|
|
|
⍟ These new definitions are ok to `add`:
|
|
|
|
|
|
|
|
foo.add : Int -> Int -> Int
|
|
|
|
foo.subtract : Int -> Int -> Int
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-07 07:17:49 +03:00
|
|
|
test-5055/main> add
|
2024-06-05 20:07:55 +03:00
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
|
|
|
|
|
|
|
foo.add : Int -> Int -> Int
|
|
|
|
foo.subtract : Int -> Int -> Int
|
|
|
|
|
2024-06-07 07:17:49 +03:00
|
|
|
test-5055/main> ls foo
|
2024-06-05 19:51:35 +03:00
|
|
|
|
2024-06-05 20:07:55 +03:00
|
|
|
1. add (Int -> Int -> Int)
|
|
|
|
2. subtract (Int -> Int -> Int)
|
2024-06-05 19:51:35 +03:00
|
|
|
|
2024-06-07 07:17:49 +03:00
|
|
|
test-5055/main> view 1
|
2024-06-05 19:51:35 +03:00
|
|
|
|
Refine Path-prefixing operations
This replaces `prefix :: Absolute -> Path' -> Path` with a couple
alternatives:
- `prefixAbs :: Absolute -> Relative -> Absolute`,
- `maybePrefix :: Path' -> Path' -> Maybe Path'`, and
- `prefix :: Path' -> Relative -> Path'`.
The previous `prefix` could fail to prefix (covered by either the new
`prefix` or `maybePrefix`, depending on whether you want to guarantee
success or capture failure), always threw away the knowledge that the
result was necessarily `Absolute` (covered by `prefixAbs`), and then
always returned an ambiguous result type (covered by all three
replacements).
Then it also provides `prefixRel` as the complement of `prefixAbs` (both
of which are used in the implementation of `prefix`).
Similar changes are made in the replacements for `prefixName :: Absolute
-> Name -> Name`. First, we don’t currently have absolute/relative
variants of `Name`, so we can generalize the first argument to `Path'`.
Then `maybePrefixName :: Path' -> Name -> Maybe Name` exposes the case
where prefixing can’t succeed, and `prefixNameIfRel :: Path' -> Name ->
Name` handles the common case of using the original `Name` if it can’t
be prefixed. Both of these new functions also preserve the `Position` of
the new `Name`, whereas the old implementation always returned a
`Relative` `Name`, despite knowing when it was `Absolute`. And
`prefixName2 :: Path -> Name -> Name` has been removed as there is no
ambiguous variant of `Name` (as `Split` is to `Split'`), so prefixing
with a `Path` isn’t particularly meaningful.
Finally, `nameFromSplit'` is added as a dual to `splitFromName'` to make
it possible to operate on the `Path'` portion of a `Name` without introducing partiality.
These new operations are then propagated through the code, and enable a
couple other type changes: `StructuredArgument.ShallowListEntry` and
`StructuredArgument.SearchResult` now take a `Path'` prefix rather than
the `Path.Absolute` and `Path` prefixes they took previously. This fixes
the absolute `Name` issue in `ls` results.
2024-06-07 07:29:15 +03:00
|
|
|
foo.add : Int -> Int -> Int
|
|
|
|
foo.add x y =
|
2024-06-05 20:07:55 +03:00
|
|
|
use Int +
|
|
|
|
x + y
|
2024-06-05 19:51:35 +03:00
|
|
|
|
2024-06-05 19:58:54 +03:00
|
|
|
```
|