mirror of
https://github.com/unisonweb/unison.git
synced 2024-08-15 13:30:27 +03:00
Edit transcripts to be in projects
This commit is contained in:
parent
5ca1eb3b8d
commit
26a0bf7b40
@ -7,7 +7,7 @@ id2 x =
|
||||
```
|
||||
|
||||
```ucm
|
||||
.scratch> add
|
||||
scratch/main> add
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -7,5 +7,5 @@ mynamespace.dependsOnText = external.mynat Nat.+ 10
|
||||
|
||||
```ucm
|
||||
scratch/main> add
|
||||
.mynamespace> namespace.dependencies
|
||||
scratch/main mynamespace> namespace.dependencies
|
||||
```
|
||||
|
@ -9,16 +9,16 @@ mynamespace.dependsOnText = external.mynat Nat.+ 10
|
||||
scratch/main> add
|
||||
|
||||
⍟ I've added these definitions:
|
||||
|
||||
|
||||
external.mynat : Nat
|
||||
mynamespace.dependsOnText : Nat
|
||||
|
||||
☝️ The namespace .mynamespace is empty.
|
||||
|
||||
.mynamespace> namespace.dependencies
|
||||
scratch/main mynamespace> namespace.dependencies
|
||||
|
||||
⚠️
|
||||
|
||||
|
||||
.mynamespace is an empty namespace.
|
||||
|
||||
```
|
||||
@ -31,6 +31,6 @@ The transcript failed due to an error in the stanza above. The error is:
|
||||
|
||||
|
||||
⚠️
|
||||
|
||||
|
||||
.mynamespace is an empty namespace.
|
||||
|
||||
|
@ -95,7 +95,7 @@ List.takeWhile p xs =
|
||||
go xs []
|
||||
```
|
||||
```ucm:hide
|
||||
.stuff> add
|
||||
scratch/main stuff> add
|
||||
```
|
||||
|
||||
The `alias.many` command can be used to copy definitions from the current namespace into your curated one.
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Get Definitions Test
|
||||
|
||||
```ucm:hide
|
||||
.nested> builtins.mergeio
|
||||
scratch/main nested> builtins.mergeio
|
||||
```
|
||||
|
||||
```unison:hide
|
||||
@ -10,7 +10,7 @@ names.x = 42
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.nested> add
|
||||
scratch/main nested> add
|
||||
```
|
||||
|
||||
```api
|
||||
@ -25,7 +25,7 @@ GET /api/non-project-code/getDefinition?names=%23qkhkl0n238&relativeTo=nested
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.doctest> builtins.mergeio
|
||||
scratch/main doctest> builtins.mergeio
|
||||
```
|
||||
|
||||
```unison:hide
|
||||
@ -38,7 +38,7 @@ otherstuff.thing = "A different thing"
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.doctest> add
|
||||
scratch/main doctest> add
|
||||
```
|
||||
|
||||
Only docs for the term we request should be returned, even if there are other term docs with the same suffix.
|
||||
|
@ -12,8 +12,8 @@ someterm = 18
|
||||
```
|
||||
|
||||
```ucm
|
||||
.some.loose.code.lib> builtins.merge
|
||||
.some.loose.code> add
|
||||
scratch/main some.loose.code.lib> builtins.merge
|
||||
scratch/main some.loose.code> add
|
||||
```
|
||||
|
||||
Now, the `branch` demo:
|
||||
@ -40,7 +40,7 @@ bar/main> branch foo/main topic2
|
||||
bar/main> branch foo/main /topic3
|
||||
scratch/main> branch foo/main bar/topic4
|
||||
|
||||
.some.loose.code> branch foo/topic13
|
||||
scratch/main some.loose.code> branch foo/topic13
|
||||
foo/main> branch .some.loose.code topic14
|
||||
foo/main> branch .some.loose.code /topic15
|
||||
scratch/main> branch .some.loose.code foo/topic16
|
||||
|
@ -1,6 +1,6 @@
|
||||
The `builtins.merge` command adds the known builtins to a `builtin` subnamespace within the current namespace.
|
||||
|
||||
```ucm
|
||||
.tmp> builtins.merge
|
||||
.tmp> ls builtin
|
||||
scratch/main tmp> builtins.merge
|
||||
scratch/main tmp> ls builtin
|
||||
```
|
||||
|
@ -5,6 +5,6 @@ scratch/main> builtins.mergeio
|
||||
Demonstrating `create.author`:
|
||||
|
||||
```ucm
|
||||
.foo> create.author alicecoder "Alice McGee"
|
||||
.foo> view 2
|
||||
scratch/main foo> create.author alicecoder "Alice McGee"
|
||||
scratch/main foo> view 2
|
||||
```
|
||||
|
@ -35,7 +35,7 @@ foo = 1
|
||||
```
|
||||
|
||||
```ucm
|
||||
.a> add
|
||||
scratch/main a> add
|
||||
```
|
||||
|
||||
```unison:hide
|
||||
@ -43,8 +43,8 @@ foo = 2
|
||||
```
|
||||
|
||||
```ucm
|
||||
.b> add
|
||||
.a> merge.old .b
|
||||
scratch/main b> add
|
||||
scratch/main a> merge.old .b
|
||||
```
|
||||
|
||||
A delete should remove both versions of the term.
|
||||
@ -54,7 +54,7 @@ scratch/main> delete.verbose a.foo
|
||||
```
|
||||
|
||||
```ucm:error
|
||||
.a> ls
|
||||
scratch/main a> ls
|
||||
```
|
||||
|
||||
Let's repeat all that on a type, for completeness.
|
||||
@ -64,7 +64,7 @@ structural type Foo = Foo ()
|
||||
```
|
||||
|
||||
```ucm
|
||||
.a> add
|
||||
scratch/main a> add
|
||||
```
|
||||
|
||||
```unison:hide
|
||||
@ -72,8 +72,8 @@ structural type Foo = Foo
|
||||
```
|
||||
|
||||
```ucm
|
||||
.b> add
|
||||
.a> merge.old .b
|
||||
scratch/main b> add
|
||||
scratch/main a> merge.old .b
|
||||
```
|
||||
|
||||
```ucm
|
||||
|
@ -109,7 +109,7 @@ a = 333
|
||||
b = a + 1
|
||||
```
|
||||
```ucm
|
||||
.nsx> add
|
||||
scratch/main nsx> add
|
||||
scratch/main> fork nsx nsy
|
||||
scratch/main> fork nsx nsz
|
||||
```
|
||||
@ -117,13 +117,13 @@ scratch/main> fork nsx nsz
|
||||
a = 444
|
||||
```
|
||||
```ucm
|
||||
.nsy> update.old
|
||||
scratch/main nsy> update.old
|
||||
```
|
||||
```unison:hide
|
||||
a = 555
|
||||
```
|
||||
```ucm
|
||||
.nsz> update.old
|
||||
scratch/main nsz> update.old
|
||||
scratch/main> merge.old nsy nsw
|
||||
```
|
||||
```ucm:error
|
||||
@ -131,7 +131,7 @@ scratch/main> merge.old nsz nsw
|
||||
```
|
||||
```ucm
|
||||
scratch/main> diff.namespace nsx nsw
|
||||
.nsw> view a b
|
||||
scratch/main nsw> view a b
|
||||
```
|
||||
|
||||
## Should be able to diff a namespace hash from history.
|
||||
@ -141,7 +141,7 @@ x = 1
|
||||
```
|
||||
|
||||
```ucm
|
||||
.hashdiff> add
|
||||
scratch/main hashdiff> add
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -149,9 +149,9 @@ y = 2
|
||||
```
|
||||
|
||||
```ucm
|
||||
.hashdiff> add
|
||||
.hashdiff> history
|
||||
.hashdiff> diff.namespace 2 1
|
||||
scratch/main hashdiff> add
|
||||
scratch/main hashdiff> history
|
||||
scratch/main hashdiff> diff.namespace 2 1
|
||||
```
|
||||
|
||||
##
|
||||
|
@ -7,7 +7,7 @@ scratch/main> builtins.merge
|
||||
Unison documentation is written in Unison. Documentation is a value of the following type:
|
||||
|
||||
```ucm
|
||||
.builtin> view Doc
|
||||
scratch/main builtin> view Doc
|
||||
```
|
||||
|
||||
You can create these `Doc` values with ordinary code, or you can use the special syntax. A value of structural type `Doc` can be created via syntax like:
|
||||
@ -42,7 +42,7 @@ List.take.ex2 = take 2 [1,2,3,4,5]
|
||||
```
|
||||
|
||||
```ucm
|
||||
.builtin> add
|
||||
scratch/main builtin> add
|
||||
```
|
||||
|
||||
And now let's write our docs and reference these examples:
|
||||
@ -67,17 +67,17 @@ List.take.doc = [:
|
||||
Let's add it to the codebase.
|
||||
|
||||
```ucm
|
||||
.builtin> add
|
||||
scratch/main builtin> add
|
||||
```
|
||||
|
||||
We can view it with `docs`, which shows the `Doc` value that is associated with a definition.
|
||||
|
||||
```ucm
|
||||
.builtin> docs List.take
|
||||
scratch/main builtin> docs List.take
|
||||
```
|
||||
|
||||
Note that if we view the source of the documentation, the various references are *not* expanded.
|
||||
|
||||
```ucm
|
||||
.builtin> view List.take
|
||||
scratch/main builtin> view List.take
|
||||
```
|
||||
|
@ -31,9 +31,9 @@ scratch/main> history mynamespace
|
||||
Merging an empty namespace should be a no-op
|
||||
|
||||
```ucm:error
|
||||
.empty> history
|
||||
.empty> merge.old .mynamespace
|
||||
.empty> history
|
||||
scratch/main empty> history
|
||||
scratch/main empty> merge.old .mynamespace
|
||||
scratch/main empty> history
|
||||
```
|
||||
|
||||
Add and then delete a term to add some history to a deleted namespace.
|
||||
|
@ -13,15 +13,15 @@ scratch/main> ls
|
||||
Technically, the definitions all exist, but they have no names. `builtins.merge` brings them into existence, under the current namespace:
|
||||
|
||||
```ucm
|
||||
.foo> builtins.merge
|
||||
.foo> ls
|
||||
scratch/main foo> builtins.merge
|
||||
scratch/main foo> ls
|
||||
```
|
||||
|
||||
And for a limited time, you can get even more builtin goodies:
|
||||
|
||||
```ucm
|
||||
.foo> builtins.mergeio
|
||||
.foo> ls
|
||||
scratch/main foo> builtins.mergeio
|
||||
scratch/main foo> ls
|
||||
```
|
||||
|
||||
More typically, you'd start out by pulling `base`.
|
||||
|
@ -32,8 +32,8 @@ scratch/main> view 1
|
||||
```
|
||||
|
||||
```ucm
|
||||
.somewhere> find bar
|
||||
.somewhere> find.global bar
|
||||
scratch/main somewhere> find bar
|
||||
scratch/main somewhere> find.global bar
|
||||
```
|
||||
|
||||
```ucm
|
||||
|
@ -38,7 +38,7 @@ scratch/main> merge.old y.b y.a
|
||||
scratch/main> delete.term.verbose 1
|
||||
scratch/main> merge.old y m
|
||||
scratch/main> merge.old.squash y s
|
||||
.s> todo
|
||||
.m> todo
|
||||
scratch/main s> todo
|
||||
scratch/main m> todo
|
||||
```
|
||||
|
||||
|
@ -39,7 +39,7 @@ scratch/main> delete.term.verbose a.delete3
|
||||
scratch/main> delete.type.verbose a.Delete4
|
||||
scratch/main> alias.term .builtin.Float.+ newbranchA.dontDelete
|
||||
scratch/main> merge.old newbranchA a
|
||||
.a> find
|
||||
scratch/main a> find
|
||||
```
|
||||
|
||||
Meanwhile, `a2` adds some other unrelated terms, some via merging in namespaces with little history. When merging `a2` back into `a`, the deletes from their common history should be respected.
|
||||
@ -64,8 +64,8 @@ scratch/main> merge.old.squash a2 asquash
|
||||
At this point, all the things that `a` has deleted (`delete1`, `delete2`, etc) should be deleted in both the merged and squashed results. Let's verify this:
|
||||
|
||||
```ucm
|
||||
.a> find
|
||||
.asquash> find
|
||||
scratch/main a> find
|
||||
scratch/main asquash> find
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
```ucm:hide
|
||||
.a> builtins.merge
|
||||
scratch/main a> builtins.merge
|
||||
```
|
||||
|
||||
This transcript checks that updates to data types propagate successfully to dependent types and dependent terms that do pattern matching. First let's create some types and terms:
|
||||
@ -38,7 +38,7 @@ g = cases
|
||||
We'll make our edits in a fork of the `a` namespace:
|
||||
|
||||
```ucm
|
||||
.a> add
|
||||
scratch/main a> add
|
||||
scratch/main> fork a a2
|
||||
```
|
||||
|
||||
|
@ -34,7 +34,7 @@ g = cases
|
||||
We'll make our edits in a fork of the `a` namespace:
|
||||
|
||||
```ucm
|
||||
.a> add
|
||||
scratch/main a> add
|
||||
|
||||
⍟ I've added these definitions:
|
||||
|
||||
|
@ -12,7 +12,7 @@ If a fuzzy resolver doesn't have any options available it should print a message
|
||||
opening an empty fuzzy-select.
|
||||
|
||||
```ucm:error
|
||||
.empty> view
|
||||
scratch/main empty> view
|
||||
```
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ opening an empty fuzzy-select.
|
||||
```ucm
|
||||
☝️ The namespace .empty is empty.
|
||||
|
||||
.empty> view
|
||||
scratch/main empty> view
|
||||
|
||||
⚠️
|
||||
|
||||
@ -35,7 +35,7 @@ Definition args
|
||||
scratch/main> add
|
||||
|
||||
⍟ I've added these definitions:
|
||||
|
||||
|
||||
nested.optionTwo : ##Nat
|
||||
optionOne : ##Nat
|
||||
|
||||
@ -66,7 +66,7 @@ Project Branch args
|
||||
myproject/main> branch mybranch
|
||||
|
||||
Done. I've created the mybranch branch based off of main.
|
||||
|
||||
|
||||
Tip: To merge your work back into the main branch, first
|
||||
`switch /main` then `merge /mybranch`.
|
||||
|
||||
|
@ -3,7 +3,7 @@ unique type Foo = Foo
|
||||
```
|
||||
|
||||
```ucm
|
||||
.a.b> add
|
||||
scratch/main a.b> add
|
||||
scratch/main> fork .a.b .c.d.f
|
||||
.c.g.f>
|
||||
```
|
||||
@ -13,7 +13,7 @@ unique type Foo = Foo
|
||||
```
|
||||
|
||||
```ucm
|
||||
.c.g.f> add
|
||||
scratch/main c.g.f> add
|
||||
.c>
|
||||
```
|
||||
|
||||
@ -22,7 +22,7 @@ foo = .d.f.Foo.Foo
|
||||
```
|
||||
|
||||
```ucm
|
||||
.c> add
|
||||
scratch/main c> add
|
||||
```
|
||||
|
||||
At this point we have:
|
||||
@ -40,5 +40,5 @@ namespace rooted at `.c`.
|
||||
|
||||
```ucm
|
||||
scratch/main> ls c
|
||||
.c> ls
|
||||
scratch/main c> ls
|
||||
```
|
||||
|
@ -9,7 +9,7 @@ a = 1
|
||||
```
|
||||
|
||||
```ucm
|
||||
.x> add
|
||||
scratch/main x> add
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -17,7 +17,7 @@ b = 2
|
||||
```
|
||||
|
||||
```ucm
|
||||
.x> add
|
||||
scratch/main x> add
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -25,7 +25,7 @@ b = 2
|
||||
```
|
||||
|
||||
```ucm
|
||||
.y> add
|
||||
scratch/main y> add
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -33,7 +33,7 @@ a = 1
|
||||
```
|
||||
|
||||
```ucm
|
||||
.y> add
|
||||
scratch/main y> add
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -42,7 +42,7 @@ b = 2
|
||||
```
|
||||
|
||||
```ucm
|
||||
.z> add
|
||||
scratch/main z> add
|
||||
scratch/main> merge.old x y
|
||||
scratch/main> merge.old y z
|
||||
scratch/main> history z
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Forking and merging namespaces in `ucm`
|
||||
|
||||
```ucm:hide
|
||||
.master> builtins.merge
|
||||
scratch/main master> builtins.merge
|
||||
```
|
||||
|
||||
The Unison namespace is a versioned tree of names that map to Unison definitions. You can change this namespace and fork and merge subtrees of it. Let's start by introducing a few definitions into a new namespace, `foo`:
|
||||
@ -40,8 +40,8 @@ y = "hello"
|
||||
|
||||
```ucm
|
||||
.feature1> add
|
||||
.master> merge.old .feature1
|
||||
.master> view y
|
||||
scratch/main master> merge.old .feature1
|
||||
scratch/main master> view y
|
||||
```
|
||||
|
||||
> Note: `merge src`, with one argument, merges `src` into the current namespace. You can also do `merge src dest` to merge into any destination namespace.
|
||||
|
@ -44,10 +44,10 @@ bonk = 5
|
||||
```
|
||||
|
||||
```ucm
|
||||
.z> builtins.merge
|
||||
.z> add
|
||||
.z> move bonk zonk
|
||||
.z> ls
|
||||
z/main> builtins.merge
|
||||
z/main> add
|
||||
z/main> move bonk zonk
|
||||
z/main> ls
|
||||
```
|
||||
|
||||
## Happy Path - Just namespace
|
||||
@ -57,11 +57,11 @@ bonk.zonk = 5
|
||||
```
|
||||
|
||||
```ucm
|
||||
.a> builtins.merge
|
||||
.a> add
|
||||
.a> move bonk zonk
|
||||
.a> ls
|
||||
.a> view zonk.zonk
|
||||
a/main> builtins.merge
|
||||
a/main> add
|
||||
a/main> move bonk zonk
|
||||
a/main> ls
|
||||
a/main> view zonk.zonk
|
||||
```
|
||||
|
||||
## Sad Path - No term, type, or namespace named src
|
||||
|
@ -1,9 +1,9 @@
|
||||
# Tests for `move.namespace`
|
||||
|
||||
```ucm:hide
|
||||
.happy> builtins.merge
|
||||
.history> builtins.merge
|
||||
.existing> builtins.merge
|
||||
scratch/main happy> builtins.merge
|
||||
scratch/main history> builtins.merge
|
||||
scratch/main existing> builtins.merge
|
||||
```
|
||||
|
||||
## Happy path
|
||||
@ -16,7 +16,7 @@ unique type a.T = T
|
||||
```
|
||||
|
||||
```ucm
|
||||
.happy> add
|
||||
scratch/main happy> add
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -25,15 +25,15 @@ unique type a.T = T1 | T2
|
||||
```
|
||||
|
||||
```ucm
|
||||
.happy> update
|
||||
scratch/main happy> update
|
||||
```
|
||||
|
||||
Should be able to move the namespace, including its types, terms, and sub-namespaces.
|
||||
|
||||
```ucm
|
||||
.happy> move.namespace a b
|
||||
.happy> ls b
|
||||
.happy> history b
|
||||
scratch/main happy> move.namespace a b
|
||||
scratch/main happy> ls b
|
||||
scratch/main happy> history b
|
||||
```
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ b.termInB = 10
|
||||
```
|
||||
|
||||
```ucm
|
||||
.history> add
|
||||
scratch/main history> add
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -57,24 +57,24 @@ b.termInB = 11
|
||||
```
|
||||
|
||||
```ucm
|
||||
.history> update
|
||||
scratch/main history> update
|
||||
```
|
||||
|
||||
Deleting a namespace should not leave behind any history,
|
||||
if we move another to that location we expect the history to simply be the history
|
||||
of the moved namespace.
|
||||
of the moved namespace.
|
||||
|
||||
```ucm
|
||||
.history> delete.namespace b
|
||||
.history> move.namespace a b
|
||||
scratch/main history> delete.namespace b
|
||||
scratch/main history> move.namespace a b
|
||||
-- Should be the history from 'a'
|
||||
.history> history b
|
||||
scratch/main history> history b
|
||||
-- Should be empty
|
||||
.history> history a
|
||||
scratch/main history> history a
|
||||
```
|
||||
|
||||
|
||||
## Moving over an existing branch
|
||||
## Moving over an existing branch
|
||||
|
||||
Create some namespace and add some history to them
|
||||
|
||||
@ -84,7 +84,7 @@ b.termInB = 10
|
||||
```
|
||||
|
||||
```ucm
|
||||
.existing> add
|
||||
scratch/main existing> add
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -93,11 +93,11 @@ b.termInB = 11
|
||||
```
|
||||
|
||||
```ucm
|
||||
.existing> update
|
||||
.existing> move.namespace a b
|
||||
scratch/main existing> update
|
||||
scratch/main existing> move.namespace a b
|
||||
```
|
||||
|
||||
## Moving the Root
|
||||
## Moving the Root
|
||||
|
||||
I should be able to move the root into a sub-namespace
|
||||
|
||||
|
@ -5,10 +5,10 @@ This transcript shows how the pretty-printer picks names for a hash when multipl
|
||||
3. Otherwise if there are multiple names with a minimal number of segments, compare the names alphabetically.
|
||||
|
||||
```ucm:hide
|
||||
.a> builtins.merge
|
||||
.a2> builtins.merge
|
||||
.a3> builtins.merge
|
||||
.biasing> builtins.merge
|
||||
scratch/main a> builtins.merge
|
||||
scratch/main a2> builtins.merge
|
||||
scratch/main a3> builtins.merge
|
||||
scratch/main biasing> builtins.merge
|
||||
```
|
||||
|
||||
```unison:hide
|
||||
@ -19,9 +19,9 @@ b = 0 + 1
|
||||
Will add `a` and `b` to the codebase and give `b` a longer (in terms of segment length alias), and show that it isn't used when viewing `a`:
|
||||
|
||||
```ucm
|
||||
.a> add
|
||||
.a> alias.term b aaa.but.more.segments
|
||||
.a> view a
|
||||
scratch/main a> add
|
||||
scratch/main a> alias.term b aaa.but.more.segments
|
||||
scratch/main a> view a
|
||||
```
|
||||
|
||||
Next let's introduce a conflicting symbol and show that its hash qualified name isn't used when it has an unconflicted name:
|
||||
@ -37,11 +37,11 @@ d = c + 10
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.a2> builtins.merge
|
||||
scratch/main a2> builtins.merge
|
||||
```
|
||||
```ucm
|
||||
.a2> add
|
||||
.a2> alias.term c long.name.but.shortest.suffixification
|
||||
scratch/main a2> add
|
||||
scratch/main a2> alias.term c long.name.but.shortest.suffixification
|
||||
```
|
||||
|
||||
```unison:hide
|
||||
@ -50,8 +50,8 @@ d = c + 10
|
||||
```
|
||||
|
||||
```ucm
|
||||
.a3> add
|
||||
.a3> merge.old .a2 .a3
|
||||
scratch/main a3> add
|
||||
scratch/main a3> merge.old .a2 .a3
|
||||
```
|
||||
|
||||
At this point, `a3` is conflicted for symbols `c` and `d`, so those are deprioritized.
|
||||
@ -74,11 +74,11 @@ a = 10
|
||||
```
|
||||
|
||||
```ucm
|
||||
.biasing> add
|
||||
scratch/main biasing> add
|
||||
-- Despite being saved with name `a`,
|
||||
-- the pretty printer should prefer the suffixified 'deeply.nested.num name' over the shallow 'a'.
|
||||
-- It's closer to the term being printed.
|
||||
.biasing> view deeply.nested.term
|
||||
scratch/main biasing> view deeply.nested.term
|
||||
```
|
||||
|
||||
Add another term with `num` suffix to force longer suffixification of `deeply.nested.num`
|
||||
@ -88,8 +88,8 @@ other.num = 20
|
||||
```
|
||||
|
||||
```ucm
|
||||
.biasing> add
|
||||
scratch/main biasing> add
|
||||
-- nested.num should be preferred over the shorter name `a` due to biasing
|
||||
-- because `deeply.nested.num` is nearby to the term being viewed.
|
||||
.biasing> view deeply.nested.term
|
||||
scratch/main biasing> view deeply.nested.term
|
||||
```
|
||||
|
@ -22,11 +22,11 @@ scratch/main> add
|
||||
```ucm
|
||||
-- We can search by suffix and find all definitions named 'x', and each of their aliases respectively.
|
||||
-- But we don't see somewhere.z which is has the same value but is out of our namespace
|
||||
.some> names x
|
||||
scratch/main some> names x
|
||||
-- We can search by hash, and see all aliases of that hash
|
||||
.some> names #gjmq673r1v
|
||||
scratch/main some> names #gjmq673r1v
|
||||
-- If the query is absolute, treat it as a `names.global`
|
||||
.some> names .some.place.x
|
||||
scratch/main some> names .some.place.x
|
||||
```
|
||||
|
||||
`names.global` searches from the root, and absolutely qualifies results
|
||||
@ -34,9 +34,9 @@ scratch/main> add
|
||||
|
||||
```ucm
|
||||
-- We can search by suffix and find all definitions in the codebase named 'x', and each of their aliases respectively.
|
||||
.some> names.global x
|
||||
scratch/main some> names.global x
|
||||
-- We can search by hash, and see all aliases of that hash in the codebase
|
||||
.some> names.global #gjmq673r1v
|
||||
scratch/main some> names.global #gjmq673r1v
|
||||
-- We can search using an absolute name
|
||||
.some> names.global .some.place.x
|
||||
scratch/main some> names.global .some.place.x
|
||||
```
|
||||
|
@ -19,9 +19,9 @@ somewhere.y = 2
|
||||
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`:
|
||||
|
||||
|
||||
some.otherplace.x : ##Nat
|
||||
some.otherplace.y : ##Nat
|
||||
some.place.x : ##Nat
|
||||
@ -33,7 +33,7 @@ somewhere.y = 2
|
||||
scratch/main> add
|
||||
|
||||
⍟ I've added these definitions:
|
||||
|
||||
|
||||
some.otherplace.x : ##Nat
|
||||
some.otherplace.y : ##Nat
|
||||
some.place.x : ##Nat
|
||||
@ -48,12 +48,12 @@ scratch/main> add
|
||||
-- But we don't see somewhere.z which is has the same value but is out of our namespace
|
||||
☝️ The namespace .some is empty.
|
||||
|
||||
.some> names x
|
||||
scratch/main some> names x
|
||||
|
||||
😶
|
||||
|
||||
|
||||
I couldn't find anything by that name.
|
||||
|
||||
|
||||
Tip: Use `names.global` to see more results.
|
||||
|
||||
```
|
||||
@ -69,8 +69,8 @@ The transcript failed due to an error in the stanza above. The error is:
|
||||
|
||||
|
||||
😶
|
||||
|
||||
|
||||
I couldn't find anything by that name.
|
||||
|
||||
|
||||
Tip: Use `names.global` to see more results.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Using numbered arguments in UCM
|
||||
|
||||
```ucm:hide
|
||||
.temp> alias.type ##Text Text
|
||||
scratch/main temp> alias.type ##Text Text
|
||||
```
|
||||
|
||||
First lets add some contents to our codebase.
|
||||
@ -16,41 +16,41 @@ corge = "corge"
|
||||
```
|
||||
|
||||
```ucm
|
||||
.temp> add
|
||||
scratch/main temp> add
|
||||
```
|
||||
|
||||
We can get the list of things in the namespace, and UCM will give us a numbered
|
||||
list:
|
||||
|
||||
```ucm
|
||||
.temp> find
|
||||
scratch/main temp> find
|
||||
```
|
||||
|
||||
We can ask to `view` the second element of this list:
|
||||
|
||||
```ucm
|
||||
.temp> find
|
||||
.temp> view 2
|
||||
scratch/main temp> find
|
||||
scratch/main temp> view 2
|
||||
```
|
||||
|
||||
And we can `view` multiple elements by separating with spaces:
|
||||
|
||||
```ucm
|
||||
.temp> find
|
||||
.temp> view 2 3 5
|
||||
scratch/main temp> find
|
||||
scratch/main temp> view 2 3 5
|
||||
```
|
||||
|
||||
We can also ask for a range:
|
||||
|
||||
```ucm
|
||||
.temp> find
|
||||
.temp> view 2-4
|
||||
scratch/main temp> find
|
||||
scratch/main temp> view 2-4
|
||||
```
|
||||
|
||||
And we can ask for multiple ranges and use mix of ranges and numbers:
|
||||
|
||||
```ucm
|
||||
.temp> find
|
||||
.temp> view 1-3 4 5-6
|
||||
scratch/main temp> find
|
||||
scratch/main temp> view 1-3 4 5-6
|
||||
```
|
||||
|
||||
|
@ -9,7 +9,7 @@ zonk = 0
|
||||
```
|
||||
|
||||
```ucm
|
||||
.foo> add
|
||||
scratch/main foo> add
|
||||
scratch/main> project.create-empty foo
|
||||
scratch/main> merge.old foo foo/main
|
||||
```
|
||||
@ -35,5 +35,5 @@ xonk = 1
|
||||
```ucm
|
||||
bar/main> add
|
||||
bar/topic> merge.old /main
|
||||
.bar> merge.old foo/main
|
||||
scratch/main bar> merge.old foo/main
|
||||
```
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Propagating type edits
|
||||
|
||||
```ucm:hide
|
||||
.subpath.lib> builtins.merge
|
||||
scratch/main subpath.lib> builtins.merge
|
||||
```
|
||||
|
||||
We introduce a type `Foo` with a function dependent `fooToInt`.
|
||||
@ -16,9 +16,9 @@ fooToInt _ = +42
|
||||
And then we add it.
|
||||
|
||||
```ucm
|
||||
.subpath> add
|
||||
.subpath> find.verbose
|
||||
.subpath> view fooToInt
|
||||
scratch/main subpath> add
|
||||
scratch/main subpath> find.verbose
|
||||
scratch/main subpath> view fooToInt
|
||||
```
|
||||
|
||||
Then if we change the type `Foo`...
|
||||
@ -30,13 +30,13 @@ unique type Foo = Foo | Bar
|
||||
and update the codebase to use the new type `Foo`...
|
||||
|
||||
```ucm
|
||||
.subpath> update.old
|
||||
scratch/main subpath> update.old
|
||||
```
|
||||
|
||||
... it should automatically propagate the type to `fooToInt`.
|
||||
|
||||
```ucm
|
||||
.subpath> view fooToInt
|
||||
scratch/main subpath> view fooToInt
|
||||
```
|
||||
|
||||
### Preserving user type variables
|
||||
@ -55,7 +55,7 @@ preserve.otherTerm y = someTerm y
|
||||
Add that to the codebase:
|
||||
|
||||
```ucm
|
||||
.subpath> add
|
||||
scratch/main subpath> add
|
||||
```
|
||||
|
||||
Let's now edit the dependency:
|
||||
@ -68,15 +68,15 @@ preserve.someTerm _ = None
|
||||
Update...
|
||||
|
||||
```ucm
|
||||
.subpath> update.old
|
||||
scratch/main subpath> update.old
|
||||
```
|
||||
|
||||
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
|
||||
.subpath> view preserve.otherTerm
|
||||
scratch/main subpath> view preserve.someTerm
|
||||
scratch/main subpath> view preserve.otherTerm
|
||||
```
|
||||
|
||||
### Propagation only applies to the local branch
|
||||
@ -85,7 +85,7 @@ Cleaning up a bit...
|
||||
|
||||
```ucm
|
||||
scratch/main> delete.namespace subpath
|
||||
.subpath.lib> builtins.merge
|
||||
scratch/main subpath.lib> builtins.merge
|
||||
```
|
||||
|
||||
Now, we make two terms, where one depends on the other.
|
||||
@ -101,8 +101,8 @@ one.otherTerm y = someTerm y
|
||||
We'll make two copies of this namespace.
|
||||
|
||||
```ucm
|
||||
.subpath> add
|
||||
.subpath> fork one two
|
||||
scratch/main subpath> add
|
||||
scratch/main subpath> fork one two
|
||||
```
|
||||
|
||||
Now let's edit one of the terms...
|
||||
@ -115,11 +115,11 @@ someTerm _ = None
|
||||
... in one of the namespaces...
|
||||
|
||||
```ucm
|
||||
.subpath.one> update.old
|
||||
scratch/main subpath.one> update.old
|
||||
```
|
||||
|
||||
The other namespace should be left alone.
|
||||
|
||||
```ucm
|
||||
.subpath> view two.someTerm
|
||||
scratch/main subpath> view two.someTerm
|
||||
```
|
||||
|
@ -20,9 +20,9 @@ Now suppose we `fork` a copy of builtin, then rename `Nat.+` to `frobnicate`, th
|
||||
|
||||
```ucm
|
||||
scratch/main> fork builtin mybuiltin
|
||||
.mybuiltin> rename.term Nat.+ Nat.frobnicate
|
||||
.mybuiltin> rename.term Nat.frobnicate Nat.+
|
||||
.mybuiltin> history
|
||||
scratch/main mybuiltin> rename.term Nat.+ Nat.frobnicate
|
||||
scratch/main mybuiltin> rename.term Nat.frobnicate Nat.+
|
||||
scratch/main mybuiltin> history
|
||||
```
|
||||
|
||||
If we merge that back into `builtin`, we get that same chain of history:
|
||||
@ -50,7 +50,7 @@ x = 1
|
||||
```
|
||||
|
||||
```ucm
|
||||
.trunk> add
|
||||
scratch/main trunk> add
|
||||
scratch/main> fork trunk alice
|
||||
scratch/main> fork trunk bob
|
||||
```
|
||||
@ -64,9 +64,9 @@ neatoFun x = x
|
||||
```
|
||||
|
||||
```ucm
|
||||
.alice> add
|
||||
.alice> rename.term radNumber superRadNumber
|
||||
.alice> rename.term neatoFun productionReadyId
|
||||
scratch/main alice> add
|
||||
scratch/main alice> rename.term radNumber superRadNumber
|
||||
scratch/main alice> rename.term neatoFun productionReadyId
|
||||
```
|
||||
|
||||
Meanwhile, Bob does his own hacking:
|
||||
@ -78,7 +78,7 @@ no more = no more
|
||||
```
|
||||
|
||||
```ucm
|
||||
.bob> add
|
||||
scratch/main bob> add
|
||||
```
|
||||
|
||||
At this point, Alice and Bob both have some history beyond what's in trunk:
|
||||
@ -132,12 +132,12 @@ There's nothing really special here, `squash src dest` discards `src` history th
|
||||
This checks to see that squashing correctly preserves deletions:
|
||||
|
||||
```ucm
|
||||
.delete> builtins.merge
|
||||
.delete> fork builtin builtin2
|
||||
.delete> delete.term.verbose builtin2.Nat.+
|
||||
.delete> delete.term.verbose builtin2.Nat.*
|
||||
.delete> merge.old.squash builtin2 builtin
|
||||
.delete> history builtin
|
||||
scratch/main delete> builtins.merge
|
||||
scratch/main delete> fork builtin builtin2
|
||||
scratch/main delete> delete.term.verbose builtin2.Nat.+
|
||||
scratch/main delete> delete.term.verbose builtin2.Nat.*
|
||||
scratch/main delete> merge.old.squash builtin2 builtin
|
||||
scratch/main delete> history builtin
|
||||
```
|
||||
|
||||
Notice that `Nat.+` and `Nat.*` are deleted by the squash, and we see them deleted in one atomic step in the history.
|
||||
@ -145,11 +145,11 @@ Notice that `Nat.+` and `Nat.*` are deleted by the squash, and we see them delet
|
||||
Just confirming that those two definitions are in fact removed:
|
||||
|
||||
```ucm:error
|
||||
.delete> view .delete.builtin.Nat.+
|
||||
scratch/main delete> view .delete.builtin.Nat.+
|
||||
```
|
||||
|
||||
```ucm:error
|
||||
.delete> view .delete.builtin.Nat.*
|
||||
scratch/main delete> view .delete.builtin.Nat.*
|
||||
```
|
||||
|
||||
## Caveats
|
||||
|
@ -3,7 +3,7 @@
|
||||
https://github.com/unisonweb/unison/issues/2786
|
||||
|
||||
```ucm:hide
|
||||
.ns> builtins.merge
|
||||
scratch/main ns> builtins.merge
|
||||
```
|
||||
|
||||
First we add a sum-type to the codebase.
|
||||
@ -13,7 +13,7 @@ structural type X = x
|
||||
```
|
||||
|
||||
```ucm
|
||||
.ns> add
|
||||
scratch/main ns> add
|
||||
```
|
||||
|
||||
Now we update the type, changing the name of the constructors, _but_, we simultaneously
|
||||
@ -32,5 +32,5 @@ This update should succeed since the conflicted constructor
|
||||
is removed in the same update that the new term is being added.
|
||||
|
||||
```ucm
|
||||
.ns> update.old
|
||||
scratch/main ns> update.old
|
||||
```
|
||||
|
@ -37,7 +37,7 @@ scratch/main> debug.tab-complete view subnamespace2
|
||||
scratch/main> debug.tab-complete view subnamespace.some
|
||||
scratch/main> debug.tab-complete view subnamespace.someOther
|
||||
-- Should tab complete absolute names
|
||||
.othernamespace> debug.tab-complete view .subnamespace.some
|
||||
scratch/main othernamespace> debug.tab-complete view .subnamespace.some
|
||||
```
|
||||
|
||||
## Tab complete namespaces
|
||||
|
@ -36,7 +36,7 @@ testInLib = [Ok "testInLib"]
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.lib> add
|
||||
scratch/main lib> add
|
||||
```
|
||||
|
||||
```ucm
|
||||
@ -47,7 +47,7 @@ scratch/main> test.all
|
||||
`test` WILL run tests within `lib` if ucm is cd'd inside.
|
||||
|
||||
```ucm
|
||||
.lib> test
|
||||
scratch/main lib> test
|
||||
```
|
||||
|
||||
`test` can be given a relative path, in which case it will only run tests found somewhere in that namespace.
|
||||
|
@ -13,7 +13,6 @@ baz = foo.bar + foo.bar
|
||||
```
|
||||
|
||||
```ucm
|
||||
|
||||
Loading changes detected in scratch.u.
|
||||
|
||||
I found and typechecked these definitions in scratch.u. If you
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
```ucm:hide
|
||||
scratch/main> builtins.merge
|
||||
.merged> builtins.merge
|
||||
scratch/main merged> builtins.merge
|
||||
```
|
||||
|
||||
```unison
|
||||
@ -13,8 +13,8 @@ b.x = 2
|
||||
Cause a conflict:
|
||||
```ucm
|
||||
scratch/main> add
|
||||
.merged> merge.old .a
|
||||
.merged> merge.old .b
|
||||
scratch/main merged> merge.old .a
|
||||
scratch/main merged> merge.old .b
|
||||
```
|
||||
|
||||
Updating conflicted definitions works fine.
|
||||
@ -24,5 +24,5 @@ x = 3
|
||||
```
|
||||
|
||||
```ucm
|
||||
.merged> update
|
||||
scratch/main merged> update
|
||||
```
|
||||
|
@ -1,5 +1,5 @@
|
||||
```ucm:hide
|
||||
.lib> builtins.merge
|
||||
scratch/main lib> builtins.merge
|
||||
```
|
||||
|
||||
```unison
|
||||
|
@ -17,9 +17,9 @@ scratch/main> add
|
||||
-- Should suffix-search and find values in sub-namespaces
|
||||
scratch/main> view thing
|
||||
-- Should be local to namespace
|
||||
.a> view thing
|
||||
scratch/main a> view thing
|
||||
-- view.global should search globally and be absolutely qualified
|
||||
.a> view.global thing
|
||||
scratch/main a> view.global thing
|
||||
-- Should support absolute paths outside of current namespace
|
||||
.a> view .b.thing
|
||||
scratch/main a> view .b.thing
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user