Inline nosync versions into their regular forms so people aren't tempted to use them.

This commit is contained in:
Chris Penner 2024-06-05 15:08:05 -07:00
parent 8b5859c798
commit 87bd96963e
7 changed files with 50 additions and 978 deletions

View File

@ -44,6 +44,7 @@ module Unison.Cli.MonadUtils
stepAt,
stepAtM,
stepManyAt,
stepManyAtM,
syncRoot,
updateRoot,
updateAtM,
@ -359,7 +360,7 @@ stepManyAt ::
f (Path, Branch0 IO -> Branch0 IO) ->
Cli ()
stepManyAt reason actions = do
stepManyAtNoSync actions
void . modifyRootBranch $ Branch.stepManyAt actions
syncRoot reason
stepManyAt' ::
@ -368,45 +369,22 @@ stepManyAt' ::
f (Path, Branch0 IO -> Cli (Branch0 IO)) ->
Cli Bool
stepManyAt' reason actions = do
res <- stepManyAtNoSync' actions
syncRoot reason
pure res
stepManyAtNoSync' ::
(Foldable f) =>
f (Path, Branch0 IO -> Cli (Branch0 IO)) ->
Cli Bool
stepManyAtNoSync' actions = do
origRoot <- getRootBranch
newRoot <- Branch.stepManyAtM actions origRoot
setRootBranch newRoot
syncRoot reason
pure (origRoot /= newRoot)
-- Like stepManyAt, but doesn't update the last saved root
stepManyAtNoSync ::
(Foldable f) =>
f (Path, Branch0 IO -> Branch0 IO) ->
Cli ()
stepManyAtNoSync actions =
void . modifyRootBranch $ Branch.stepManyAt actions
stepManyAtM ::
(Foldable f) =>
Text ->
f (Path, Branch0 IO -> IO (Branch0 IO)) ->
Cli ()
stepManyAtM reason actions = do
stepManyAtMNoSync actions
syncRoot reason
stepManyAtMNoSync ::
(Foldable f) =>
f (Path, Branch0 IO -> IO (Branch0 IO)) ->
Cli ()
stepManyAtMNoSync actions = do
oldRoot <- getRootBranch
newRoot <- liftIO (Branch.stepManyAtM actions oldRoot)
setRootBranch newRoot
syncRoot reason
-- | Sync the in-memory root branch.
syncRoot :: Text -> Cli ()

View File

@ -81,12 +81,9 @@ These should fail with a term/ctor conflict since we exclude the ability from th
⍟ I've added these definitions:
ability Channels
Channels.send : a -> ()
thing : '{Channels} ()
⍟ I've updated these names to your new definition:
ability Channels
```
If however, `Channels.send` and `thing` _depend_ on `Channels`, updating them should succeed since it pulls in the ability as a dependency.

View File

@ -62,10 +62,8 @@ inner.ping _ = !pong + 3
.> view inner.ping
inner.ping : 'Nat
inner.ping _ =
use Nat +
!pong + 1
inner.inner.ping : '##Nat
inner.inner.ping _ = ##Nat.+ !#4t465jk908 3
```
The bug here is that `inner.ping` still refers to `pong` by name. But if we properly identified the nameless (in the

View File

@ -213,399 +213,23 @@ unique type Y a b = Y a b
.> diff.namespace ns1 ns2
Resolved name conflicts:
⚠️
1. ┌ fromJust#gjmq673r1v : Nat
2. └ fromJust#rnbo52q2sh : Text
3. fromJust#6gn1k53ie0 : Nat
Updates:
4. b : Nat
5. b : Text
6. fromJust' : Nat
7. fromJust' : Nat
Added definitions:
8. type Y a b
9. Y.Y : a -> b -> Y a b
10. d : Nat
11. e : Nat
12. f : Nat
13. patch patch (added 2 updates)
The namespace .ns1 is empty. Was there a typo?
.> alias.term ns2.d ns2.d'
Done.
.> alias.type ns2.A ns2.A'
Done.
.> alias.type ns2.X ns2.X'
Done.
.> diff.namespace ns1 ns2
Resolved name conflicts:
1. ┌ fromJust#gjmq673r1v : Nat
2. └ fromJust#rnbo52q2sh : Text
3. fromJust#6gn1k53ie0 : Nat
Updates:
4. b : Nat
5. b : Text
6. fromJust' : Nat
7. fromJust' : Nat
Added definitions:
8. type Y a b
9. Y.Y : a -> b -> Y a b
10. ┌ d : Nat
11. └ d' : Nat
12. e : Nat
13. f : Nat
14. patch patch (added 2 updates)
Name changes:
Original Changes
15. A 16. A' (added)
17. X 18. X' (added)
.> alias.type ns1.X ns1.X2
Done.
.> alias.type ns2.A' ns2.A''
Done.
.> fork ns2 ns3
Done.
.> alias.term ns2.fromJust' ns2.yoohoo
Done.
.> delete.term.verbose ns2.fromJust'
Name changes:
Original Changes
1. ns2.fromJust ┐ 2. ns2.fromJust' (removed)
3. ns2.fromJust' │
4. ns2.yoohoo │
5. ns3.fromJust │
6. ns3.fromJust' ┘
Tip: You can use `undo` or `reflog` to undo this change.
.> diff.namespace ns3 ns2
Name changes:
Original Changes
1. fromJust ┐ 2. yoohoo (added)
3. fromJust' ┘ 4. fromJust' (removed)
```
```unison
bdependent = "banana"
```
```ucm
.ns3> update.old
⍟ I've updated these names to your new definition:
bdependent : ##Text
.> diff.namespace ns2 ns3
Updates:
1. bdependent : Nat
2. bdependent : Text
3. patch patch (added 1 updates)
Name changes:
Original Changes
4. fromJust ┐ 5. fromJust' (added)
6. yoohoo ┘ 7. yoohoo (removed)
```
## Two different auto-propagated changes creating a name conflict
Currently, the auto-propagated name-conflicted definitions are not explicitly
shown, only their also-conflicted dependency is shown.
```unison
a = 333
b = a + 1
.ns2> update.old.> diff.namespace ns1 ns2.> alias.term ns2.d ns2.d'.> alias.type ns2.A ns2.A'.> alias.type ns2.X ns2.X'.> diff.namespace ns1 ns2.> alias.type ns1.X ns1.X2.> alias.type ns2.A' ns2.A''.> fork ns2 ns3.> alias.term ns2.fromJust' ns2.yoohoo.> delete.term.verbose ns2.fromJust'.> diff.namespace ns3 ns2
```
```ucm
☝️ The namespace .nsx is empty.
.nsx> add
🛑
⍟ I've added these definitions:
The transcript failed due to an error in the stanza above. The error is:
⚠️
a : ##Nat
b : ##Nat
The namespace .ns1 is empty. Was there a typo?
.> fork nsx nsy
Done.
.> fork nsx nsz
Done.
```
```unison
a = 444
```
```ucm
.nsy> update.old
⍟ I've updated these names to your new definition:
a : ##Nat
```
```unison
a = 555
```
```ucm
.nsz> update.old
⍟ I've updated these names to your new definition:
a : ##Nat
.> merge.old nsy nsw
Here's what's changed in nsw after the merge:
Added definitions:
1. a : Nat
2. b : Nat
3. patch patch (added 1 updates)
Tip: You can use `todo` to see if this generated any work to
do in this namespace and `test` to run the tests. Or you
can use `undo` or `reflog` to undo the results of this
merge.
Applying changes from patch...
```
```ucm
.> merge.old nsz nsw
Here's what's changed in nsw after the merge:
New name conflicts:
1. a#mdl4vqtu00 : Nat
2. ┌ a#mdl4vqtu00 : Nat
3. └ a#vrs8gtkl2t : Nat
4. b#unkqhuu66p : Nat
5. ┌ b#aapqletas7 : Nat
6. └ b#unkqhuu66p : Nat
Updates:
7. patch patch (added 1 updates)
Tip: You can use `todo` to see if this generated any work to
do in this namespace and `test` to run the tests. Or you
can use `undo` or `reflog` to undo the results of this
merge.
Applying changes from patch...
I tried to auto-apply the patch, but couldn't because it
contained contradictory entries.
```
```ucm
.> diff.namespace nsx nsw
New name conflicts:
1. a#uiiiv8a86s : Nat
2. ┌ a#mdl4vqtu00 : Nat
3. └ a#vrs8gtkl2t : Nat
4. b#lhigeb1let : Nat
5. ┌ b#aapqletas7 : Nat
6. └ b#unkqhuu66p : Nat
Added definitions:
7. patch patch (added 2 updates)
.nsw> view a b
a#mdl4vqtu00 : ##Nat
a#mdl4vqtu00 = 444
a#vrs8gtkl2t : ##Nat
a#vrs8gtkl2t = 555
b#aapqletas7 : ##Nat
b#aapqletas7 = ##Nat.+ a#vrs8gtkl2t 1
b#unkqhuu66p : ##Nat
b#unkqhuu66p = ##Nat.+ a#mdl4vqtu00 1
```
## Should be able to diff a namespace hash from history.
```unison
x = 1
```
```ucm
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`:
x : ##Nat
```
```ucm
☝️ The namespace .hashdiff is empty.
.hashdiff> add
⍟ I've added these definitions:
x : ##Nat
```
```unison
y = 2
```
```ucm
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`:
y : ##Nat
```
```ucm
.hashdiff> add
⍟ I've added these definitions:
y : ##Nat
.hashdiff> history
Note: The most recent namespace hash is immediately below this
message.
⊙ 1. #ru1hnjofdj
+ Adds / updates:
y
□ 2. #i52j9fd57b (start of history)
.hashdiff> diff.namespace 2 1
Added definitions:
1. y : ##Nat
```
##
Updates: -- 1 to 1
New name conflicts: -- updates where RHS has multiple hashes (excluding when RHS=LHS)
1. foo#jk19sm5bf8 : Nat - do we want to force a hashqualified? Arya thinks so
2. ┌ foo#0ja1qfpej6 : Nat
3. └ foo#jk19sm5bf8 : Nat
Resolved name conflicts: -- updates where LHS had multiple hashes and RHS has one
4. ┌ bar#0ja1qfpej6 : Nat
5. └ bar#jk19sm5bf8 : Nat
6. bar#jk19sm5bf8 : Nat
## Display issues to fixup
- [d] Do we want to surface new edit conflicts in patches?
- [t] two different auto-propagated changes creating a name conflict should show
up somewhere besides the auto-propagate count
- [t] Things look screwy when the type signature doesn't fit and has to get broken
up into multiple lines. Maybe just disallow that?
- [d] Delete blank line in between copies / renames entries if all entries are 1 to 1
see todo in the code
- [x] incorrectly calculated bracket alignment on hashqualified "Name changes" (delete.output.md)
- [x] just handle deletion of isPropagated in propagate function, leave HandleInput alone (assuming this does the trick)
- [x] might want unqualified names to be qualified sometimes:
- [x] if a name is updated to a not-yet-named reference, it's shown as both an update and an add
- [x] similarly, if a conflicted name is resolved by deleting the last name to
a reference, I (arya) suspect it will show up as a Remove
- [d] Maybe group and/or add headings to the types, constructors, terms
- [x] add tagging of propagated updates to test propagated updates output
- [x] missing old names in deletion ppe (delete.output.md) (superseded by \#1143)
- [x] delete.term has some bonkers output
- [x] Make a decision about how we want to show constructors in the diff
- [x] 12.patch patch needs a space
- [x] This looks like garbage
- [x] Extra 2 blank lines at the end of the add section
- [x] Fix alignment issues with buildTable, convert to column3M (to be written)
- [x] adding an alias is showing up as an Add and a Copy; should just show as Copy
- [x] removing one of multiple aliases appears in removes + moves + copies section
- [x] some overlapping cases between Moves and Copies^
- [x] Maybe don't list the type signature twice for aliases?

View File

@ -72,149 +72,35 @@ Let's do the update now, and verify that the definitions all look good and there
.a2> view A NeedsA f f2 f3 g
type A a b c d
= B b
| D d
| E a d
| C c
| A a
structural type NeedsA a b
= Zoink Text
| NeedsA (A a b Nat Nat)
f : A Nat Nat Nat Nat -> Nat
f = cases
A n -> n
_ -> 42
f2 : A Nat Nat Nat Nat -> Nat
f2 a =
use Nat +
n = f a
n + 1
f3 : NeedsA Nat Nat -> Nat
f3 = cases
NeedsA a -> f a Nat.+ 20
_ -> 0
g : A Nat Nat Nat Nat -> Nat
g = cases
D n -> n
_ -> 43
type A a b c d = B b | D d | E a d | C c | A a
.a2> todo
⚠️
No conflicts or edits in progress.
The following names were not found in the codebase. Check your spelling.
NeedsA
f
f2
f3
g
```
## Record updates
Here's a test of updating a record:
```unison
structural type Rec = { uno : Nat, dos : Nat }
combine r = uno r + dos r
```
```ucm
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`:
structural type Rec
Rec.dos : Rec -> Nat
Rec.dos.modify : (Nat ->{g} Nat) -> Rec ->{g} Rec
Rec.dos.set : Nat -> Rec -> Rec
Rec.uno : Rec -> Nat
Rec.uno.modify : (Nat ->{g} Nat) -> Rec ->{g} Rec
Rec.uno.set : Nat -> Rec -> Rec
combine : Rec -> Nat
```
```ucm
.a3> add
⍟ I've added these definitions:
structural type Rec
Rec.dos : Rec -> Nat
Rec.dos.modify : (Nat ->{g} Nat) -> Rec ->{g} Rec
Rec.dos.set : Nat -> Rec -> Rec
Rec.uno : Rec -> Nat
Rec.uno.modify : (Nat ->{g} Nat) -> Rec ->{g} Rec
Rec.uno.set : Nat -> Rec -> Rec
combine : Rec -> Nat
```
```unison
structural type Rec = { uno : Nat, dos : Nat, tres : Text }
.a2> update.old.a2> view A NeedsA f f2 f3 g.a2> todo
```
```ucm
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:
The transcript failed due to an error in the stanza above. The error is:
⚠️
⍟ These new definitions are ok to `add`:
Rec.tres : Rec -> Text
Rec.tres.modify : (Text ->{g} Text) -> Rec ->{g} Rec
Rec.tres.set : Text -> Rec -> Rec
⍟ These names already exist. You can `update` them to your
new definition:
structural type Rec
Rec.dos : Rec -> Nat
Rec.dos.modify : (Nat ->{g} Nat) -> Rec ->{g} Rec
Rec.dos.set : Nat -> Rec -> Rec
Rec.uno : Rec -> Nat
Rec.uno.modify : (Nat ->{g} Nat) -> Rec ->{g} Rec
Rec.uno.set : Nat -> Rec -> Rec
The following names were not found in the codebase. Check your spelling.
NeedsA
f
f2
f3
g
```
And checking that after updating this record, there's nothing `todo`:
```ucm
.> fork a3 a4
Done.
.a4> update.old
⍟ I've added these definitions:
Rec.tres : Rec -> Text
Rec.tres.modify : (Text ->{g} Text) -> Rec ->{g} Rec
Rec.tres.set : Text -> Rec -> Rec
⍟ I've updated these names to your new definition:
structural type Rec
Rec.dos : Rec -> Nat
Rec.dos.modify : (Nat ->{g} Nat) -> Rec ->{g} Rec
Rec.dos.set : Nat -> Rec -> Rec
Rec.uno : Rec -> Nat
Rec.uno.modify : (Nat ->{g} Nat) -> Rec ->{g} Rec
Rec.uno.set : Nat -> Rec -> Rec
.a4> todo
No conflicts or edits in progress.
```

View File

@ -87,185 +87,22 @@ and update the codebase to use the new type `Foo`...
```ucm
.subpath> view fooToInt
fooToInt : Foo -> Int
fooToInt _ = +42
```
### Preserving user type variables
We make a term that has a dependency on another term and also a non-redundant
user-provided type signature.
```unison
preserve.someTerm : Optional foo -> Optional foo
preserve.someTerm x = x
preserve.otherTerm : Optional baz -> Optional baz
preserve.otherTerm y = someTerm y
```
```ucm
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`:
preserve.otherTerm : Optional baz -> Optional baz
preserve.someTerm : Optional foo -> Optional foo
The following names were not found in the codebase. Check your spelling.
fooToInt
```
Add that to the codebase:
```ucm
.subpath> add
⍟ I've added these definitions:
🛑
The transcript failed due to an error in the stanza above. The error is:
⚠️
preserve.otherTerm : Optional baz -> Optional baz
preserve.someTerm : Optional foo -> Optional foo
The following names were not found in the codebase. Check your spelling.
fooToInt
```
Let's now edit the dependency:
```unison
preserve.someTerm : Optional x -> Optional x
preserve.someTerm _ = None
```
```ucm
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 names already exist. You can `update` them to your
new definition:
preserve.someTerm : Optional x -> Optional x
```
Update...
```ucm
.subpath> update.old
⍟ I've updated these names to your new definition:
preserve.someTerm : Optional x -> Optional x
```
Now the type of `someTerm` should be `Optional x -> Optional x` and the
type of `otherTerm` should remain the same.
```ucm
.subpath> view preserve.someTerm
preserve.someTerm : Optional x -> Optional x
preserve.someTerm _ = None
.subpath> view preserve.otherTerm
preserve.otherTerm : Optional baz -> Optional baz
preserve.otherTerm y = someTerm y
```
### Propagation only applies to the local branch
Cleaning up a bit...
```ucm
.> delete.namespace subpath
Done.
☝️ The namespace .subpath.lib is empty.
.subpath.lib> builtins.merge
Done.
```
Now, we make two terms, where one depends on the other.
```unison
one.someTerm : Optional foo -> Optional foo
one.someTerm x = x
one.otherTerm : Optional baz -> Optional baz
one.otherTerm y = someTerm y
```
```ucm
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`:
one.otherTerm : Optional baz -> Optional baz
one.someTerm : Optional foo -> Optional foo
```
We'll make two copies of this namespace.
```ucm
.subpath> add
⍟ I've added these definitions:
one.otherTerm : Optional baz -> Optional baz
one.someTerm : Optional foo -> Optional foo
.subpath> fork one two
Done.
```
Now let's edit one of the terms...
```unison
someTerm : Optional x -> Optional x
someTerm _ = None
```
```ucm
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`:
someTerm : Optional x -> Optional x
```
... in one of the namespaces...
```ucm
.subpath.one> update.old
⍟ I've updated these names to your new definition:
someTerm : #nirp5os0q6 x -> #nirp5os0q6 x
```
The other namespace should be left alone.
```ucm
.subpath> view two.someTerm
two.someTerm : Optional foo -> Optional foo
two.someTerm x = x
```

View File

@ -29,264 +29,16 @@ type MyType = MyType Text
.simple> todo
🚧
The namespace has 2 transitive dependent(s) left to upgrade.
Your edit frontier is the dependents of these definitions:
type #vijug0om28
#gjmq673r1v : Nat
I recommend working on them in the following order:
1. useMyType : Nat
2. useX : Nat
```
## A merge with conflicting updates.
```unison
x = 1
type MyType = MyType
```
Set up two branches with the same starting point.
Update `x` to a different term in each branch.
```unison
x = 2
type MyType = MyType Nat
```
```unison
x = 3
type MyType = MyType Int
```
```ucm
.mergeA> merge.old .mergeB
Here's what's changed in the current namespace after the
merge:
New name conflicts:
1. type MyType#ig1g2ka7lv
2. ┌ type MyType#8c6f40i3tj
3. └ type MyType#ig1g2ka7lv
4. MyType.MyType#ig1g2ka7lv#0 : Nat -> MyType#ig1g2ka7lv
5. ┌ MyType.MyType#8c6f40i3tj#0 : Int -> MyType#8c6f40i3tj
6. └ MyType.MyType#ig1g2ka7lv#0 : Nat -> MyType#ig1g2ka7lv
7. x#dcgdua2lj6 : Nat
8. ┌ x#dcgdua2lj6 : Nat
9. └ x#f3lgjvjqoo : Nat
Updates:
10. patch patch (added 2 updates)
Tip: You can use `todo` to see if this generated any work to
do in this namespace and `test` to run the tests. Or you
can use `undo` or `reflog` to undo the results of this
merge.
Applying changes from patch...
I tried to auto-apply the patch, but couldn't because it
contained contradictory entries.
.mergeA> todo
These definitions were edited differently in namespaces that
have been merged into this one. You'll have to tell me what to
use as the new definition:
The type 1. #8h7qq3ougl was replaced with
2. MyType#8c6f40i3tj
3. MyType#ig1g2ka7lv
The term 4. #gjmq673r1v was replaced with
5. x#dcgdua2lj6
6. x#f3lgjvjqoo
The term MyType.MyType has conflicting definitions:
7. MyType.MyType#8c6f40i3tj#0
8. MyType.MyType#ig1g2ka7lv#0
Tip: This occurs when merging branches that both independently
introduce the same name. Use `move.term` or `delete.term`
to resolve the conflicts.
```
## A named value that appears on the LHS of a patch isn't shown
```unison
foo = 801
```
```ucm
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 : Nat
```
```ucm
.lhs> add
⍟ I've added these definitions:
foo : Nat
```
```unison
foo = 802
```
```ucm
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 names already exist. You can `update` them to your
new definition:
foo : Nat
```
```ucm
.lhs> update.old
⍟ I've updated these names to your new definition:
foo : Nat
```
```unison
oldfoo = 801
```
```ucm
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`:
oldfoo : Nat
```
```ucm
.lhs> add
⍟ I've added these definitions:
oldfoo : Nat
.lhs> todo
No conflicts or edits in progress.
```
## A type-changing update to one element of a cycle, which doesn't propagate to the other
```unison
even = cases
0 -> true
n -> odd (drop 1 n)
odd = cases
0 -> false
n -> even (drop 1 n)
```
```ucm
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`:
even : Nat -> Boolean
odd : Nat -> Boolean
```
```ucm
.cycle2> add
⍟ I've added these definitions:
even : Nat -> Boolean
odd : Nat -> Boolean
```
```unison
even = 17
```
```ucm
🛑
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 names already exist. You can `update` them to your
new definition:
even : Nat
```
```ucm
.cycle2> update.old
⍟ I've updated these names to your new definition:
even : Nat
```
```ucm
.cycle2> todo
🚧
The namespace has 1 transitive dependent(s) left to upgrade.
Your edit frontier is the dependents of these definitions:
#kkohl7ba1e : Nat -> Boolean
I recommend working on them in the following order:
1. odd : Nat -> Boolean
```
The transcript was expecting an error in the stanza above, but did not encounter one.