unison/unison-src/transcripts/fix1800.md

65 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2021-04-28 04:48:50 +03:00
```ucm:hide
scratch/main> builtins.merge
2021-04-28 04:48:50 +03:00
```
```unison:hide
2021-04-28 04:48:50 +03:00
printLine : Text ->{IO} ()
printLine msg =
2022-12-02 08:51:11 +03:00
_ = putBytes.impl (stdHandle StdOut) (Text.toUtf8 (msg ++ "\n"))
2021-04-28 04:48:50 +03:00
()
-- An unannotated main function
main1 = '(printLine "\nhello world!")
-- Another variation
main2 _ = printLine "🌹"
-- An annotated main function
main3 : '{IO} ()
main3 _ = printLine "🦄 ☁️ 🌈"
```
Testing a few variations here:
* Should be able to run annotated and unannotated main functions in the current file.
* Should be able to run annotated and unannotated main functions from the codebase.
```ucm
scratch/main> run main1
scratch/main> run main2
scratch/main> run main3
scratch/main> add
scratch/main> rename.term main1 code.main1
scratch/main> rename.term main2 code.main2
scratch/main> rename.term main3 code.main3
2021-04-28 04:48:50 +03:00
```
The renaming just ensures that when running `code.main1`, it has to get that main from the codebase rather than the scratch file:
2021-04-28 04:48:50 +03:00
```ucm
scratch/main> run code.main1
scratch/main> run code.main2
scratch/main> run code.main3
```
Now testing a few variations that should NOT typecheck.
```unison:hide
main4 : Nat ->{IO} Nat
main4 n = n
main5 : Nat ->{IO} ()
main5 _ = ()
```
This shouldn't work since `main4` and `main5` don't have the right type.
```ucm:error
scratch/main> run main4
```
```ucm:error
scratch/main> run main5
2021-04-28 04:48:50 +03:00
```