plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
7eb0b59
— Peter John
2026-11-04T10:19:17+05:30
docs: component-style functional game in restrictions T14; decision record updated
docs/decisions/2026-11-language-and-scene-decisions.md
CHANGED
|
@@ -36,6 +36,12 @@ A record of the design decisions taken in the 2026-11-03/04 sessions, with the r
|
|
|
36
36
|
- **Deferred (user):** structural `==` for records. The user chose deep structural equality (like Rust's `#[derive(PartialEq)]`, not cycle-safe), then deferred building it. Until then `==` on records is identity, and events are compared field by field.
|
|
37
37
|
- **Plan:** `docs/plans/2026-11-03-state-view-parity.md` (merged).
|
|
38
38
|
|
|
39
|
+
## 4b. Component style for the functional game (React/Elm model)
|
|
40
|
+
|
|
41
|
+
- **Observation (user):** the pure example read more easily than the functional one, because each kind (Orb, Ship) kept its data, behaviour and drawing together, while the functional file spread an orb over many functions, nested `Cons(head:, tail:)` literals, rebuilt list helpers and threaded random seeds by hand.
|
|
42
|
+
- **Decision (user):** keep the cohesion and the purity: per-kind records with `step(self, ..) -> Self` (Elm `update`) and `view(self, ..) -> SceneNode` (a React component returning a tree), a `State` with its own `step`/`view`, `List(...)` literals, an `Rng` value. Heterogeneous kinds can use a trait (`trait Entity = fun step(self, dt) -> Entity; fun view(self, ..) -> SceneNode`). The tree costs nothing at runtime because the supercompiler fuses `Picture.draw(io, state.view())`; nothing is diffed because every frame is redrawn.
|
|
43
|
+
- **Plan:** done in the language-restrictions plan's T14. PureScene stays for now; retiring it (two styles left: mutable `Scene` and functional components) is a follow-up once the result is seen.
|
|
44
|
+
|
|
39
45
|
## 5. Functional scene graphs: notes from the discussion
|
|
40
46
|
|
|
41
47
|
- Picture already follows the textbook functional design: a recursive ADT, the matrix passed down instead of parent pointers, top-down hit paths, assets referenced by handle.
|
|
@@ -70,6 +76,7 @@ A record of the design decisions taken in the 2026-11-03/04 sessions, with the r
|
|
|
70
76
|
3. **Fusion runs before union lowering** (internal).
|
|
71
77
|
4. **Only expression-bodied functions** (`= ...`) are fusion candidates.
|
|
72
78
|
5. **Pattern casing is enforced:** Capitalised names are tags, lowercase names are binders. This removes the bug class behind a miscompile where an error name was read as a variable.
|
|
79
|
+
- **Refinement (during the build):** "expression-bodied" allows leading pure local bindings (`x := e`) before one tail expression, with no `return`, loops or assignments, like `let ... in`.
|
|
73
80
|
- **Plan:** `docs/plans/2026-11-03-language-restrictions.md` (in progress).
|
|
74
81
|
|
|
75
82
|
## 9. Next: no heap mutation at all (Koka-style FBIP)
|
docs/plans/2026-11-03-language-restrictions.md
CHANGED
|
@@ -218,7 +218,7 @@ Package: compiler + std; categories: state, deep.
|
|
|
218
218
|
**Model:** sonnet
|
|
219
219
|
**Est. time:** 5 min
|
|
220
220
|
**Consumes:** none
|
|
221
|
-
**Produces:** examples/games/fixtures: game shells' changing fields (World.state etc.) `mut`, pure game code on spreads; `--allow-mutation` removed from the checker/CLI
|
|
221
|
+
**Produces:** examples/games/fixtures: game shells' changing fields (World.state etc.) `mut`, pure game code on spreads; `--allow-mutation` removed from the checker/CLI; games/functional/game_state_view.plum rewritten in the component style (user, 2026-11-04): per-kind records (Ship, Orb, Mine, Star) with `step(self, ..) -> Self` and `view(self, ..) -> SceneNode`, a `State` with `step`/`view`, `List(...)` and std List methods instead of Cons chains and the homemade list helpers, an `Rng` value instead of hand-threaded seeds and helper records, the draw path `Picture.draw(io, w.state.view())` still fully fused (fusion_alloc_test green); game tests keep names and values
|
|
222
222
|
**Review Focus:** state: game behaviour identical (host parity, browser checks).
|
|
223
223
|
**Test code:** full suite green; host_test + web_check green.
|
|
224
224
|
|