From 2227929566ae3a13d0b93efb87e6405a4d6cb5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Mon, 19 Aug 2024 21:52:19 +1200 Subject: [PATCH 01/13] Starts docs and exercises, implement verify-exercises --- bin/verify-exercises | 14 ++++- config.json | 57 +++++++++++++++---- docs/ABOUT.md | 17 +++--- docs/INSTALLATION.md | 14 +---- docs/LEARNING.md | 14 ++--- docs/RESOURCES.md | 15 ++--- docs/SNIPPET.txt | 18 +++++- docs/TESTS.md | 14 +---- .../hello-world/.docs/instructions.append.md | 5 ++ .../hello-world/.docs/instructions.md | 16 ++++++ .../practice/hello-world/.meta/Example.roc | 3 + .../practice/hello-world/.meta/config.json | 22 +++++++ .../practice/hello-world/.meta/tests.toml | 13 +++++ exercises/practice/hello-world/HelloWorld.roc | 3 + .../practice/hello-world/hello-world-test.roc | 9 +++ exercises/practice/leap/.docs/instructions.md | 3 + exercises/practice/leap/.docs/introduction.md | 16 ++++++ exercises/practice/leap/.meta/Example.roc | 4 ++ exercises/practice/leap/.meta/config.json | 11 ++++ exercises/practice/leap/.meta/tests.toml | 37 ++++++++++++ exercises/practice/leap/Leap.roc | 4 ++ exercises/practice/leap/leap-test.roc | 26 +++++++++ exercises/shared/.docs/help.md | 21 +------ exercises/shared/.docs/tests.md | 16 +----- 24 files changed, 271 insertions(+), 101 deletions(-) create mode 100644 exercises/practice/hello-world/.docs/instructions.append.md create mode 100644 exercises/practice/hello-world/.docs/instructions.md create mode 100644 exercises/practice/hello-world/.meta/Example.roc create mode 100644 exercises/practice/hello-world/.meta/config.json create mode 100644 exercises/practice/hello-world/.meta/tests.toml create mode 100644 exercises/practice/hello-world/HelloWorld.roc create mode 100644 exercises/practice/hello-world/hello-world-test.roc create mode 100644 exercises/practice/leap/.docs/instructions.md create mode 100644 exercises/practice/leap/.docs/introduction.md create mode 100644 exercises/practice/leap/.meta/Example.roc create mode 100644 exercises/practice/leap/.meta/config.json create mode 100644 exercises/practice/leap/.meta/tests.toml create mode 100644 exercises/practice/leap/Leap.roc create mode 100644 exercises/practice/leap/leap-test.roc diff --git a/bin/verify-exercises b/bin/verify-exercises index 1a93da6..a636bb1 100755 --- a/bin/verify-exercises +++ b/bin/verify-exercises @@ -23,11 +23,21 @@ slug="${1:-*}" +test_example() { + MODULE_FILE=`jq -r '.files.solution[]' $1/.meta/config.json` + EXAMPLE_FILE=`jq -r '.files.example[]' $1/.meta/config.json` + TEST_FILE=`jq -r '.files.test[]' $1/.meta/config.json` + mv "$1/${MODULE_FILE}" "$1/${MODULE_FILE}.bak" + cp "$1/${EXAMPLE_FILE}" "$1/${MODULE_FILE}" + roc test "$1/${TEST_FILE}" + mv -f "$1/${MODULE_FILE}".bak "$1/${MODULE_FILE}" +} + # Verify the Concept Exercises for concept_exercise_dir in ./exercises/concept/${slug}/; do if [ -d $concept_exercise_dir ]; then echo "Checking $(basename "${concept_exercise_dir}") exercise..." - # TODO: run command to verify that the exemplar solution passes the tests + test_example "${concept_exercise_dir%/}" fi done @@ -35,6 +45,6 @@ done for practice_exercise_dir in ./exercises/practice/${slug}/; do if [ -d $practice_exercise_dir ]; then echo "Checking $(basename "${practice_exercise_dir}") exercise..." - # TODO: run command to verify that the example solution passes the tests + test_example "${practice_exercise_dir%/}" fi done diff --git a/config.json b/config.json index 813798e..1fee224 100644 --- a/config.json +++ b/config.json @@ -8,23 +8,58 @@ "representer": false, "analyzer": false }, - "blurb": "TODO: add blurb", + "blurb": "Roc is a fast, friendly, functional language.", "version": 3, "online_editor": { "indent_style": "space", - "indent_size": 4 + "indent_size": 4, + "highlightjs_language": "roc" }, "files": { - "solution": [], - "test": [], - "example": [], - "exemplar": [] + "solution": [ + "%{pascal_slug}.roc" + ], + "test": [ + "%{kebab_slug}-test.roc" + ], + "example": [ + ".meta/Example.roc" + ] }, "exercises": { - "concept": [], - "practice": [] + "practice": [ + { + "slug": "hello-world", + "name": "Hello World", + "uuid": "c2e68f17-4f90-4510-a945-9e2dbf23d777", + "practices": [], + "prerequisites": [], + "difficulty": 1 + }, + { + "slug": "leap", + "name": "Leap", + "uuid": "fd8452d6-b1af-424a-9d03-aadb4945e644", + "practices": [], + "prerequisites": [], + "difficulty": 1 + } + ] }, - "concepts": [], - "key_features": [], - "tags": [] + "tags": [ + "execution_mode/compiled", + "paradigm/functional", + "platform/linux", + "platform/mac", + "platform/windows", + "typing/strong", + "used_for/artificial_intelligence", + "used_for/backends", + "used_for/cross_platform_development", + "used_for/embedded_systems", + "used_for/games", + "used_for/robotics", + "used_for/scientific_calculations", + "used_for/scripts" + ] } diff --git a/docs/ABOUT.md b/docs/ABOUT.md index 9864ed0..249a63a 100644 --- a/docs/ABOUT.md +++ b/docs/ABOUT.md @@ -1,14 +1,13 @@ # About - +For more details, visit [roc-lang.org](https://roc-lang.org). diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index cd6ce85..1df9f8e 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -1,15 +1,3 @@ # Installation - +To install Roc, please follow the instructions at [roc-lang.org/install](https://roc-lang.org/install). diff --git a/docs/LEARNING.md b/docs/LEARNING.md index b14434d..c435ba0 100644 --- a/docs/LEARNING.md +++ b/docs/LEARNING.md @@ -1,13 +1,7 @@ # Learning - +Have fun learning Roc! diff --git a/docs/RESOURCES.md b/docs/RESOURCES.md index 9811f04..c072fc0 100644 --- a/docs/RESOURCES.md +++ b/docs/RESOURCES.md @@ -1,13 +1,6 @@ # Resources - +- Official website: https://www.roc-lang.org/ +- Code examples: https://www.roc-lang.org/examples +- Community: https://www.roc-lang.org/community +- Github: https://github.com/roc-lang/roc/ diff --git a/docs/SNIPPET.txt b/docs/SNIPPET.txt index 4b4a4f0..e2e6243 100644 --- a/docs/SNIPPET.txt +++ b/docs/SNIPPET.txt @@ -1 +1,17 @@ -TODO: add snippet +main = + Path.fromStr "url.txt" + |> storeEmail + |> Task.onErr handleErr + +storeEmail = \path -> + url = File.readUtf8! path + user = Http.get! url Json.utf8 + dest = Path.fromStr "$(user.name).txt" + File.writeUtf8! dest user.email + Stdout.line! "Wrote email to $(Path.display dest)" + +handleErr = \err -> + when err is + HttpErr url _ -> Stderr.line! "Error fetching URL $(url)" + FileReadErr path _ -> Stderr.line! "Error reading from $(Path.display path)" + FileWriteErr path _ -> Stderr.line! "Error writing to $(Path.display path)" diff --git a/docs/TESTS.md b/docs/TESTS.md index bec9502..ffe0aec 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -1,15 +1,5 @@ # Tests - +To test your solution to an exercise, open a terminal, go to the exercise directory, run `roc test -test.roc`, for example `roc test hello-world-test.roc`, and ensure that all the tests pass. diff --git a/exercises/practice/hello-world/.docs/instructions.append.md b/exercises/practice/hello-world/.docs/instructions.append.md new file mode 100644 index 0000000..6c0d918 --- /dev/null +++ b/exercises/practice/hello-world/.docs/instructions.append.md @@ -0,0 +1,5 @@ +# Instructions append + +The file to edit is named `HelloWorld.roc`. + +If you are using the command line, run the test suite using `roc test hello-world-test.roc` diff --git a/exercises/practice/hello-world/.docs/instructions.md b/exercises/practice/hello-world/.docs/instructions.md new file mode 100644 index 0000000..c9570e4 --- /dev/null +++ b/exercises/practice/hello-world/.docs/instructions.md @@ -0,0 +1,16 @@ +# Instructions + +The classical introductory exercise. +Just say "Hello, World!". + +["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. + +The objectives are simple: + +- Modify the provided code so that it produces the string "Hello, World!". +- Run the test suite and make sure that it succeeds. +- Submit your solution and check it at the website. + +If everything goes well, you will be ready to fetch your first real exercise. + +[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program diff --git a/exercises/practice/hello-world/.meta/Example.roc b/exercises/practice/hello-world/.meta/Example.roc new file mode 100644 index 0000000..7ebf6a7 --- /dev/null +++ b/exercises/practice/hello-world/.meta/Example.roc @@ -0,0 +1,3 @@ +module [hello] + +hello = "Hello, World!" diff --git a/exercises/practice/hello-world/.meta/config.json b/exercises/practice/hello-world/.meta/config.json new file mode 100644 index 0000000..52565a2 --- /dev/null +++ b/exercises/practice/hello-world/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "ageron" + ], + "contributors": [ + "keiravillekode" + ], + "files": { + "solution": [ + "HelloWorld.roc" + ], + "test": [ + "hello-world-test.roc" + ], + "example": [ + ".meta/Example.roc" + ] + }, + "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", + "source": "This is an exercise to introduce users to using Exercism", + "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" +} diff --git a/exercises/practice/hello-world/.meta/tests.toml b/exercises/practice/hello-world/.meta/tests.toml new file mode 100644 index 0000000..73466d6 --- /dev/null +++ b/exercises/practice/hello-world/.meta/tests.toml @@ -0,0 +1,13 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[af9ffe10-dc13-42d8-a742-e7bdafac449d] +description = "Say Hi!" diff --git a/exercises/practice/hello-world/HelloWorld.roc b/exercises/practice/hello-world/HelloWorld.roc new file mode 100644 index 0000000..ec7eeea --- /dev/null +++ b/exercises/practice/hello-world/HelloWorld.roc @@ -0,0 +1,3 @@ +module [hello] + +hello = "Goodbye, Mars!" diff --git a/exercises/practice/hello-world/hello-world-test.roc b/exercises/practice/hello-world/hello-world-test.roc new file mode 100644 index 0000000..63f9eee --- /dev/null +++ b/exercises/practice/hello-world/hello-world-test.roc @@ -0,0 +1,9 @@ +app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" } + +import pf.Task exposing [Task] +import HelloWorld exposing [hello] + +expect hello == "Hello, World!" + +main = + Task.ok {} diff --git a/exercises/practice/leap/.docs/instructions.md b/exercises/practice/leap/.docs/instructions.md new file mode 100644 index 0000000..b14f856 --- /dev/null +++ b/exercises/practice/leap/.docs/instructions.md @@ -0,0 +1,3 @@ +# Instructions + +Your task is to determine whether a given year is a leap year. diff --git a/exercises/practice/leap/.docs/introduction.md b/exercises/practice/leap/.docs/introduction.md new file mode 100644 index 0000000..4ffd2da --- /dev/null +++ b/exercises/practice/leap/.docs/introduction.md @@ -0,0 +1,16 @@ +# Introduction + +A leap year (in the Gregorian calendar) occurs: + +- In every year that is evenly divisible by 4. +- Unless the year is evenly divisible by 100, in which case it's only a leap year if the year is also evenly divisible by 400. + +Some examples: + +- 1997 was not a leap year as it's not divisible by 4. +- 1900 was not a leap year as it's not divisible by 400. +- 2000 was a leap year! + +~~~~exercism/note +For a delightful, four-minute explanation of the whole phenomenon of leap years, check out [this YouTube video](https://www.youtube.com/watch?v=xX96xng7sAE). +~~~~ diff --git a/exercises/practice/leap/.meta/Example.roc b/exercises/practice/leap/.meta/Example.roc new file mode 100644 index 0000000..060bc58 --- /dev/null +++ b/exercises/practice/leap/.meta/Example.roc @@ -0,0 +1,4 @@ +module [isLeapYear] + +isLeapYear = \year -> + (year % 4 == 0) && (year % 400 == 0 || year % 100 != 0) diff --git a/exercises/practice/leap/.meta/config.json b/exercises/practice/leap/.meta/config.json new file mode 100644 index 0000000..1186fe2 --- /dev/null +++ b/exercises/practice/leap/.meta/config.json @@ -0,0 +1,11 @@ +{ + "authors": ["ageron"], + "files": { + "solution": ["Leap.roc"], + "test": ["leap-test.roc"], + "example": [".meta/Example.roc"] + }, + "blurb": "Determine whether a given year is a leap year.", + "source": "CodeRanch Cattle Drive, Assignment 3", + "source_url": "https://coderanch.com/t/718816/Leap" +} diff --git a/exercises/practice/leap/.meta/tests.toml b/exercises/practice/leap/.meta/tests.toml new file mode 100644 index 0000000..ce6ba32 --- /dev/null +++ b/exercises/practice/leap/.meta/tests.toml @@ -0,0 +1,37 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[6466b30d-519c-438e-935d-388224ab5223] +description = "year not divisible by 4 in common year" + +[ac227e82-ee82-4a09-9eb6-4f84331ffdb0] +description = "year divisible by 2, not divisible by 4 in common year" + +[4fe9b84c-8e65-489e-970b-856d60b8b78e] +description = "year divisible by 4, not divisible by 100 in leap year" + +[7fc6aed7-e63c-48f5-ae05-5fe182f60a5d] +description = "year divisible by 4 and 5 is still a leap year" + +[78a7848f-9667-4192-ae53-87b30c9a02dd] +description = "year divisible by 100, not divisible by 400 in common year" + +[9d70f938-537c-40a6-ba19-f50739ce8bac] +description = "year divisible by 100 but not by 3 is still not a leap year" + +[42ee56ad-d3e6-48f1-8e3f-c84078d916fc] +description = "year divisible by 400 is leap year" + +[57902c77-6fe9-40de-8302-587b5c27121e] +description = "year divisible by 400 but not by 125 is still a leap year" + +[c30331f6-f9f6-4881-ad38-8ca8c12520c1] +description = "year divisible by 200, not divisible by 400 in common year" diff --git a/exercises/practice/leap/Leap.roc b/exercises/practice/leap/Leap.roc new file mode 100644 index 0000000..4473f63 --- /dev/null +++ b/exercises/practice/leap/Leap.roc @@ -0,0 +1,4 @@ +module [isLeapYear] + +isLeapYear = \year -> + year > 0 diff --git a/exercises/practice/leap/leap-test.roc b/exercises/practice/leap/leap-test.roc new file mode 100644 index 0000000..7aececf --- /dev/null +++ b/exercises/practice/leap/leap-test.roc @@ -0,0 +1,26 @@ +app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" } + +import pf.Task exposing [Task] +import Leap exposing [isLeapYear] + +# year not divisible by 4 in common year +expect !(isLeapYear 2015) +# year divisible by 2, not divisible by 4 in common year +expect !(isLeapYear 1970) +# year divisible by 4, not divisible by 100 in leap year +expect isLeapYear 1996 +# year divisible by 4 and 5 is still a leap year +expect isLeapYear 1960 +# year divisible by 100, not divisible by 400 in common year +expect !(isLeapYear 2100) +# year divisible by 100 but not by 3 is still not a leap year +expect !(isLeapYear 1900) +# year divisible by 400 is leap year +expect isLeapYear 2000 +# year divisible by 400 but not by 125 is still a leap year +expect isLeapYear 2400 +# year divisible by 200, not divisible by 400 in common year +expect !(isLeapYear 1800) + +main = + Task.ok {} diff --git a/exercises/shared/.docs/help.md b/exercises/shared/.docs/help.md index 45aa2d6..3ba7772 100644 --- a/exercises/shared/.docs/help.md +++ b/exercises/shared/.docs/help.md @@ -1,21 +1,6 @@ # Help - +Feel free to ask us questions, we'd be happy to help. diff --git a/exercises/shared/.docs/tests.md b/exercises/shared/.docs/tests.md index 1f197bf..c246ec6 100644 --- a/exercises/shared/.docs/tests.md +++ b/exercises/shared/.docs/tests.md @@ -1,15 +1,3 @@ -# Tests +# Testing on the Command Line - +To test your solution to an exercise, open a terminal, go to this exercise's directory, run `roc test -test.roc`, for example `roc test hello-world-test.roc`, and ensure that all the tests pass. From 345b0100e57f80493cecbf354e53bf403695944d Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:09:43 +0200 Subject: [PATCH 02/13] change highligh lang highlightjs does not support Roc, haskell should work ok --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 1fee224..73135d1 100644 --- a/config.json +++ b/config.json @@ -13,7 +13,7 @@ "online_editor": { "indent_style": "space", "indent_size": 4, - "highlightjs_language": "roc" + "highlightjs_language": "haskell" }, "files": { "solution": [ From 71717af6c8d5b7b34ea0ec7f8f10b226a9bf3791 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:13:06 +0200 Subject: [PATCH 03/13] use crash instead --- exercises/practice/leap/Leap.roc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/leap/Leap.roc b/exercises/practice/leap/Leap.roc index 4473f63..b2f11a8 100644 --- a/exercises/practice/leap/Leap.roc +++ b/exercises/practice/leap/Leap.roc @@ -1,4 +1,4 @@ module [isLeapYear] isLeapYear = \year -> - year > 0 + crash "TODO" From 98b37e0b3d4b379678c8a76b26fb417cd30cfed5 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:14:20 +0200 Subject: [PATCH 04/13] remove some tags --- config.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config.json b/config.json index 73135d1..6fa47bb 100644 --- a/config.json +++ b/config.json @@ -51,15 +51,10 @@ "paradigm/functional", "platform/linux", "platform/mac", - "platform/windows", "typing/strong", - "used_for/artificial_intelligence", "used_for/backends", "used_for/cross_platform_development", - "used_for/embedded_systems", "used_for/games", - "used_for/robotics", - "used_for/scientific_calculations", "used_for/scripts" ] } From 54e5d30508a426fbe005015b94ca7c127a3cbedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Tue, 20 Aug 2024 06:56:28 +1200 Subject: [PATCH 05/13] Update docs/ABOUT.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clarify About.md Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> --- docs/ABOUT.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/ABOUT.md b/docs/ABOUT.md index 249a63a..410928e 100644 --- a/docs/ABOUT.md +++ b/docs/ABOUT.md @@ -1,6 +1,7 @@ # About -Roc is a modern, fast, and safe programming language designed for building reliable software with simplicity in mind. With an emphasis on performance and minimalism, Roc brings a fresh perspective to the world of functional programming, aiming to make it accessible and efficient for developers. +Roc is a modern, fast, and safe programming language designed for building reliable software with simplicity in mind. +With an emphasis on performance and minimalism, Roc brings a fresh perspective to the world of functional programming, aiming to make it accessible and efficient for developers. ## Main Features From 29c32c13fd5f16584a452e84ea61a085c8e588a9 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:41:54 +0200 Subject: [PATCH 06/13] improve TODO Co-authored-by: Erik Schierboom --- exercises/practice/leap/Leap.roc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/leap/Leap.roc b/exercises/practice/leap/Leap.roc index b2f11a8..8881ba7 100644 --- a/exercises/practice/leap/Leap.roc +++ b/exercises/practice/leap/Leap.roc @@ -1,4 +1,4 @@ module [isLeapYear] isLeapYear = \year -> - crash "TODO" + crash "Please implement the `isLeapYear` function" From c9281f0316b84209f975002b29e04738be021a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Tue, 20 Aug 2024 22:36:36 +1200 Subject: [PATCH 07/13] Format exercises/practice/leap/.meta/config.json --- exercises/practice/leap/.meta/config.json | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/exercises/practice/leap/.meta/config.json b/exercises/practice/leap/.meta/config.json index 1186fe2..7eb6b38 100644 --- a/exercises/practice/leap/.meta/config.json +++ b/exercises/practice/leap/.meta/config.json @@ -1,9 +1,17 @@ { - "authors": ["ageron"], + "authors": [ + "ageron" + ], "files": { - "solution": ["Leap.roc"], - "test": ["leap-test.roc"], - "example": [".meta/Example.roc"] + "solution": [ + "Leap.roc" + ], + "test": [ + "leap-test.roc" + ], + "example": [ + ".meta/Example.roc" + ] }, "blurb": "Determine whether a given year is a leap year.", "source": "CodeRanch Cattle Drive, Assignment 3", From cbca5aad66397ce8c1bdc4b81cd8ceb56646360d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Tue, 20 Aug 2024 22:59:03 +1200 Subject: [PATCH 08/13] Give more details in tests.md --- exercises/shared/.docs/tests.md | 41 ++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/exercises/shared/.docs/tests.md b/exercises/shared/.docs/tests.md index c246ec6..aeaf21f 100644 --- a/exercises/shared/.docs/tests.md +++ b/exercises/shared/.docs/tests.md @@ -1,3 +1,42 @@ # Testing on the Command Line -To test your solution to an exercise, open a terminal, go to this exercise's directory, run `roc test -test.roc`, for example `roc test hello-world-test.roc`, and ensure that all the tests pass. +To download an exercise, for example `hello-world`, open a terminal and run: + +```bash +exercism download --track roc --exercise hello-world +``` + +Then go to the exercise directory and edit the code to solve the exercise. For example: + +```bash +cd {your Exercism folder}/roc/hello-world +edit HelloWorld.roc +``` + +Each exercise comes with a test suite. You can run the tests using the `roc test` command, for example: + +``` +roc test hello-world-test.roc +``` + +If you've solved the exercise, you should see 0 failed test, for example: + +``` +0 failed and 1 passed in 583 ms. +``` + +However, if your code has any errors, they will look like this: + +``` +── EXPECT FAILED in hello-world-test.roc ─────────────────────────────────────── + +This expectation failed: + +6│ expect hello == "Hello, World!" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +1 failed and 0 passed in 1264 ms. +``` + +This should help you fix your code. Once your code works, you can submit it using the `exercism submit` command (see `HELP.md` in the exercise directory for more details). From 858ac115a62373a3f2abbea04a4c4cc77655caca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Tue, 20 Aug 2024 23:00:31 +1200 Subject: [PATCH 09/13] Simplify LEARNING.md --- docs/LEARNING.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/LEARNING.md b/docs/LEARNING.md index c435ba0..5070ec0 100644 --- a/docs/LEARNING.md +++ b/docs/LEARNING.md @@ -2,6 +2,5 @@ - The [Roc tutorial](https://www.roc-lang.org/tutorial) is a good place to start. - You can then go through the [code examples](https://www.roc-lang.org/examples). -- Then you will want to get your hands dirty! Go through the Exercism practice exercises in this Roc track. Have fun learning Roc! From feb2abb77dca5397de3682b0a126d046ee439483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Tue, 20 Aug 2024 23:04:31 +1200 Subject: [PATCH 10/13] Clarify what needs to be installed --- docs/INSTALLATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 1df9f8e..18c4a5e 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -1,3 +1,3 @@ # Installation -To install Roc, please follow the instructions at [roc-lang.org/install](https://roc-lang.org/install). +To install Roc, please follow the instructions at [roc-lang.org/install](https://roc-lang.org/install). You only need to install Roc, and optionally the editor Extensions/Plugins of your choice, you don't need to install Rust or Zig (which are used to build Roc itself). From a493200653878664fb9f761adfb7012138ec6ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Wed, 21 Aug 2024 08:49:47 +1200 Subject: [PATCH 11/13] Simplify & shorten the code snippet --- docs/SNIPPET.txt | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/docs/SNIPPET.txt b/docs/SNIPPET.txt index e2e6243..6857229 100644 --- a/docs/SNIPPET.txt +++ b/docs/SNIPPET.txt @@ -1,17 +1,13 @@ -main = - Path.fromStr "url.txt" - |> storeEmail - |> Task.onErr handleErr +app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" } + +import pf.Stdout -storeEmail = \path -> - url = File.readUtf8! path - user = Http.get! url Json.utf8 - dest = Path.fromStr "$(user.name).txt" - File.writeUtf8! dest user.email - Stdout.line! "Wrote email to $(Path.display dest)" +factorial = \n -> + if n == 1 then + 1 + else + n * factorial (n - 1) -handleErr = \err -> - when err is - HttpErr url _ -> Stderr.line! "Error fetching URL $(url)" - FileReadErr path _ -> Stderr.line! "Error reading from $(Path.display path)" - FileWriteErr path _ -> Stderr.line! "Error writing to $(Path.display path)" +main = + result = factorial 5 + Stdout.line! "factorial 5 = 1 * 2 * 3 * 4 * 5 = $(Num.toStr result)" From 49bca3e86571769d271f7c223552beb98dda2ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Wed, 21 Aug 2024 09:14:33 +1200 Subject: [PATCH 12/13] Add key features to config.json --- config.json | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/config.json b/config.json index 6fa47bb..16aa984 100644 --- a/config.json +++ b/config.json @@ -46,6 +46,38 @@ } ] }, + "key_features": [ + { + "title": "Fast", + "content": "Roc code is designed to build fast and run fast. It compiles to machine code or WebAssembly.", + "icon": "fast" + }, + { + "title": "Functional", + "content": "Roc has a small number of simple language primitives. It's a single-paradigm functional language.", + "icon": "functional" + }, + { + "title": "Friendly", + "content": "Roc's syntax, semantics, and included toolset all prioritize user-friendliness.", + "icon": "extensible" + }, + { + "title": "Safe", + "content": "Roc's powerful type system and immutability lead to more predictable and maintainable code.", + "icon": "immutable" + }, + { + "title": "Interoperable", + "content": "Roc is works well with other languages, making it easier to integrate into existing projects.", + "icon": "interop" + }, + { + "title": "Evolving", + "content": "Roc is a young language, and it is evolving fast.", + "icon": "evolving" + } + ], "tags": [ "execution_mode/compiled", "paradigm/functional", From 48147a08b533143007fb1a43e5c62adce0f2f1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Wed, 21 Aug 2024 09:16:48 +1200 Subject: [PATCH 13/13] Update docs/INSTALLATION.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com> --- docs/INSTALLATION.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 18c4a5e..d5fa26a 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -1,3 +1,4 @@ # Installation -To install Roc, please follow the instructions at [roc-lang.org/install](https://roc-lang.org/install). You only need to install Roc, and optionally the editor Extensions/Plugins of your choice, you don't need to install Rust or Zig (which are used to build Roc itself). +To install Roc, please follow the instructions at [roc-lang.org/install](https://roc-lang.org/install). +You only need to install Roc, and optionally the editor Extensions/Plugins of your choice, you don't need to install Rust or Zig (which are used to build Roc itself).