Skip to content

Commit ec8ae53

Browse files
committed
deprecate cd, up, reset-root, add find-in
also hides unimplemented `update.builtins` removing some unnecessary `cd`s from these files produced different slurp output, because we are no longer moving away to typecheck, meaning different names are in scope at slurp time - propagate.md - sum-type-update-conflicts.md similarly, in `todo.md` it shifted the hashes for the same reason
1 parent b4f1486 commit ec8ae53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+194
-302
lines changed

scripts/check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ true \
66
&& stack exec transcripts \
77
&& stack exec unison transcript unison-src/transcripts-round-trip/main.md \
88
&& stack exec unison transcript unison-src/transcripts-manual/rewrites.md \
9-
&& stack exec integration-tests
9+
&& stack exec cli-integration-tests

unison-cli/src/Unison/Codebase/Editor/HandleInput.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,12 @@ handleFindI isVerbose fscope ws input = do
14371437
-- results may contain things in lib.
14381438
pped <- Cli.currentPrettyPrintEnvDecl
14391439
pure (pped, names)
1440+
FindLocalSubnamespace p -> do
1441+
path <- Cli.resolvePath p
1442+
branch0 <- Cli.getBranch0At path
1443+
let names = Branch.toNames branch0
1444+
pped <- Cli.currentPrettyPrintEnvDecl
1445+
pure (pped, names)
14401446
FindLocalAndDeps -> do
14411447
let names = Branch.toNames (Branch.withoutTransitiveLibs currentBranch0)
14421448
-- Don't exclude anything from the pretty printer, since the type signatures we print for

unison-cli/src/Unison/Codebase/Editor/Input.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Data.These (These)
3535
import U.Codebase.HashTags (CausalHash)
3636
import Unison.Codebase.Branch.Merge qualified as Branch
3737
import Unison.Codebase.Editor.RemoteRepo (ReadRemoteNamespace, WriteGitRepo, WriteRemoteNamespace)
38-
import Unison.Codebase.Path (Path')
38+
import Unison.Codebase.Path (Path, Path')
3939
import Unison.Codebase.Path qualified as Path
4040
import Unison.Codebase.Path.Parse qualified as Path
4141
import Unison.Codebase.PushBehavior (PushBehavior)
@@ -315,6 +315,7 @@ data OutputLocation
315315
data FindScope
316316
= FindLocal
317317
| FindLocalAndDeps
318+
| FindLocalSubnamespace Path
318319
| FindGlobal
319320
deriving stock (Eq, Show)
320321

unison-cli/src/Unison/CommandLine/InputPatterns.hs

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Unison.Cli.ProjectUtils qualified as ProjectUtils
3030
import Unison.Codebase (Codebase)
3131
import Unison.Codebase qualified as Codebase
3232
import Unison.Codebase.Branch.Merge qualified as Branch
33-
import Unison.Codebase.Editor.Input (DeleteOutput (..), DeleteTarget (..), Input)
33+
import Unison.Codebase.Editor.Input (DeleteOutput (..), DeleteTarget (..), FindScope (FindLocalSubnamespace), Input)
3434
import Unison.Codebase.Editor.Input qualified as Input
3535
import Unison.Codebase.Editor.Output.PushPull (PushPull (Pull, Push))
3636
import Unison.Codebase.Editor.Output.PushPull qualified as PushPull
@@ -124,7 +124,7 @@ updateBuiltins =
124124
InputPattern
125125
"builtins.update"
126126
[]
127-
I.Visible
127+
I.Hidden
128128
[]
129129
( "Adds all the builtins that are missing from this namespace, "
130130
<> "and deprecate the ones that don't exist in this version of Unison."
@@ -597,32 +597,55 @@ findAll = find' "find.all" Input.FindLocalAndDeps
597597
findGlobal :: InputPattern
598598
findGlobal = find' "find.global" Input.FindGlobal
599599

600+
findIn :: InputPattern
601+
findIn =
602+
InputPattern
603+
"find-in"
604+
[]
605+
I.Visible
606+
[("namespace", Required, namespaceArg)]
607+
findHelp
608+
\case
609+
p : args -> first P.text do
610+
p <- Path.parsePath p
611+
pure (Input.FindI False (FindLocalSubnamespace p) args)
612+
_ -> Left (I.help updateIn)
613+
614+
findHelp :: P.Pretty CT.ColorText
615+
findHelp =
616+
( P.wrapColumn2
617+
[ ("`find`", "lists all definitions in the current namespace."),
618+
( "`find foo`",
619+
"lists all definitions with a name similar to 'foo' in the current "
620+
<> "namespace (excluding those under 'lib')."
621+
),
622+
( "`find foo bar`",
623+
"lists all definitions with a name similar to 'foo' or 'bar' in the "
624+
<> "current namespace (excluding those under 'lib')."
625+
),
626+
("`find-in namespace`", "lists all definitions in the specified subnamespace."),
627+
( "`find-in namespace foo bar`",
628+
"lists all definitions with a name similar to 'foo' or 'bar' in the "
629+
<> "specified subnamespace."
630+
),
631+
( "find.all foo",
632+
"lists all definitions with a name similar to 'foo' in the current "
633+
<> "namespace (including one level of 'lib')."
634+
),
635+
( "find.global foo",
636+
"lists all definitions with a name similar to 'foo' in any namespace"
637+
)
638+
]
639+
)
640+
600641
find' :: String -> Input.FindScope -> InputPattern
601642
find' cmd fscope =
602643
InputPattern
603644
cmd
604645
[]
605646
I.Visible
606647
[("query", ZeroPlus, exactDefinitionArg)]
607-
( P.wrapColumn2
608-
[ ("`find`", "lists all definitions in the current namespace."),
609-
( "`find foo`",
610-
"lists all definitions with a name similar to 'foo' in the current "
611-
<> "namespace (excluding those under 'lib')."
612-
),
613-
( "`find foo bar`",
614-
"lists all definitions with a name similar to 'foo' or 'bar' in the "
615-
<> "current namespace (excluding those under 'lib')."
616-
),
617-
( "find.all foo",
618-
"lists all definitions with a name similar to 'foo' in the current "
619-
<> "namespace (including one level of 'lib')."
620-
),
621-
( "find.global foo",
622-
"lists all definitions with a name similar to 'foo' in any namespace"
623-
)
624-
]
625-
)
648+
findHelp
626649
(pure . Input.FindI False fscope)
627650

628651
findShallow :: InputPattern
@@ -968,11 +991,11 @@ aliasMany =
968991
up :: InputPattern
969992
up =
970993
InputPattern
971-
"up"
994+
"deprecated.up"
972995
[]
973996
I.Visible
974997
[]
975-
(P.wrapColumn2 [(makeExample up [], "move current path up one level")])
998+
(P.wrapColumn2 [(makeExample up [], "move current path up one level (deprecated)")])
976999
( \case
9771000
[] -> Right Input.UpI
9781001
_ -> Left (I.help up)
@@ -981,12 +1004,12 @@ up =
9811004
cd :: InputPattern
9821005
cd =
9831006
InputPattern
984-
"namespace"
985-
["cd", "j"]
1007+
"deprecated.cd"
1008+
["deprecated.namespace"]
9861009
I.Visible
9871010
[("namespace", Required, namespaceArg)]
9881011
( P.lines
989-
[ "Moves your perspective to a different namespace.",
1012+
[ "Moves your perspective to a different namespace. Deprecated for now because too many important things depend on your perspective selection.",
9901013
"",
9911014
P.wrapColumn2
9921015
[ ( makeExample cd ["foo.bar"],
@@ -1020,7 +1043,7 @@ back =
10201043
[]
10211044
( P.wrapColumn2
10221045
[ ( makeExample back [],
1023-
"undoes the last" <> makeExample' cd <> "command."
1046+
"undoes the last" <> makeExample' projectSwitch <> "or" <> makeExample' cd <> "command."
10241047
)
10251048
]
10261049
)
@@ -1231,17 +1254,20 @@ reset =
12311254
resetRoot :: InputPattern
12321255
resetRoot =
12331256
InputPattern
1234-
"reset-root"
1257+
"deprecated.reset-root"
12351258
[]
12361259
I.Visible
12371260
[("namespace or hash to reset to", Required, namespaceArg)]
1238-
( P.wrapColumn2
1239-
[ ( makeExample resetRoot [".foo"],
1240-
"Reset the root namespace (along with its history) to that of the `.foo` namespace."
1241-
),
1242-
( makeExample resetRoot ["#9dndk3kbsk13nbpeu"],
1243-
"Reset the root namespace (along with its history) to that of the namespace with hash `#9dndk3kbsk13nbpeu`."
1244-
)
1261+
( P.lines
1262+
[ "Deprecated because it's not compatible with the introduction of projects.",
1263+
P.wrapColumn2
1264+
[ ( makeExample resetRoot [".foo"],
1265+
"Reset the root namespace (along with its history) to that of the `.foo` namespace. Deprecated"
1266+
),
1267+
( makeExample resetRoot ["#9dndk3kbsk13nbpeu"],
1268+
"Reset the root namespace (along with its history) to that of the namespace with hash `#9dndk3kbsk13nbpeu`."
1269+
)
1270+
]
12451271
]
12461272
)
12471273
\case
@@ -2982,6 +3008,7 @@ validInputs =
29823008
editNamespace,
29833009
execute,
29843010
find,
3011+
findIn,
29853012
findAll,
29863013
findGlobal,
29873014
findPatch,

unison-cli/src/Unison/CommandLine/OutputMessages.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,8 @@ notifyUser dir = \case
971971
pure . P.warnCallout . P.lines $
972972
[ "Are you sure you want to clear away everything?",
973973
"You could use "
974-
<> IP.makeExample' IP.cd
975-
<> " to switch to a new namespace instead."
974+
<> IP.makeExample' IP.projectCreate
975+
<> " to switch to a new project instead."
976976
]
977977
DeleteBranchConfirmation _uniqueDeletions -> error "todo"
978978
-- let

unison-cli/tests/Unison/Test/GitSync.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ test =
286286
```ucm
287287
.> pull git(${repo})
288288
.> history
289-
.> reset-root #l43v9nr16v
289+
.> deprecated.reset-root #l43v9nr16v
290290
.> history
291291
```
292292
|] -- Not sure why this hash is here.

unison-src/transcripts-using-base/_base.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ transcripts which contain less boilerplate.
1212
```ucm:hide
1313
.> builtins.merge
1414
.> builtins.mergeio
15-
.> cd builtin
1615
.> load unison-src/transcripts-using-base/base.u
1716
.> add
1817
```
@@ -55,4 +54,3 @@ testAutoClean _ =
5554
.> add
5655
.> io.test testAutoClean
5756
```
58-

unison-src/transcripts-using-base/binary-encoding-nats.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
```ucm:hide
33
.> builtins.merge
44
.> builtins.mergeio
5-
.> cd builtin
65
.> load unison-src/transcripts-using-base/base.u
76
.> add
87
.> find

unison-src/transcripts-using-base/hashing.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
```ucm:hide
44
.> builtins.merge
5-
.> cd builtin
65
```
76

87
Unison has cryptographic builtins for hashing and computing [HMACs](https://en.wikipedia.org/wiki/HMAC) (hash-based message authentication codes). This transcript shows their usage and has some test cases.
@@ -48,8 +47,7 @@ ex5 = crypto.hmac Sha2_256 mysecret f |> hex
4847
And here's the full API:
4948

5049
```ucm
51-
.builtin.crypto> find
52-
.> cd .
50+
.> find-in builtin.crypto
5351
```
5452

5553
Note that the universal versions of `hash` and `hmac` are currently unimplemented and will bomb at runtime:
@@ -263,4 +261,3 @@ test> md5.tests.ex3 =
263261
```ucm
264262
.> test
265263
```
266-

unison-src/transcripts-using-base/hashing.output.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@ ex5 = crypto.hmac Sha2_256 mysecret f |> hex
120120
And here's the full API:
121121

122122
```ucm
123-
.builtin.crypto> find
123+
.> find-in builtin.crypto
124124
125125
1. type CryptoFailure
126-
2. Ed25519.sign.impl : ##Bytes
127-
-> ##Bytes
128-
-> ##Bytes
129-
-> #0o7mf021fo #r29dja8j9d ##Bytes
130-
3. Ed25519.verify.impl : ##Bytes
131-
-> ##Bytes
132-
-> ##Bytes
133-
-> #0o7mf021fo #r29dja8j9d ##Boolean
134-
4. hash : HashAlgorithm -> a -> ##Bytes
126+
2. Ed25519.sign.impl : Bytes
127+
-> Bytes
128+
-> Bytes
129+
-> Either Failure Bytes
130+
3. Ed25519.verify.impl : Bytes
131+
-> Bytes
132+
-> Bytes
133+
-> Either Failure Boolean
134+
4. hash : HashAlgorithm -> a -> Bytes
135135
5. builtin type HashAlgorithm
136136
6. HashAlgorithm.Blake2b_256 : HashAlgorithm
137137
7. HashAlgorithm.Blake2b_512 : HashAlgorithm
@@ -142,13 +142,11 @@ And here's the full API:
142142
12. HashAlgorithm.Sha2_512 : HashAlgorithm
143143
13. HashAlgorithm.Sha3_256 : HashAlgorithm
144144
14. HashAlgorithm.Sha3_512 : HashAlgorithm
145-
15. hashBytes : HashAlgorithm -> ##Bytes -> ##Bytes
146-
16. hmac : HashAlgorithm -> ##Bytes -> a -> ##Bytes
147-
17. hmacBytes : HashAlgorithm -> ##Bytes -> ##Bytes -> ##Bytes
145+
15. hashBytes : HashAlgorithm -> Bytes -> Bytes
146+
16. hmac : HashAlgorithm -> Bytes -> a -> Bytes
147+
17. hmacBytes : HashAlgorithm -> Bytes -> Bytes -> Bytes
148148
149149
150-
.> cd .
151-
152150
```
153151
Note that the universal versions of `hash` and `hmac` are currently unimplemented and will bomb at runtime:
154152

0 commit comments

Comments
 (0)