Skip to content

Commit

Permalink
Merge pull request #5586 from sellout/clarify-transcript
Browse files Browse the repository at this point in the history
Modify the fix-2805 transcript to use return type
  • Loading branch information
aryairani authored Feb 20, 2025
2 parents 510b184 + 4be484a commit c89b687
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 6 additions & 3 deletions unison-src/transcripts-using-base/fix-2805.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
When running a main function in `ucm` a numeric argument is replaced by the potential last result of a find command:

``` unison
main : '{IO, Exception} ()
main _ =
printLine ("Hello " ++ Optional.getOrBug "definitely passed an arg" (List.head !getArgs) ++ "!")
main : '{IO, Exception} Text
main _ = "Hello " ++ Optional.getOrBug "definitely passed an arg" (List.head !getArgs) ++ "!"
```

First we run it with no numbered results in the history, so if number expansion is applied, it should end up calling `main` with zero args, whereas without number expansion, we get a single argument, “1”, passed to it.

``` ucm
scratch/main> run main 1
"Hello 1!"
```

Now we set it up so there _are_ numbered results in the history. If number expansion is applied here, we will get an error “`run` can’t accept a numbered argument []”, and otherwise our expected "1".

``` ucm
scratch/main> find.all isLeft
scratch/main> run main 1
"Hello 1!"
```
11 changes: 5 additions & 6 deletions unison-src/transcripts-using-base/fix-2805.output.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
When running a main function in `ucm` a numeric argument is replaced by the potential last result of a find command:

``` unison
main : '{IO, Exception} ()
main _ =
printLine ("Hello " ++ Optional.getOrBug "definitely passed an arg" (List.head !getArgs) ++ "!")
main : '{IO, Exception} Text
main _ = "Hello " ++ Optional.getOrBug "definitely passed an arg" (List.head !getArgs) ++ "!"
```

``` ucm :added-by-ucm
Expand All @@ -15,15 +14,15 @@ main _ =
⍟ These new definitions are ok to `add`:
main : '{IO, Exception} ()
main : '{IO, Exception} Text
```

First we run it with no numbered results in the history, so if number expansion is applied, it should end up calling `main` with zero args, whereas without number expansion, we get a single argument, “1”, passed to it.

``` ucm
scratch/main> run main 1
()
"Hello 1!"
```

Now we set it up so there *are* numbered results in the history. If number expansion is applied here, we will get an error “`run` can’t accept a numbered argument \[\]”, and otherwise our expected "1".
Expand All @@ -35,5 +34,5 @@ scratch/main> find.all isLeft
scratch/main> run main 1
()
"Hello 1!"
```

0 comments on commit c89b687

Please sign in to comment.