docs(course): fix review findings in modules 00–05

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-29 01:04:03 +01:00
1 parent 1d0b8c3a5c
commit ab8abaaa77
4 files changed
+66 -7

No files matched your search

+18 -4
View File
@@ -26,7 +26,7 @@ After this module you can:
### Design it yourself first
Take a sheet of paper and fifteen minutes. **Do not read past the "Stop here" line until you have written something down.** It does not matter if your answer differs from the course's; what matters is that you have thought about the questions, so that the canonical model answers questions you have actually asked.
Take a sheet of paper and fifteen minutes. **Do not read past the "Stop here" line until you have written something down, and do not open this module's stub file yet** (`js/src/model.js`, `scala/src/Model.scala`, `fsharp/src/Model.fs`): its type declarations already contain the course's answer. You will open it for the exercises, after the reveal. It does not matter if your answer differs from the course's; what matters is that you have thought about the questions, so that the canonical model answers questions you have actually asked.
Your task: write down the type of "the state of a game of Snake", in the language of your track or in pseudo-code. Use these questions to guide you:
@@ -47,9 +47,9 @@ Your task: write down the type of "the state of a game of Snake", in the languag
### The canonical model
Here is the model the course uses. All three tracks use the same fields with the same meaning, which is what lets one JSON fixture test all three.
Here is the model the course uses. (Now you may open your stub file: in Scala and F# these declarations are already written there for you, and in JS they are the JSDoc comments at the top of `model.js`.) All three tracks use the same fields with the same meaning, which is what lets one JSON fixture test all three.
**JavaScript** (JS has no types, so the shape is documented with JSDoc in `model.js`)
**JavaScript** (JS has no types, so the shape is documented with JSDoc comments)
```js
/** @typedef {{x: number, y: number}} Point */
/** @typedef {'Up'|'Down'|'Left'|'Right'} Direction */
@@ -59,7 +59,7 @@ Here is the model the course uses. All three tracks use the same fields with the
// Action: {tag:'Tick'} | {tag:'Turn', dir} | {tag:'TogglePause'} | {tag:'Restart'} | {tag:'Frame'}
```
**Scala** (already in `Model.scala`)
**Scala**
```scala
final case class Point(x: Int, y: Int)
enum Direction:
@@ -403,6 +403,20 @@ Replace `get Tick() { return todo('m02') }` by `Tick: { tag: 'Tick' }`, and so o
</details>
<details><summary>Exercise 2.4 (Action) — near-solution (try the others first)</summary>
```js
export const Action = {
Tick: { tag: ___ },
Turn: (dir) => ({ tag: ___, ___ }),
TogglePause: ___,
Restart: ___,
Frame: ___,
}
```
</details>
<details><summary>Exercise 2.5 (initialState) — nudge</summary>
This is a single record literal. Read the fixture `m02-initial-state.json`: the `expected` value is exactly the record you must build (with the seed from `args`).