docs(course): fix review findings in modules 06–11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a7a4cb5b2a
commit
673be0067e
6 files changed
+93
-51
No files matched your search
@@ -268,6 +268,8 @@ Later work in Haskell, such as [Yampa](https://wiki.haskell.org/Yampa) (used for
|
||||
|
||||
## Exercises
|
||||
|
||||
> **About test names.** The test titles quoted under "Proved by" are the JavaScript ones. The Scala and F# suites test the same things one-to-one, but their titles use each track's vocabulary: "events" instead of "inputs", `None` instead of `null`, `()` instead of `undefined`, `bind`/`choose` instead of `flatMap`/`filterMap`, `IO.map throwingF io` instead of `map(io, throwingF)`, and so on. Failing tests are reported by name when you run the module's tests; to read all titles, open `scala/test/M08Stream.test.scala` or `fsharp/tests/M08Stream.fs`. Fixture-based tests have the same case names in every track.
|
||||
|
||||
Do them in this order; later ones use earlier ones (`filterMap` can be written using `map` and `filter`; the tests for everything use `run`, so write `run` early).
|
||||
|
||||
### Exercise 8.1 — `run`
|
||||
@@ -287,9 +289,12 @@ def run(events: List[Event]): List[A] = ??? // a method on Stream[A]: s.run(ev
|
||||
**F#**
|
||||
|
||||
```fsharp
|
||||
let run (events: Event list) (Stream step: Stream<'a>) : 'a list = failwith "TODO m08"
|
||||
let step (e: Event) (s: Stream<'a>) : 'a list * Stream<'a> = failwith "TODO m08" // F# only, see below
|
||||
let run (events: Event list) (s: Stream<'a>) : 'a list = failwith "TODO m08"
|
||||
```
|
||||
|
||||
**F# only:** in JS and Scala you step a stream with `s.step(e)`. In F# the function is wrapped in the single-case union `Stream`, so the F# file has a small helper `Stream.step e s` that unwraps it and calls the function (one line with a pattern match, `let (Stream f) = s`). Write it first and use it everywhere else. It has its own test: `step feeds one event and returns its outputs and the next stream`.
|
||||
|
||||
A pure fold over the events (no `let` reassignments, no `push`). **Proved by:** `run of no inputs is empty` (Scala/F#: `run of no events is empty`), and every other test.
|
||||
|
||||
### Exercise 8.2 — sources: `keyDowns`, `keyUps`, `interval`
|
||||
|
||||
Reference in new issue
Block a user