From 3742ef5f427c98b9cd7b384d066b83fb1a79ae9c Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sun, 28 Apr 2024 12:45:31 +0200 Subject: [PATCH 01/18] update basic-cli links to 0.10 --- crates/cli/tests/cli_run.rs | 2 +- crates/compiler/load_internal/tests/test_load.rs | 2 +- .../pass/newline_in_packages.full.formatted.roc | 2 +- .../snapshots/pass/newline_in_packages.full.result-ast | 2 +- .../tests/snapshots/pass/newline_in_packages.full.roc | 2 +- examples/cli/argsBROKEN.roc | 2 +- examples/cli/countdown.roc | 2 +- examples/cli/echo.roc | 2 +- examples/cli/env.roc | 2 +- examples/cli/fileBROKEN.roc | 2 +- examples/cli/form.roc | 2 +- examples/cli/http-get.roc | 2 +- examples/cli/ingested-file-bytes.roc | 2 +- examples/cli/ingested-file.roc | 2 +- examples/helloWorld.roc | 2 +- examples/inspect-logging.roc | 2 +- examples/parser/letter-counts.roc | 2 +- examples/parser/parse-movies-csv.roc | 2 +- www/content/platforms.md | 2 +- www/content/tutorial.md | 10 +++++----- 20 files changed, 24 insertions(+), 24 deletions(-) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index e67474321e..ac6f8524b1 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -949,7 +949,7 @@ mod cli_run { This roc file can print its own source code. The source is: app "ingested-file" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, "ingested-file.roc" as ownCode : Str, diff --git a/crates/compiler/load_internal/tests/test_load.rs b/crates/compiler/load_internal/tests/test_load.rs index ab03b7bd43..6929536638 100644 --- a/crates/compiler/load_internal/tests/test_load.rs +++ b/crates/compiler/load_internal/tests/test_load.rs @@ -1280,7 +1280,7 @@ fn roc_file_no_extension() { indoc!( r#" app "helloWorld" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout] provides [main] to pf diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.formatted.roc index 5e804ba783..e56f127e4a 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.formatted.roc @@ -1,7 +1,7 @@ app "hello" packages { pf: - "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br", + "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br", } imports [pf.Stdout] provides [main] to pf diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast index 7f98b39683..9e480292f6 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast @@ -24,7 +24,7 @@ Full { Newline, ], package_name: @31-145 PackageName( - "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br", + "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br", ), }, [ diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.roc b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.roc index 25148860d5..ba43f8a290 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.roc @@ -1,6 +1,6 @@ app "hello" packages { pf: -"https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" +"https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout] provides [main] to pf diff --git a/examples/cli/argsBROKEN.roc b/examples/cli/argsBROKEN.roc index 1d301f4757..230322fc67 100644 --- a/examples/cli/argsBROKEN.roc +++ b/examples/cli/argsBROKEN.roc @@ -1,5 +1,5 @@ app "args" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout, pf.Arg, pf.Task.{ Task }] provides [main] to pf diff --git a/examples/cli/countdown.roc b/examples/cli/countdown.roc index 7f5173bbdc..957d68c6cf 100644 --- a/examples/cli/countdown.roc +++ b/examples/cli/countdown.roc @@ -1,5 +1,5 @@ app "countdown" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdin, pf.Stdout, pf.Task.{ await, loop }] provides [main] to pf diff --git a/examples/cli/echo.roc b/examples/cli/echo.roc index 7b6e04bc2b..baa1d00ce1 100644 --- a/examples/cli/echo.roc +++ b/examples/cli/echo.roc @@ -1,5 +1,5 @@ app "echo" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdin, pf.Stdout, pf.Task.{ Task }] provides [main] to pf diff --git a/examples/cli/env.roc b/examples/cli/env.roc index aef97a5978..29e89ff481 100644 --- a/examples/cli/env.roc +++ b/examples/cli/env.roc @@ -1,5 +1,5 @@ app "env" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout, pf.Stderr, pf.Env, pf.Task.{ Task }] provides [main] to pf diff --git a/examples/cli/fileBROKEN.roc b/examples/cli/fileBROKEN.roc index 007eb669bf..786bba35fa 100644 --- a/examples/cli/fileBROKEN.roc +++ b/examples/cli/fileBROKEN.roc @@ -1,5 +1,5 @@ app "file-io" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, pf.Stderr, diff --git a/examples/cli/form.roc b/examples/cli/form.roc index cb447acfa9..7393e76aeb 100644 --- a/examples/cli/form.roc +++ b/examples/cli/form.roc @@ -1,5 +1,5 @@ app "form" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdin, pf.Stdout, pf.Task.{ await, Task }] provides [main] to pf diff --git a/examples/cli/http-get.roc b/examples/cli/http-get.roc index eb922ea500..5e52961953 100644 --- a/examples/cli/http-get.roc +++ b/examples/cli/http-get.roc @@ -1,5 +1,5 @@ app "http-get" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Http, pf.Task.{ Task }, pf.Stdin, pf.Stdout] provides [main] to pf diff --git a/examples/cli/ingested-file-bytes.roc b/examples/cli/ingested-file-bytes.roc index ebf5b67cef..59a99f0027 100644 --- a/examples/cli/ingested-file-bytes.roc +++ b/examples/cli/ingested-file-bytes.roc @@ -1,5 +1,5 @@ app "ingested-file-bytes" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, "../../LICENSE" as license : _, # A type hole can also be used here. diff --git a/examples/cli/ingested-file.roc b/examples/cli/ingested-file.roc index f6a420909c..a8f8d6b76b 100644 --- a/examples/cli/ingested-file.roc +++ b/examples/cli/ingested-file.roc @@ -1,5 +1,5 @@ app "ingested-file" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, "ingested-file.roc" as ownCode : Str, diff --git a/examples/helloWorld.roc b/examples/helloWorld.roc index 172d634517..c44d458f07 100644 --- a/examples/helloWorld.roc +++ b/examples/helloWorld.roc @@ -1,5 +1,5 @@ app "helloWorld" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout] provides [main] to pf diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc index 0f69394d7d..bcc418c8fe 100644 --- a/examples/inspect-logging.roc +++ b/examples/inspect-logging.roc @@ -2,7 +2,7 @@ # Shows how Roc values can be logged # app "inspect-logging" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, Community, diff --git a/examples/parser/letter-counts.roc b/examples/parser/letter-counts.roc index 08769ba703..1a1ab4bf8c 100644 --- a/examples/parser/letter-counts.roc +++ b/examples/parser/letter-counts.roc @@ -1,6 +1,6 @@ app "example" packages { - cli: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br", + cli: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br", parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.5.2/9VrPjwfQQ1QeSL3CfmWr2Pr9DESdDIXy97pwpuq84Ck.tar.br", } imports [ diff --git a/examples/parser/parse-movies-csv.roc b/examples/parser/parse-movies-csv.roc index fe1fd540f5..682252c5ef 100644 --- a/examples/parser/parse-movies-csv.roc +++ b/examples/parser/parse-movies-csv.roc @@ -1,6 +1,6 @@ app "example" packages { - pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br", + pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br", parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.5.2/9VrPjwfQQ1QeSL3CfmWr2Pr9DESdDIXy97pwpuq84Ck.tar.br", } imports [ diff --git a/www/content/platforms.md b/www/content/platforms.md index abb559033c..8b786a00d6 100644 --- a/www/content/platforms.md +++ b/www/content/platforms.md @@ -8,7 +8,7 @@ Here is a Roc application that prints `"Hello, World!"` to the command line: ```roc app "hello" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout] provides [main] to pf diff --git a/www/content/tutorial.md b/www/content/tutorial.md index 8f86835b90..adb34c26fd 100644 --- a/www/content/tutorial.md +++ b/www/content/tutorial.md @@ -155,7 +155,7 @@ Make a file named `main.roc` and put this in it: ```roc app "hello" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout] provides [main] to pf @@ -1455,7 +1455,7 @@ Let's take a closer look at the part of `main.roc` above the `main` def: ```roc app "hello" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout] provides [main] to pf ``` @@ -1467,7 +1467,7 @@ The line `app "hello"` shows that this module is a Roc application. The "hello" The remaining lines all involve the [platform](https://github.com/roc-lang/roc/wiki/Roc-concepts-explained#platform) this application is built on: ```roc -packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } +packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout] provides [main] to pf ``` @@ -1566,7 +1566,7 @@ Let's start with a basic "Hello World" program. ```roc app "cli-tutorial" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout] provides [main] to pf @@ -1600,7 +1600,7 @@ Let's change `main` to read a line from `stdin`, and then print what we got: ```roc app "cli-tutorial" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.9.1/y_Ww7a2_ZGjp0ZTt9Y_pNdSqqMRdMLzHMKfdN8LWidk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [pf.Stdout, pf.Stdin, pf.Task] provides [main] to pf From 1c83abcb0386aaab61fdd11a7eb81d5550b47e9f Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 28 Apr 2024 08:20:31 -0400 Subject: [PATCH 02/18] Remove type annotations on CLI examples --- examples/cli/argsBROKEN.roc | 3 +-- examples/cli/echo.roc | 1 - examples/cli/env.roc | 1 - examples/cli/fileBROKEN.roc | 1 - examples/cli/form.roc | 1 - examples/cli/http-get.roc | 1 - examples/parser/parse-movies-csv.roc | 1 - 7 files changed, 1 insertion(+), 8 deletions(-) diff --git a/examples/cli/argsBROKEN.roc b/examples/cli/argsBROKEN.roc index 230322fc67..44d8f9eb30 100644 --- a/examples/cli/argsBROKEN.roc +++ b/examples/cli/argsBROKEN.roc @@ -3,7 +3,6 @@ app "args" imports [pf.Stdout, pf.Arg, pf.Task.{ Task }] provides [main] to pf -main : Task {} I32 main = args <- Arg.list |> Task.await parser = @@ -57,7 +56,7 @@ main = Err helpMenu -> {} <- Stdout.line helpMenu |> Task.await - Task.err 1 + Task.err [Exit 1 ""] runCmd = \cmd -> when cmd is diff --git a/examples/cli/echo.roc b/examples/cli/echo.roc index baa1d00ce1..0e15596a42 100644 --- a/examples/cli/echo.roc +++ b/examples/cli/echo.roc @@ -3,7 +3,6 @@ app "echo" imports [pf.Stdin, pf.Stdout, pf.Task.{ Task }] provides [main] to pf -main : Task {} I32 main = _ <- Task.await (Stdout.line "🗣 Shout into this cave and hear the echo! 👂👂👂") diff --git a/examples/cli/env.roc b/examples/cli/env.roc index 29e89ff481..93303f591f 100644 --- a/examples/cli/env.roc +++ b/examples/cli/env.roc @@ -3,7 +3,6 @@ app "env" imports [pf.Stdout, pf.Stderr, pf.Env, pf.Task.{ Task }] provides [main] to pf -main : Task {} I32 main = task = Env.decode "EDITOR" diff --git a/examples/cli/fileBROKEN.roc b/examples/cli/fileBROKEN.roc index 786bba35fa..9f35344029 100644 --- a/examples/cli/fileBROKEN.roc +++ b/examples/cli/fileBROKEN.roc @@ -11,7 +11,6 @@ app "file-io" ] provides [main] to pf -main : Task {} I32 main = path = Path.fromStr "out.txt" task = diff --git a/examples/cli/form.roc b/examples/cli/form.roc index 7393e76aeb..07c3cf40b9 100644 --- a/examples/cli/form.roc +++ b/examples/cli/form.roc @@ -3,7 +3,6 @@ app "form" imports [pf.Stdin, pf.Stdout, pf.Task.{ await, Task }] provides [main] to pf -main : Task {} I32 main = _ <- await (Stdout.line "What's your first name?") firstName <- await Stdin.line diff --git a/examples/cli/http-get.roc b/examples/cli/http-get.roc index 5e52961953..85fe7ccc00 100644 --- a/examples/cli/http-get.roc +++ b/examples/cli/http-get.roc @@ -3,7 +3,6 @@ app "http-get" imports [pf.Http, pf.Task.{ Task }, pf.Stdin, pf.Stdout] provides [main] to pf -main : Task {} I32 main = _ <- Task.await (Stdout.line "Enter a URL to fetch. It must contain a scheme like \"http://\" or \"https://\".") diff --git a/examples/parser/parse-movies-csv.roc b/examples/parser/parse-movies-csv.roc index 682252c5ef..5b6195b4e0 100644 --- a/examples/parser/parse-movies-csv.roc +++ b/examples/parser/parse-movies-csv.roc @@ -16,7 +16,6 @@ app "example" input : Str input = "Airplane!,1980,\"Robert Hays,Julie Hagerty\"\r\nCaddyshack,1980,\"Chevy Chase,Rodney Dangerfield,Ted Knight,Michael O'Keefe,Bill Murray\"" -main : Task {} * main = when CSV.parseStr movieInfoParser input is Ok movies -> From 1fd7f079c57dd66b192951a07950fcf08f25052b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 28 Apr 2024 08:35:44 -0400 Subject: [PATCH 03/18] Fix typo in tutorial --- www/content/tutorial.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/content/tutorial.md b/www/content/tutorial.md index adb34c26fd..3e617b95eb 100644 --- a/www/content/tutorial.md +++ b/www/content/tutorial.md @@ -1630,7 +1630,7 @@ high-quality programs handle errors gracefully. Fortunately, we can do this nice If we wanted to add the type annotation to `main` that Roc is inferring for it, we would add this annotation: ```roc -main : Task {} [Exit I32, StdoutErr Stdout.Err, StinErr Stdin.Err] +main : Task {} [Exit I32, StdoutErr Stdout.Err, StdinErr Stdin.Err] main = ``` @@ -1638,7 +1638,7 @@ Let's break down what this type is saying: - `Task` tells us this is a `Task` type. Its two type parameters are just like the ones we saw in `Result` earlier: the first type tells us what this task will produce if it succeeds, and the other one tells us what it will produce if it fails. - `{}` tells us that this task always produces an empty record when it succeeds. (That is, it doesn't produce anything useful. Empty records don't have any information in them!) This is because the last task in `main` comes from `Stdout.line`, which doesn't produce anything. (In contrast, the `Stdin` task's first type parameter is a `Str`, because it produces a `Str` if it succeeds.) -- `[Exit I32, StdoutErr Stdout.Err, StinErr Stdin.Err]` tells us the different ways this task can fail. The `StdoutErr` and `StdinErr` tags are there becase we used `Stdout.line` and `Stdin.line`. We'll talk about `Exit I32` more in a moment. +- `[Exit I32, StdoutErr Stdout.Err, StdinErr Stdin.Err]` tells us the different ways this task can fail. The `StdoutErr` and `StdinErr` tags are there becase we used `Stdout.line` and `Stdin.line`. We'll talk about `Exit I32` more in a moment. To understand what the `Exit I32 Str` error means, let's try temporarily commenting out our current `main` and replacing it with this one: @@ -1666,7 +1666,7 @@ In summary: ### [Handling task failures](#handling-task-failures) {#handling-task-failures} -If the `main` task ends up failing with any other errors besides `Exit` (such as `StdoutErr` or `StdinErr`), then the `basic-cli` platform's automatic error handling will handle them by printing out words taken from the source code (such as "StdoutErr" and "StinErr"), which could lead to a bad experience for people using this program! +If the `main` task ends up failing with any other errors besides `Exit` (such as `StdoutErr` or `StdinErr`), then the `basic-cli` platform's automatic error handling will handle them by printing out words taken from the source code (such as "StdoutErr" and "StdinErr"), which could lead to a bad experience for people using this program! We can prevent that by gracefully handling the other error types, and then translating them into `Exit` errors so that they affect the program's exit code and don't result in the platform printing anything. A convenient way to make sure we've handled all the other errors is to keep our current type annotation for `main` but restore our old implementation: From 82660f1cae661226cb4123342e11b1e313d8067d Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 28 Apr 2024 08:36:48 -0400 Subject: [PATCH 04/18] Fix some Task imports in examples --- examples/parser/letter-counts.roc | 1 + examples/parser/parse-movies-csv.roc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/parser/letter-counts.roc b/examples/parser/letter-counts.roc index 1a1ab4bf8c..3a5fa19b43 100644 --- a/examples/parser/letter-counts.roc +++ b/examples/parser/letter-counts.roc @@ -6,6 +6,7 @@ app "example" imports [ cli.Stdout, cli.Stderr, + cli.Task, parser.Core.{ Parser, buildPrimitiveParser, many }, parser.String.{ parseStr }, ] diff --git a/examples/parser/parse-movies-csv.roc b/examples/parser/parse-movies-csv.roc index 5b6195b4e0..a5a5557708 100644 --- a/examples/parser/parse-movies-csv.roc +++ b/examples/parser/parse-movies-csv.roc @@ -6,7 +6,7 @@ app "example" imports [ pf.Stdout, pf.Stderr, - pf.Task.{ Task }, + pf.Task, parser.Core.{ Parser, map, keep }, parser.String.{ strFromUtf8 }, parser.CSV.{ CSV }, From 681df41fd3f3eeea38964675979e8caf26fffa47 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 28 Apr 2024 11:20:00 -0400 Subject: [PATCH 05/18] Fix some missing Task imports in examples --- examples/helloWorld.roc | 4 ++-- examples/inspect-logging.roc | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/helloWorld.roc b/examples/helloWorld.roc index c44d458f07..9e16783fc5 100644 --- a/examples/helloWorld.roc +++ b/examples/helloWorld.roc @@ -1,7 +1,7 @@ app "helloWorld" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } - imports [pf.Stdout] + imports [pf.Stdout, pf.Task] provides [main] to pf main = - Stdout.line "Hello, World!" + Stdout.line! "Hello, World!" diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc index bcc418c8fe..ffbc5af6cf 100644 --- a/examples/inspect-logging.roc +++ b/examples/inspect-logging.roc @@ -5,6 +5,7 @@ app "inspect-logging" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, + pf.Task, Community, ] provides [main] to pf @@ -35,4 +36,4 @@ main = |> Community.addFriend 0 2 |> Community.addFriend 1 2 |> Inspect.toStr - |> Stdout.line + |> Stdout.line! From 7fcf13d14b77cc7ad2af4d17bc38e091b7cce53a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 28 Apr 2024 11:26:37 -0400 Subject: [PATCH 06/18] Update some tests to use `!` --- crates/cli/tests/cli_run.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index ac6f8524b1..e2faf3c25d 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -952,12 +952,13 @@ mod cli_run { packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, + pf.Task, "ingested-file.roc" as ownCode : Str, ] provides [main] to pf main = - Stdout.line "\nThis roc file can print its own source code. The source is:\n\n$(ownCode)" + Stdout.line! "\nThis roc file can print its own source code. The source is:\n\n$(ownCode)" "# ), From 87d19c664bfa4d4d39c06c0535fc2b0526c205d2 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 28 Apr 2024 11:35:25 -0400 Subject: [PATCH 07/18] Update more examples to use `!` --- examples/cli/fileBROKEN.roc | 45 ++++++++++++++-------------- examples/cli/form.roc | 18 ++++------- examples/cli/http-get.roc | 37 ++++++++++------------- examples/cli/ingested-file-bytes.roc | 3 +- examples/cli/ingested-file.roc | 3 +- 5 files changed, 48 insertions(+), 58 deletions(-) diff --git a/examples/cli/fileBROKEN.roc b/examples/cli/fileBROKEN.roc index 9f35344029..51733fc028 100644 --- a/examples/cli/fileBROKEN.roc +++ b/examples/cli/fileBROKEN.roc @@ -11,33 +11,32 @@ app "file-io" ] provides [main] to pf +main : Task {} [Exit I32 Str] main = path = Path.fromStr "out.txt" - task = - cwd <- Env.cwd |> Task.await - cwdStr = Path.display cwd - _ <- Stdout.line "cwd: $(cwdStr)" |> Task.await - dirEntries <- Dir.list cwd |> Task.await + task = + cwd = Env.cwd! + + Stdout.line! "cwd: $(Path.display cwd)" + dirEntries = Dir.list! cwd contentsStr = Str.joinWith (List.map dirEntries Path.display) "\n " - _ <- Stdout.line "Directory contents:\n $(contentsStr)\n" |> Task.await - _ <- Stdout.line "Writing a string to out.txt" |> Task.await - _ <- File.writeUtf8 path "a string!" |> Task.await - contents <- File.readUtf8 path |> Task.await - Stdout.line "I read the file back. Its contents: \"$(contents)\"" + Stdout.line! "Directory contents:\n $(contentsStr)\n" + Stdout.line! "Writing a string to out.txt" + File.writeUtf8! path "a string!" + contents = File.readUtf8! path + Stdout.line! "I read the file back. Its contents: \"$(contents)\"" - Task.attempt task \result -> - when result is - Ok {} -> Stdout.line "Successfully wrote a string to out.txt" - Err err -> - msg = - when err is - FileWriteErr _ PermissionDenied -> "PermissionDenied" - FileWriteErr _ Unsupported -> "Unsupported" - FileWriteErr _ (Unrecognized _ other) -> other - FileReadErr _ _ -> "Error reading file" - _ -> "Uh oh, there was an error!" + when Task.result! task is + Ok {} -> Stdout.line! "Successfully wrote a string to out.txt" + Err err -> + msg = + when err is + FileWriteErr _ PermissionDenied -> "PermissionDenied" + FileWriteErr _ Unsupported -> "Unsupported" + FileWriteErr _ (Unrecognized _ other) -> other + FileReadErr _ _ -> "Error reading file" + _ -> "Uh oh, there was an error!" - {} <- Stderr.line msg |> Task.await - Task.err 1 + Task.err (Exit 1 msg) diff --git a/examples/cli/form.roc b/examples/cli/form.roc index 07c3cf40b9..b20ef6ee44 100644 --- a/examples/cli/form.roc +++ b/examples/cli/form.roc @@ -1,19 +1,13 @@ app "form" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } - imports [pf.Stdin, pf.Stdout, pf.Task.{ await, Task }] + imports [pf.Stdin, pf.Stdout, pf.Task] provides [main] to pf main = - _ <- await (Stdout.line "What's your first name?") - firstName <- await Stdin.line + Stdout.line! "What's your first name?" + firstName = Stdin.line! - _ <- await (Stdout.line "What's your last name?") - lastName <- await Stdin.line + Stdout.line! "What's your last name?" + lastName = Stdin.line! - Stdout.line "Hi, $(unwrap firstName) $(unwrap lastName)! 👋" - -unwrap : [Input Str, End] -> Str -unwrap = \input -> - when input is - Input line -> line - End -> "Received end of input (EOF)." + Stdout.line "Hi, $(firstName) $(lastName)! 👋" diff --git a/examples/cli/http-get.roc b/examples/cli/http-get.roc index 85fe7ccc00..6d3da47b8c 100644 --- a/examples/cli/http-get.roc +++ b/examples/cli/http-get.roc @@ -1,30 +1,25 @@ app "http-get" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } - imports [pf.Http, pf.Task.{ Task }, pf.Stdin, pf.Stdout] + imports [pf.Http, pf.Task, pf.Stdin, pf.Stdout] provides [main] to pf main = - _ <- Task.await (Stdout.line "Enter a URL to fetch. It must contain a scheme like \"http://\" or \"https://\".") + Stdout.line! "Enter a URL to fetch. It must contain a scheme like \"http://\" or \"https://\"." - input <- Task.await Stdin.line + url = Stdin.line! - when input is - End -> - Stdout.line "I received end-of-input (EOF) instead of a URL." + request = { + method: Get, + headers: [], + url, + mimeType: "", + body: [], + timeout: NoTimeout, + } - Input url -> - request = { - method: Get, - headers: [], - url, - mimeType: "", - body: [], - timeout: NoTimeout, - } + output = + Http.send request + |> Task.await \resp -> resp |> Http.handleStringResponse |> Task.fromResult + |> Task.onErr! \err -> crash (Http.errorToString err) - output <- Http.send request - |> Task.await \resp -> resp |> Http.handleStringResponse |> Task.fromResult - |> Task.onErr \err -> crash (Http.errorToString err) - |> Task.await - - Stdout.line output + Stdout.line! output diff --git a/examples/cli/ingested-file-bytes.roc b/examples/cli/ingested-file-bytes.roc index 59a99f0027..623f55d238 100644 --- a/examples/cli/ingested-file-bytes.roc +++ b/examples/cli/ingested-file-bytes.roc @@ -2,6 +2,7 @@ app "ingested-file-bytes" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, + pf.Task "../../LICENSE" as license : _, # A type hole can also be used here. ] provides [main] to pf @@ -12,4 +13,4 @@ main = |> List.map Num.toU64 |> List.sum |> Num.toStr - |> Stdout.line + |> Stdout.line! diff --git a/examples/cli/ingested-file.roc b/examples/cli/ingested-file.roc index a8f8d6b76b..a13c38ff81 100644 --- a/examples/cli/ingested-file.roc +++ b/examples/cli/ingested-file.roc @@ -2,9 +2,10 @@ app "ingested-file" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, + pf.Task, "ingested-file.roc" as ownCode : Str, ] provides [main] to pf main = - Stdout.line "\nThis roc file can print its own source code. The source is:\n\n$(ownCode)" + Stdout.line! "\nThis roc file can print its own source code. The source is:\n\n$(ownCode)" From b044f588c06c23e1741086fde00b098380ae8713 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sun, 28 Apr 2024 18:08:34 +0200 Subject: [PATCH 08/18] fix some cli run check tests --- examples/cli/argsBROKEN.roc | 9 ++++----- examples/cli/echo.roc | 11 +++++------ examples/cli/fileBROKEN.roc | 3 +-- examples/cli/http-get.roc | 21 +++++++++------------ 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/examples/cli/argsBROKEN.roc b/examples/cli/argsBROKEN.roc index 44d8f9eb30..a58a0cf772 100644 --- a/examples/cli/argsBROKEN.roc +++ b/examples/cli/argsBROKEN.roc @@ -4,7 +4,7 @@ app "args" provides [main] to pf main = - args <- Arg.list |> Task.await + args = Arg.list! parser = divCmd = Arg.succeed (\dividend -> \divisor -> Div (Num.toF64 dividend) (Num.toF64 divisor)) @@ -54,13 +54,12 @@ main = |> Num.toStr |> Stdout.line - Err helpMenu -> - {} <- Stdout.line helpMenu |> Task.await - Task.err [Exit 1 ""] + Err helpMenuErr -> + Task.err (Exit 1 "unable to parse args: $(Inspect.toStr helpMenuErr)") runCmd = \cmd -> when cmd is Div n d -> n / d Log b n -> # log_b(n) = log_x(n) / log_x(b) for all x - runCmd (Div (Num.log n) (Num.log b)) + runCmd (Div (Num.log n) (Num.log b)) \ No newline at end of file diff --git a/examples/cli/echo.roc b/examples/cli/echo.roc index 0e15596a42..ee3dea1b3f 100644 --- a/examples/cli/echo.roc +++ b/examples/cli/echo.roc @@ -8,13 +8,12 @@ main = Task.loop {} tick -tick : {} -> Task [Step {}, Done {}] * +tick : {} -> Task [Step {}, Done {}] _ tick = \{} -> - shout <- Task.await Stdin.line - - when shout is - Input s -> Stdout.line (echo s) |> Task.map Step - End -> Stdout.line (echo "Received end of input (EOF).") |> Task.map Done + when Stdin.line |> Task.result! is + Ok str -> Stdout.line (echo str) |> Task.map Step + Err (StdinErr EndOfFile) -> Stdout.line (echo "Received end of input (EOF).") |> Task.map Done + Err (StdinErr err) -> Stdout.line (echo "Unable to read input $(Inspect.toStr err)") |> Task.map Done echo : Str -> Str echo = \shout -> diff --git a/examples/cli/fileBROKEN.roc b/examples/cli/fileBROKEN.roc index 51733fc028..237898fc7f 100644 --- a/examples/cli/fileBROKEN.roc +++ b/examples/cli/fileBROKEN.roc @@ -2,7 +2,6 @@ app "file-io" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, - pf.Stderr, pf.Task.{ Task }, pf.File, pf.Path, @@ -11,7 +10,7 @@ app "file-io" ] provides [main] to pf -main : Task {} [Exit I32 Str] +main : Task {} [Exit I32 Str]_ main = path = Path.fromStr "out.txt" diff --git a/examples/cli/http-get.roc b/examples/cli/http-get.roc index 6d3da47b8c..e6b79a4d2f 100644 --- a/examples/cli/http-get.roc +++ b/examples/cli/http-get.roc @@ -1,25 +1,22 @@ app "http-get" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } - imports [pf.Http, pf.Task, pf.Stdin, pf.Stdout] + imports [pf.Http, pf.Task, pf.Stdout] provides [main] to pf main = - Stdout.line! "Enter a URL to fetch. It must contain a scheme like \"http://\" or \"https://\"." - - url = Stdin.line! - request = { method: Get, headers: [], - url, + url: "http://www.example.com", mimeType: "", body: [], - timeout: NoTimeout, + timeout: TimeoutMilliseconds 5000, } - output = - Http.send request - |> Task.await \resp -> resp |> Http.handleStringResponse |> Task.fromResult - |> Task.onErr! \err -> crash (Http.errorToString err) + resp = Http.send! request - Stdout.line! output + output = when resp |> Http.handleStringResponse is + Err err -> crash (Http.errorToString err) + Ok body -> body + + Stdout.line output From 6c974070337d117879c43dfc1723ec9c448e78c2 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sun, 28 Apr 2024 18:13:42 +0200 Subject: [PATCH 09/18] fix ingested file bytes example --- examples/cli/ingested-file-bytes.roc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cli/ingested-file-bytes.roc b/examples/cli/ingested-file-bytes.roc index 623f55d238..d806bba251 100644 --- a/examples/cli/ingested-file-bytes.roc +++ b/examples/cli/ingested-file-bytes.roc @@ -2,7 +2,7 @@ app "ingested-file-bytes" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } imports [ pf.Stdout, - pf.Task + pf.Task, "../../LICENSE" as license : _, # A type hole can also be used here. ] provides [main] to pf From 9d28e70cdce35e5bb2ecad00db2170525237111a Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sun, 28 Apr 2024 18:27:59 +0200 Subject: [PATCH 10/18] all fixed --- .../pass/newline_in_packages.full.result-ast | 20 ++++---- examples/cli/fileBROKEN.roc | 2 - examples/cli/form.roc | 1 - examples/cli/http-get.roc | 7 +-- examples/cli/ingested-file-bytes.roc | 8 +-- examples/inspect-logging.roc | 50 +++++++++---------- 6 files changed, 43 insertions(+), 45 deletions(-) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast index 9e480292f6..73f8eaa2af 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast @@ -17,13 +17,13 @@ Full { after: [], }, item: [ - @27-145 SpaceAfter( + @27-146 SpaceAfter( PackageEntry { shorthand: "pf", spaces_after_shorthand: [ Newline, ], - package_name: @31-145 PackageName( + package_name: @31-146 PackageName( "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br", ), }, @@ -44,7 +44,7 @@ Full { after: [], }, item: [ - @161-170 Package( + @162-171 Package( "pf", ModuleName( "Stdout", @@ -63,7 +63,7 @@ Full { after: [], }, entries: [ - @186-190 ExposedName( + @187-191 ExposedName( "main", ), ], @@ -73,7 +73,7 @@ Full { item: ToKeyword, after: [], }, - to: @195-197 ExistingPackage( + to: @196-198 ExistingPackage( "pf", ), }, @@ -85,7 +85,7 @@ Full { Index(2147483648), ], regions: [ - @199-246, + @200-247, ], space_before: [ Slice(start = 0, length = 2), @@ -100,17 +100,17 @@ Full { type_defs: [], value_defs: [ Body( - @199-203 Identifier { + @200-204 Identifier { ident: "main", }, - @210-246 SpaceBefore( + @211-247 SpaceBefore( Apply( - @210-221 Var { + @211-222 Var { module_name: "Stdout", ident: "line", }, [ - @222-246 Str( + @223-247 Str( PlainLine( "I'm a Roc application!", ), diff --git a/examples/cli/fileBROKEN.roc b/examples/cli/fileBROKEN.roc index 237898fc7f..b81f16c57a 100644 --- a/examples/cli/fileBROKEN.roc +++ b/examples/cli/fileBROKEN.roc @@ -16,11 +16,9 @@ main = task = cwd = Env.cwd! - Stdout.line! "cwd: $(Path.display cwd)" dirEntries = Dir.list! cwd contentsStr = Str.joinWith (List.map dirEntries Path.display) "\n " - Stdout.line! "Directory contents:\n $(contentsStr)\n" Stdout.line! "Writing a string to out.txt" File.writeUtf8! path "a string!" diff --git a/examples/cli/form.roc b/examples/cli/form.roc index b20ef6ee44..c605313f88 100644 --- a/examples/cli/form.roc +++ b/examples/cli/form.roc @@ -6,7 +6,6 @@ app "form" main = Stdout.line! "What's your first name?" firstName = Stdin.line! - Stdout.line! "What's your last name?" lastName = Stdin.line! diff --git a/examples/cli/http-get.roc b/examples/cli/http-get.roc index e6b79a4d2f..5c4cb54c84 100644 --- a/examples/cli/http-get.roc +++ b/examples/cli/http-get.roc @@ -15,8 +15,9 @@ main = resp = Http.send! request - output = when resp |> Http.handleStringResponse is - Err err -> crash (Http.errorToString err) - Ok body -> body + output = + when resp |> Http.handleStringResponse is + Err err -> crash (Http.errorToString err) + Ok body -> body Stdout.line output diff --git a/examples/cli/ingested-file-bytes.roc b/examples/cli/ingested-file-bytes.roc index d806bba251..67e6667cbf 100644 --- a/examples/cli/ingested-file-bytes.roc +++ b/examples/cli/ingested-file-bytes.roc @@ -10,7 +10,7 @@ app "ingested-file-bytes" main = # Due to how license is used, it will be a List U8. license - |> List.map Num.toU64 - |> List.sum - |> Num.toStr - |> Stdout.line! + |> List.map Num.toU64 + |> List.sum + |> Num.toStr + |> Stdout.line! diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc index ffbc5af6cf..0883b5b7d0 100644 --- a/examples/inspect-logging.roc +++ b/examples/inspect-logging.roc @@ -12,28 +12,28 @@ app "inspect-logging" main = Community.empty - |> Community.addPerson { - firstName: "John", - lastName: "Smith", - age: 27, - hasBeard: Bool.true, - favoriteColor: Blue, - } - |> Community.addPerson { - firstName: "Debby", - lastName: "Johnson", - age: 47, - hasBeard: Bool.false, - favoriteColor: Green, - } - |> Community.addPerson { - firstName: "Jane", - lastName: "Doe", - age: 33, - hasBeard: Bool.false, - favoriteColor: RGB (255, 255, 0), - } - |> Community.addFriend 0 2 - |> Community.addFriend 1 2 - |> Inspect.toStr - |> Stdout.line! + |> Community.addPerson { + firstName: "John", + lastName: "Smith", + age: 27, + hasBeard: Bool.true, + favoriteColor: Blue, + } + |> Community.addPerson { + firstName: "Debby", + lastName: "Johnson", + age: 47, + hasBeard: Bool.false, + favoriteColor: Green, + } + |> Community.addPerson { + firstName: "Jane", + lastName: "Doe", + age: 33, + hasBeard: Bool.false, + favoriteColor: RGB (255, 255, 0), + } + |> Community.addFriend 0 2 + |> Community.addFriend 1 2 + |> Inspect.toStr + |> Stdout.line! From 5f26d5a097d9ee3569afa85fdeaa9fbf56fe10be Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 28 Apr 2024 13:15:39 -0400 Subject: [PATCH 11/18] Update tutorial CSS --- www/public/site.css | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/www/public/site.css b/www/public/site.css index 9178b6acdd..76a5dc2bde 100644 --- a/www/public/site.css +++ b/www/public/site.css @@ -39,6 +39,7 @@ --header-link-color: #1bbcb3; --header-link-hover: #222; --h1-color: #8055e4; + --tutorial-h3-color: #8c5ce3; /* Slightly darker than --primary-1, which looks washed-out in

s */ } html { @@ -167,7 +168,7 @@ hr { } #sponsor-logos .logo-decem .cls-1 { - fill:#04021e; + fill: #04021e; } #sponsor-logos + p { @@ -731,7 +732,8 @@ li { font-style: normal; font-weight: 400; font-display: swap; - src: url("/fonts/permanent-marker-v16-latin/permanent-marker-v16-latin-regular.woff2") + src: + url("/fonts/permanent-marker-v16-latin/permanent-marker-v16-latin-regular.woff2") format("woff2"), url("/fonts/permanent-marker-v16-latin/permanent-marker-v16-latin-regular.woff") format("woff"); @@ -746,7 +748,8 @@ li { font-style: normal; font-weight: 400; font-display: swap; - src: url("/fonts/lato-v23-latin-ext_latin/lato-v23-latin-ext_latin-regular.woff2") + src: + url("/fonts/lato-v23-latin-ext_latin/lato-v23-latin-ext_latin-regular.woff2") format("woff2"), url("/fonts/lato-v23-latin-ext_latin/lato-v23-latin-ext_latin-regular.woff") format("woff"); @@ -760,7 +763,8 @@ li { font-style: normal; font-weight: 400; font-display: swap; - src: url("/fonts/lato-v23-latin/lato-v23-latin-regular.woff2") + src: + url("/fonts/lato-v23-latin/lato-v23-latin-regular.woff2") format("woff2"), url("/fonts/lato-v23-latin/lato-v23-latin-regular.woff") format("woff"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, @@ -774,7 +778,8 @@ li { font-style: normal; font-weight: 400; font-display: swap; - src: url("/fonts/source-code-pro-v22-latin-ext_latin/source-code-pro-v22-latin-ext_latin-regular.woff2") + src: + url("/fonts/source-code-pro-v22-latin-ext_latin/source-code-pro-v22-latin-ext_latin-regular.woff2") format("woff2"), url("/fonts/source-code-pro-v22-latin-ext_latin/source-code-pro-v22-latin-ext_latin-regular.woff") format("woff"); @@ -788,7 +793,8 @@ li { font-style: normal; font-weight: 400; font-display: swap; - src: url("/fonts/source-code-pro-v22-latin/source-code-pro-v22-latin-regular.woff2") + src: + url("/fonts/source-code-pro-v22-latin/source-code-pro-v22-latin-regular.woff2") format("woff2"), url("/fonts/source-code-pro-v22-latin/source-code-pro-v22-latin-regular.woff") format("woff"); @@ -825,6 +831,7 @@ li { --header-link-color: #9c7cea; --header-link-hover: #ddd; --h1-color: #1bc6bd; + --tutorial-h3-color: var(--primary-1); } .logo-dark { @@ -1137,7 +1144,8 @@ code .dim { color: #7c38f5; } -.interactive-desc code, .interactive-desc pre { +.interactive-desc code, +.interactive-desc pre { background: none; color: inherit; } @@ -1201,9 +1209,12 @@ code .dim { border: none; } +#tutorial-main h3 a { + color: var(--tutorial-h3-color); +} + #tutorial-main h1 a, #tutorial-main h2 a, -#tutorial-main h3 a, #tutorial-main h4 a, #tutorial-main h5 a { color: var(--header-link-color); @@ -1240,7 +1251,7 @@ code .dim { font-family: inherit; font-size: 1.65rem; line-height: 3rem; - text-shadow: 1px 1px 1px #010101; + margin-bottom: 0.5rem; } #tutorial-main h4 { @@ -1364,12 +1375,14 @@ code .dim { font-size: 18px; } -#homepage-repl-container #repl-prompt, #homepage-repl-container .input-line-prefix { +#homepage-repl-container #repl-prompt, +#homepage-repl-container .input-line-prefix { top: 1.25rem; color: var(--light-cyan); } -.input-line-prefix, #repl-prompt { +.input-line-prefix, +#repl-prompt { color: var(--cyan); color: var(--primary-2); } @@ -1481,7 +1494,7 @@ code .dim { in a light color scheme, and only white in dark mode. The name could be better! */ #homepage-repl-container .color-white { - color: #FFF; + color: #fff; } #repl-container .color-white { @@ -1489,15 +1502,13 @@ code .dim { } @media (prefers-color-scheme: dark) { - #homepage-repl-container .color-white { - color: #FFF; + color: #fff; } #repl-container .color-white { - color: #FFF; + color: #fff; } - } .bold { From 4b1433bfc68517e90f9f4774cd681d630849ca08 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 29 Apr 2024 09:02:54 -0400 Subject: [PATCH 12/18] Remove `Inspect` from /plans It exists already! Signed-off-by: Richard Feldman --- www/content/plans.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/www/content/plans.md b/www/content/plans.md index def218f733..ac8a527795 100644 --- a/www/content/plans.md +++ b/www/content/plans.md @@ -70,9 +70,3 @@ These are planned changes to how things work, which should be backwards-compatib This doesn't come up a lot, but [the feature](https://github.com/roc-lang/roc/issues/5504) basically means you can match on some tags in a `when`, and then have an `other ->` branch which has the tags you already matched on removed from the union. That means if you later do another `when` on the `other` value, you won't have to match on (or use `_ ->` to ignore) the tags you already matched in the first `when`, like you do today. This is planned but nobody is currently working on it. It's a quality of life improvement but doesn't unblock anything; today you can just add a `_ ->` branch to the inner `when`, which is undesirable but not a blocker. - -### [`Inspect` Inference](#inspect-inference) {#inspect-inference} - -When this lands, all Roc types will have a default `implements Inspect`, which you can override if desired. `dbg` will use it to display things, which in turn means you'll be able to customize `dbg` output. Also it will mean you can do things like turning any Roc type into a string and writing it to a log file. - -Note that in this design, functions will have an `Inspect` implementation which essentially renders them as `""` with no other information, and opaque types will be `""` by default unless you customize them. This is important because neither functions nor opaque types should expose their internal details, so that you can safely refactor them without causing regressions in distant parts of the code base because something depended on an internal implementation detail. From 712d648cf0103a7f875ec1b627fde05b5b75bcd2 Mon Sep 17 00:00:00 2001 From: faldor20 Date: Tue, 23 Apr 2024 14:40:25 +1000 Subject: [PATCH 13/18] reduce panics --- crates/language_server/src/registry.rs | 3 ++- crates/language_server/src/server.rs | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/crates/language_server/src/registry.rs b/crates/language_server/src/registry.rs index 09c021fc8c..7be32a702a 100644 --- a/crates/language_server/src/registry.rs +++ b/crates/language_server/src/registry.rs @@ -74,7 +74,8 @@ impl Registry { if &document.doc_info.url == updating_url { //Write the newly analysed document into the oncelock that any request requiring the latest document will be waiting on if let Some(a) = documents.get_mut(updating_url) { - a.latest_document.set(document.clone()).unwrap() + //We don't care if this fails becasue we expect the document to sometimes alreday be there + a.latest_document.set(document.clone()).unwrap_or(()) } } diff --git a/crates/language_server/src/server.rs b/crates/language_server/src/server.rs index 9933c98e5c..18938a9e65 100644 --- a/crates/language_server/src/server.rs +++ b/crates/language_server/src/server.rs @@ -3,7 +3,7 @@ use analysis::HIGHLIGHT_TOKENS_LEGEND; use log::{debug, trace}; use registry::{Registry, RegistryConfig}; use std::future::Future; -use std::panic::AssertUnwindSafe; +use std::panic::{catch_unwind, AssertUnwindSafe}; use std::time::Duration; use tower_lsp::jsonrpc::{self, Result}; @@ -173,10 +173,17 @@ impl RocServerState { return Err("Not latest version skipping analysis".to_string()); } - let results = match tokio::task::spawn_blocking(|| global_analysis(doc_info)).await { - Err(e) => return Err(format!("Document analysis failed. reason:{:?}", e)), - Ok(a) => a, - }; + let results = + match tokio::task::spawn_blocking(|| catch_unwind(|| global_analysis(doc_info))) + .await + { + Err(e) => { + return Err(format!("Document analysis thread failed. reason:{:?}", e)) + } + Ok(res) => { + res.map_err(|err| format!("Document analysis panicked with: {:?}", err))? + } + }; let latest_version = inner_ref.registry.get_latest_version(fi).await; //if this version is not the latest another change must have come in and this analysis is useless @@ -230,8 +237,11 @@ impl LanguageServer for RocServer { // NOTE: We specify that we expect full-content syncs in the server capabilities, // so here we assume the only change passed is a change of the entire document's content. - let TextDocumentContentChangeEvent { text, .. } = - params.content_changes.into_iter().next().unwrap(); + let TextDocumentContentChangeEvent { text, .. } = params + .content_changes + .into_iter() + .last() + .expect("textDocument change event had no changes "); self.change(uri, text, version).await; } From 29864c2508ccd23de909d5308ca481a4596bf351 Mon Sep 17 00:00:00 2001 From: faldor20 Date: Tue, 30 Apr 2024 09:33:21 +1000 Subject: [PATCH 14/18] added timeout to analysis --- crates/language_server/src/server.rs | 30 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/language_server/src/server.rs b/crates/language_server/src/server.rs index 18938a9e65..9f3bc9550a 100644 --- a/crates/language_server/src/server.rs +++ b/crates/language_server/src/server.rs @@ -173,17 +173,25 @@ impl RocServerState { return Err("Not latest version skipping analysis".to_string()); } - let results = - match tokio::task::spawn_blocking(|| catch_unwind(|| global_analysis(doc_info))) - .await - { - Err(e) => { - return Err(format!("Document analysis thread failed. reason:{:?}", e)) - } - Ok(res) => { - res.map_err(|err| format!("Document analysis panicked with: {:?}", err))? - } - }; + let results = match tokio::time::timeout( + Duration::from_secs(60), + tokio::task::spawn_blocking(|| catch_unwind(|| global_analysis(doc_info))), + ) + .await + { + Err(e) => { + return Err(format!( + "Document analysis thread timeout out after: {:?}", + e + )) + } + Ok(Err(e)) => { + return Err(format!("Document analysis thread failed. reason:{:?}", e)) + } + Ok(Ok(res)) => { + res.map_err(|err| format!("Document analysis panicked with: {:?}", err))? + } + }; let latest_version = inner_ref.registry.get_latest_version(fi).await; //if this version is not the latest another change must have come in and this analysis is useless From e2b4af8af579addd5bb6809eca146056d94a9f3a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 30 Apr 2024 16:21:48 -0400 Subject: [PATCH 15/18] fix typos in comment Signed-off-by: Richard Feldman --- crates/language_server/src/registry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/language_server/src/registry.rs b/crates/language_server/src/registry.rs index 7be32a702a..807ba6625a 100644 --- a/crates/language_server/src/registry.rs +++ b/crates/language_server/src/registry.rs @@ -74,7 +74,7 @@ impl Registry { if &document.doc_info.url == updating_url { //Write the newly analysed document into the oncelock that any request requiring the latest document will be waiting on if let Some(a) = documents.get_mut(updating_url) { - //We don't care if this fails becasue we expect the document to sometimes alreday be there + //We don't care if this fails because we expect the document to sometimes already be there a.latest_document.set(document.clone()).unwrap_or(()) } } From 6c21bdf91fe7dc95947f74b3d2872f9222381ffb Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 30 Apr 2024 16:22:11 -0400 Subject: [PATCH 16/18] cargo fmt Signed-off-by: Richard Feldman --- crates/language_server/src/registry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/language_server/src/registry.rs b/crates/language_server/src/registry.rs index 807ba6625a..965ad3e467 100644 --- a/crates/language_server/src/registry.rs +++ b/crates/language_server/src/registry.rs @@ -74,7 +74,7 @@ impl Registry { if &document.doc_info.url == updating_url { //Write the newly analysed document into the oncelock that any request requiring the latest document will be waiting on if let Some(a) = documents.get_mut(updating_url) { - //We don't care if this fails because we expect the document to sometimes already be there + // We don't care if this fails because we expect the document to sometimes already be there a.latest_document.set(document.clone()).unwrap_or(()) } } From 0660c94acbfe34bbeabe7852938ab5f0352b3184 Mon Sep 17 00:00:00 2001 From: Andy Ferris Date: Wed, 1 May 2024 20:33:14 +1000 Subject: [PATCH 17/18] Import pf.Task in first application example As it is, the tutorial example does not compile due to a missing import. Signed-off-by: Andy Ferris --- www/content/tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/content/tutorial.md b/www/content/tutorial.md index 3e617b95eb..015486b7bd 100644 --- a/www/content/tutorial.md +++ b/www/content/tutorial.md @@ -156,7 +156,7 @@ Make a file named `main.roc` and put this in it: ```roc app "hello" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } - imports [pf.Stdout] + imports [pf.Stdout, pf.Task] provides [main] to pf main = From f7945c8bda01fb90ff00044ba82035b1455ef35f Mon Sep 17 00:00:00 2001 From: Andy Ferris Date: Wed, 1 May 2024 20:39:34 +1000 Subject: [PATCH 18/18] Fix same problem in platforms.md Signed-off-by: Andy Ferris --- www/content/platforms.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/content/platforms.md b/www/content/platforms.md index 8b786a00d6..7e42d1e067 100644 --- a/www/content/platforms.md +++ b/www/content/platforms.md @@ -9,7 +9,7 @@ Here is a Roc application that prints `"Hello, World!"` to the command line: ```roc app "hello" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" } - imports [pf.Stdout] + imports [pf.Stdout, pf.Task] provides [main] to pf main =