From 0b67b217cb91b034945d1c9458f4a48d005e86cf Mon Sep 17 00:00:00 2001 From: BNAndras <20251272+BNAndras@users.noreply.github.com> Date: Mon, 30 Mar 2026 21:17:16 -0700 Subject: [PATCH 1/2] add SNIPPET.txt --- docs/SNIPPET.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/SNIPPET.txt b/docs/SNIPPET.txt index 4b4a4f0..d9f4ceb 100644 --- a/docs/SNIPPET.txt +++ b/docs/SNIPPET.txt @@ -1 +1,8 @@ -TODO: add snippet +let rec fibonacci = n => + switch n { + | 0 => 0 + | 1 => 1 + | n => fibonacci(n - 1) + fibonacci(n - 2) + } + +let first10 = Array.fromInitializer(~length=10, fibonacci) From c5dc1b4c9455f563fb621cc633b730bec827c63b Mon Sep 17 00:00:00 2001 From: BNAndras <20251272+BNAndras@users.noreply.github.com> Date: Mon, 30 Mar 2026 22:45:52 -0700 Subject: [PATCH 2/2] Add track docs --- docs/ABOUT.md | 15 +---- docs/INSTALLATION.md | 34 +++++++--- docs/LEARNING.md | 14 ++--- docs/RESOURCES.md | 14 +---- docs/TESTS.md | 106 +++++++++++++++++++++++++++++--- exercises/shared/.docs/help.md | 23 ++----- exercises/shared/.docs/tests.md | 15 +---- 7 files changed, 142 insertions(+), 79 deletions(-) diff --git a/docs/ABOUT.md b/docs/ABOUT.md index 9864ed0..4c4b0df 100644 --- a/docs/ABOUT.md +++ b/docs/ABOUT.md @@ -1,14 +1,5 @@ # About - +If it compiles, it runs. +ReScript is a typed language that brings OCaml's type system to the JavaScript ecosystem, with built-in JSX syntax and official React bindings. +Every type is inferred, there is no `any` escape hatch, and pattern matching is exhaustive. diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index cd6ce85..1433248 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -1,15 +1,31 @@ # Installation - +## Installing dependencies + +Each ReScript exercise is a self-contained npm project. +After downloading an exercise with the [Exercism CLI][exercism-cli], install the project dependencies including ReScript and you're ready to go: + +```sh +cd /path/to/exercise +npm install +``` + +## Editor support + +The ReScript Project maintains a [list of both official and community-supported editor plugins][rescript-plugins]. + +[nodejs]: https://nodejs.org/ +[nodejs-install]: https://nodejs.org/en/download +[exercism-cli]: https://github.com/exercism/cli +[rescript-plugins]: https://rescript-lang.org/docs/manual/editor-plugins diff --git a/docs/LEARNING.md b/docs/LEARNING.md index b14434d..1ff2d5b 100644 --- a/docs/LEARNING.md +++ b/docs/LEARNING.md @@ -1,13 +1,13 @@ # Learning - +If you know **OCaml**, ReScript shares the same type system and many of the same concepts. diff --git a/docs/RESOURCES.md b/docs/RESOURCES.md index 9811f04..74e109c 100644 --- a/docs/RESOURCES.md +++ b/docs/RESOURCES.md @@ -1,13 +1,5 @@ # Resources - +- [ReScript Language Manual](https://rescript-lang.org/docs/manual/introduction) — full language reference +- [ReScript API](https://rescript-lang.org/docs/manual/latest/api) — standard library documentation +- [ReScript Forum](https://forum.rescript-lang.org/) — the official discussion forum diff --git a/docs/TESTS.md b/docs/TESTS.md index bec9502..e5bcc69 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -1,15 +1,103 @@ -# Tests +# Running the Tests - +## Install Dependencies + +Before running the tests, install the exercise dependencies. + +```sh +npm install +``` + +## Run the Tests + +Compile and run the provided test suite using either `exercism test` or `npm install`. + +## Understanding Test Results + +The test runner shows each test run with a pass/fail status. + +```text +1/3: no name given + PASS - no name given +2/3: a name given + FAIL - a name given + --- + operator: equal + left: One for you, one for me. + right: One for Alice, one for me. + ... +3/3: another name given + FAIL - another name given + --- + operator: equal + left: One for you, one for me. + right: One for Bob, one for me. + ... + +# Ran 3 tests (3 assertions) +# 1 passed +# 2 failed +``` + +`left` is what your code returned. `right` is what the test expected. + +## Understanding the Exercise Structure + +```text +two-fer/ +├── src/ +│ ├── TwoFer.res // your solution goes here +│ └── TwoFer.resi // the optional interface file containing signatures +├── tests/ +│ └── TwoFer_test.res // your test suite +├── package.json // used to install project dependencies +└── ... +``` + +`TwoFer.resi` here is an optional interface file. +When present, it defines the function signatures your solution must satisfy and can serve as a hint for what to implement. + +For example, if the interface declares: + +```rescript +let hello: unit => string +``` + +Your implementation should define: + +```rescript +let hello = () => "Hello, World!" +``` + +## Compiler Errors + +If your code doesn't compile, ReScript's compiler produces detailed error messages with the exact location and expected types. + +```text + We've found a bug for you! + + 1 │ let x: string = 42 + + This has type: int + But it's expected to have type: string + + You can convert int to string with Int.toString. +``` + +Read the error message carefully because it usually points directly to the problem. + +[cli]: https://exercism.org/docs/using/solving-exercises/working-locally diff --git a/exercises/shared/.docs/help.md b/exercises/shared/.docs/help.md index 45aa2d6..7084ca8 100644 --- a/exercises/shared/.docs/help.md +++ b/exercises/shared/.docs/help.md @@ -1,21 +1,8 @@ # Help - +- [ReScript Language Manual](https://rescript-lang.org/docs/manual/introduction) — full language reference +- [ReScript API](https://rescript-lang.org/docs/manual/latest/api) — standard library documentation +- [ReScript Discord](https://rescript-lang.org/community#discord) - the official Discord server +- [ReScript Forum](https://forum.rescript-lang.org/) — the official discussion forum diff --git a/exercises/shared/.docs/tests.md b/exercises/shared/.docs/tests.md index 1f197bf..95d24c8 100644 --- a/exercises/shared/.docs/tests.md +++ b/exercises/shared/.docs/tests.md @@ -1,15 +1,4 @@ # Tests - +First, install dependencies if you haven't already by running `npm install` in the project folder. +Then, run the tests either using `exercism test` or `npm test`.