diff --git a/README.md b/README.md index c7b95bdb..9c01f342 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ + + # ReactiveScript A small language for reactive UIs that carries diff --git a/assets/README.md b/assets/README.md new file mode 100644 index 00000000..77159e06 --- /dev/null +++ b/assets/README.md @@ -0,0 +1,13 @@ +# Logo + +`logo.svg` is `r = x`: the name read as an equation, `=` being how .rx writes +one (an equation stays true). The two bars are two colours, two values held +equal. + +- Tile `#12233D`, corner radius 22 of 100. On a dark ground the tile can be + `#1F3B63`. +- Letters `#FFFFFF`, JetBrains Mono ExtraBold at 38/100, outlined to paths, so + the SVG needs no font. +- Top bar `#5B9BE6`, bottom bar `#F0B44C`, 7/100 thick with round caps. + +`tooling/vscode-rx/icon.png` is this SVG rendered at 256 px. diff --git a/assets/logo.svg b/assets/logo.svg new file mode 100644 index 00000000..9c1c3f69 --- /dev/null +++ b/assets/logo.svg @@ -0,0 +1,8 @@ + + ReactiveScript + + + + + + diff --git a/guide/async.md b/guide/async.md index 51ec27b5..03fe5f35 100644 --- a/guide/async.md +++ b/guide/async.md @@ -23,7 +23,7 @@ submitted, close a menu, clear an error), give it its own instant: `onFlush(() = compiler can't tell a reset from a write that should wait with the rest, such as a tab highlight that moves with its page, so it's your call. Decide it for each write that sits next to work that loads. -``` +```rx // submit a todo: the input clears now, the row shows as a guess until the server answers let t = text onFlush(() => { text := "" }) @@ -32,7 +32,7 @@ addTodo(t) ## 1. Reading from the server: an equation -``` +```rx forecast = city == "" ? null : city.length < 3 ? throw TooShort(city) : await fetchForecast(city) ``` @@ -59,7 +59,7 @@ forecast = city == "" ? null : city.length < 3 ? throw TooShort(city) : await fe ## 3. Writing to the server: an action -``` +```rx export source profile: Profile = await loadProfile() // a source with a question: it can take a guess export source saveError: string = "" @@ -95,7 +95,7 @@ by what the screen should do: When several actions can each change a different row of one list, guess the row, not the list: -``` +```rx export source todos: Todo[] key id = await loadTodos() export action markDone(id: number) { @@ -136,7 +136,7 @@ A guess on a value whose question reads a selection holds the selection with it: something else waits for the server, and the screen stays on the old choice until the action ends (F-1). Keep the pending items in a source of their own, with a constant question, and show them beside the loaded ones: -``` +```rx source photo: number := 1 tags = await loadTags(photo) source adding: { photo: number; tag: string }[] = [] @@ -169,7 +169,7 @@ and the screen reads only the top: `examples/todos.rx` is the whole app: -``` +```rx server = await loadTodos() // 1. what the server has: re-asked after every write source failures: Failure[] := [] // outlives a reset: kept until a retry is accepted source todos: Row[] key id = withFailures(server, failures) // 2. the client's layer; 3. row guesses go on it diff --git a/guide/language.md b/guide/language.md index 8c6dfd46..a3440230 100644 --- a/guide/language.md +++ b/guide/language.md @@ -7,7 +7,7 @@ code. ## Modules -``` +```rx import pure { fetchUser } from "./api" // a loader: callable anywhere, re-asked when its inputs change import { saveUser } from "./api" // io: callable only in imperative code (handlers, actions, effects) import { Avatar } from "./Avatar.rx" // another .rx module @@ -21,7 +21,7 @@ does (`export action select(id) { selected := id }`, or an action passed as a pr ## Declarations -``` +```rx source count: number := 0 // state; written only with `:=` in imperative code source user = await fetchUser(id) // state with a question: re-asked when `id` changes, can take a guess double = count * 2 // an equation: always equal to its right side, never written @@ -57,7 +57,7 @@ values. Arrays and strings have their usual methods: `xs.filter(f)`, `xs.map(f)` A component body is declarations, then markup. JSX is verbatim; control flow is braced: -``` +```rx component IssueList(props: { issues: Issue[] }) { source open := true
@@ -87,7 +87,7 @@ component IssueList(props: { issues: Issue[] }) { Handlers, `action` bodies and `effect` apply blocks: -``` +```rx effect (count) { log($0) } // runs after `count` changes; `$0` is its value (async.md §6) @@ -106,7 +106,7 @@ effect (count) { log($0) } // runs after `count` changes; `$0` is its value (a ## Components -``` +```rx component Card(props: { title: string; children: View }) { source open := false
{ open := !open }}> diff --git a/scenarios/S-action-1.md b/scenarios/S-action-1.md index 7f99aa31..c303067d 100644 --- a/scenarios/S-action-1.md +++ b/scenarios/S-action-1.md @@ -4,7 +4,7 @@ Rules: AC-7, AC-1, AC-3, W-6, R-f-6. ## Program -``` +```rx export default component App() { source cart = [1, 2] source status := "" @@ -45,7 +45,7 @@ a failed action: the action handled it. ## Variant: a panic ends the body — the held writes still commit -``` +```rx export default component App() { source cart = [1, 2] source status := "" @@ -76,7 +76,7 @@ rejection or a `throw` the body does not catch is a compile error (below). ## Variant: throw caught in a plain handler -``` +```rx export default component App() { source status := "" @@ -90,7 +90,7 @@ export default component App() { ## Rejected variants -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE export default component App() { source cart = [1, 2] @@ -111,7 +111,7 @@ R-f-6: the rejection of `fetch("checkout")` (a JS promise: `fails(Error)`) leaves the body uncaught, and nothing can catch it after — the handler that launched the action does not await it. -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE error Declined(reason) export default component App() { diff --git a/scenarios/S-action-2.md b/scenarios/S-action-2.md index 7c31893b..beb3cb3f 100644 --- a/scenarios/S-action-2.md +++ b/scenarios/S-action-2.md @@ -5,7 +5,7 @@ authoritative view), `tests/until.test.ts`. ## Program -``` +```rx export default component App() { source name := "Ann" // the truth, as a live channel pushes it source shown = name @@ -55,7 +55,7 @@ The truth is already `Ann`: `until` resolves at once. ## Rejected variants -``` +```rx -- reject: IO_IN_REACTIVE export default component App() { source ok := false @@ -67,7 +67,7 @@ export default component App() { `until` waits for the world; it is called from imperative scope (Solid: "Cannot call until inside a reactive scope"). -``` +```rx -- reject: UNTIL_PREDICATE export default component App() { source ok := false @@ -79,7 +79,7 @@ export default component App() { The argument is a predicate, `() => e`: a value is read once, and would never change. -``` +```rx -- reject: REACTIVE_WRITE_IN_OWNED_SCOPE export default component App() { source ok := false @@ -90,7 +90,7 @@ export default component App() { The predicate is reactive scope: it reads; it does not write. -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE export default component App() { source id := 1 diff --git a/scenarios/S-action-3.md b/scenarios/S-action-3.md index c130e298..7efa5f47 100644 --- a/scenarios/S-action-3.md +++ b/scenarios/S-action-3.md @@ -5,7 +5,7 @@ compiled .rx show `1` at instant 1; the interpreter showed `3`. ## Program -``` +```rx export default component App() { source n := 0 source guess = n diff --git a/scenarios/S-action-4.md b/scenarios/S-action-4.md index d4475cc7..6072498b 100644 --- a/scenarios/S-action-4.md +++ b/scenarios/S-action-4.md @@ -5,7 +5,7 @@ Solid and compiled .rx show `0` at instant 3; the interpreter showed `5`. ## Program -``` +```rx export default component App() { source n := 0 source guess = n diff --git a/scenarios/S-ai-feed.md b/scenarios/S-ai-feed.md index 87bfcbe9..1c92ae65 100644 --- a/scenarios/S-ai-feed.md +++ b/scenarios/S-ai-feed.md @@ -61,7 +61,7 @@ change and lands with the body's end (AC-7). ## Rejected variants -``` +```rx -- reject: OPTIMISTIC_NO_QUESTION -- handler: pick() export default component App() { @@ -74,7 +74,7 @@ export default component App() { `selected` is declared with `:=` — it has no question for a guess to confirm against (ST-5c). -``` +```rx -- reject: RG-7b context room: number component Room(props: { id: number }) { diff --git a/scenarios/S-await-1.md b/scenarios/S-await-1.md index 0b9dc9bb..cbc77a7d 100644 --- a/scenarios/S-await-1.md +++ b/scenarios/S-await-1.md @@ -4,7 +4,7 @@ Rules: R-1, E-11, R-7, R-f-4, AC-1, AC-7, R-f-6. ## Program -``` +```rx error Declined(reason: string) => `declined: ${reason}` component Badge(props: { v: string }) { {props.v} @@ -50,7 +50,7 @@ action's end. Instant 5: the reader re-asks with `more` true; the held ## Variant: a typed catch passes other classes to the `try` around it -``` +```rx error Declined(reason: string) => `declined: ${reason}` export default component App() { source status := "" @@ -79,7 +79,7 @@ the statement catches it. ## Rejected variants -``` +```rx -- reject: AWAIT_IN_EXPRESSION export default component App() { source status := "" @@ -94,7 +94,7 @@ AC-1: a run suspends only at a statement — `await e`, `let v = await e`, either with a `catch`. An `await` inside an imperative expression is refused: bind it first (`let r = await fetch("checkout")`). -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE error Declined(reason: string) => `declined: ${reason}` export default component App() { diff --git a/scenarios/S-check-1.md b/scenarios/S-check-1.md index b009fe3d..9cab6844 100644 --- a/scenarios/S-check-1.md +++ b/scenarios/S-check-1.md @@ -8,7 +8,7 @@ checker, statically, before the program runs. ## Program -``` +```rx import pure { len } from "./prelude" context panel: string // RG-7: a declared context @@ -60,7 +60,7 @@ Instant 1: `a`'s own `pre` is the value it is replacing, `1` (C-2). ## Rejected variants -``` +```rx -- reject: DUPLICATE_DECLARATION export default component App() { source x := 1 @@ -70,7 +70,7 @@ export default component App() { } ``` -``` +```rx -- reject: CYCLE export default component App() { source m := true @@ -84,7 +84,7 @@ export default component App() { The branches are exclusive and no run closes the cycle; the static graph is the union of branches and refuses it (CN-3a). -``` +```rx -- reject: CYCLE export default component App() { source s := 1 @@ -98,7 +98,7 @@ export default component App() { `pre` of *another* node is an input of it (C-2): only an equation's own `pre` breaks a cycle. -``` +```rx -- reject: PRE_OF_NON_REACTIVE export default component App() { fn f(x) => x @@ -108,7 +108,7 @@ export default component App() { } ``` -``` +```rx -- reject: ROW_NARROWER_THAN_INFERRED export default component App() { source id := 1 @@ -121,7 +121,7 @@ export default component App() { The written row says `lane` only; the value is also `pending` (CN-4a). Rows are checked only when written. -``` +```rx -- reject: UNBOUND component Row(props) {

{caption}

} component List(props) { @@ -136,14 +136,14 @@ export default component App() { `Row` sees its declaration site, not its caller (RG-7a). -``` +```rx -- reject: UNKNOWN_COMPONENT export default component App() { } ``` -``` +```rx -- reject: ACTION_CALLED_IN_OWNED_SCOPE export default component App() { source n := 1 @@ -154,7 +154,7 @@ export default component App() { } ``` -``` +```rx -- reject: IO_IN_FN import { log } from "./prelude" export default component App() { @@ -165,7 +165,7 @@ export default component App() { } ``` -``` +```rx -- reject: REACTIVE_WRITE_IN_OWNED_SCOPE export default component App() { source n := 1 @@ -178,7 +178,7 @@ export default component App() { A closure created in reactive scope is pure (SC-3); a statement body is a write position. Handlers are written on the element (`onClick={() => { … }}`). -``` +```rx -- reject: ASYNC_STORE_SETTER export default component App() { source id := 1 @@ -188,7 +188,7 @@ export default component App() { } ``` -``` +```rx -- reject: WRITE_TO_NON_SOURCE export default component App() { source n := 1 @@ -198,7 +198,7 @@ export default component App() { } ``` -``` +```rx -- reject: OPTIMISTIC_OUTSIDE_HOLD export default component App() { source name := "Ann" @@ -209,7 +209,7 @@ export default component App() { } ``` -``` +```rx -- reject: OPTIMISTIC_NO_QUESTION export default component App() { source shown := "Ann" @@ -219,7 +219,7 @@ export default component App() { } ``` -``` +```rx -- reject: INVALID_REFRESH_TARGET export default component App() { source base := 1 @@ -228,7 +228,7 @@ export default component App() { } ``` -``` +```rx -- reject: INVALID_AFFECTS_TARGET export default component App() { action go(n) { affects n } @@ -237,7 +237,7 @@ export default component App() { } ``` -``` +```rx -- reject: REGION_ESCAPE export default component App() { source handlers := [] @@ -252,7 +252,7 @@ export default component App() { `() => hits` captures the row's `hits`; `handlers` outlives the row (O-3). -``` +```rx -- reject: REGION_ESCAPE export default component App() { source handlers := [] @@ -273,7 +273,7 @@ fs => [...fs, () => v]`. RG-7c is withdrawn, 2026-10-31: a provider now provides writer functions, and a closure handed to one as an argument is not yet followed by O-3. See the gap noted under O-3 in 03-regions.) -``` +```rx -- reject: REGION_ESCAPE source handlers := [] fn counter(ref start: number) { @@ -298,7 +298,7 @@ Calling it is fine anywhere: `handlers := [...handlers, c.get()]` stores a number. What a call returns holds a closure only when the closure called makes one: -``` +```rx -- reject: REGION_ESCAPE export default component App() { source handlers := [] @@ -312,7 +312,7 @@ export default component App() { } ``` -``` +```rx -- reject: REGION_ESCAPE source registry := [] component Item(props) { @@ -338,7 +338,7 @@ a `source` context provided above the rows. That form is withdrawn (RG-7c, 2026-10-31); the same store made through a provided writer function is the O-3 gap noted in 03-regions.) -``` +```rx -- reject: CONTEXT_NOT_FOUND context panel: string component Panel(props) { diff --git a/scenarios/S-check-2.md b/scenarios/S-check-2.md index 99cb96a5..125caaa9 100644 --- a/scenarios/S-check-2.md +++ b/scenarios/S-check-2.md @@ -8,7 +8,7 @@ loop across instants and is refused. A write in a closure the apply creates ## Program -``` +```rx export default component App() { source n := 0 effect (n) { log($0); return () => { n := 0 } } @@ -30,7 +30,7 @@ cleanup writes `n := 0`, which opens instant 2 (EF-5, W-3). ## Rejected variants -``` +```rx -- reject: EFFECT_WRITES_OWN_SOURCE export default component App() { source count := 0 @@ -43,7 +43,7 @@ export default component App() { Clamping in the apply: write `clamped = count > 10 ? 10 : count`, or clamp at the write. -``` +```rx -- reject: EFFECT_WRITES_OWN_SOURCE export default component App() { source items := [1, 2] @@ -60,7 +60,7 @@ instead — `shown = valid ? selected : null` — or make `selected` a source with a question over `items` (ST-5), which re-derives when `items` changes and stays writable otherwise. -``` +```rx -- reject: EFFECT_WRITES_OWN_SOURCE export default component App() { source n := 0 diff --git a/scenarios/S-context-1.md b/scenarios/S-context-1.md index 0fe41bf7..6d1d4c6f 100644 --- a/scenarios/S-context-1.md +++ b/scenarios/S-context-1.md @@ -4,13 +4,13 @@ Rules: RG-7a..e, MO-7, R-f-5, CN-4a. ## Modules -``` +```rx -- module: ./theme.rx export context theme: string = "light" export context accent: string ``` -``` +```rx -- module: ./other.rx export context accent: string ``` @@ -20,7 +20,7 @@ spelling, another declaration. ## Program -``` +```rx import { theme, accent } from "./theme.rx" source mode := "dark" component Label(props) { {use theme}/{use accent} } @@ -47,7 +47,7 @@ default; the second reads `Themed`'s. Both find `main`'s `accent`. ## Rejected variants -``` +```rx -- reject: CONTEXT_NOT_FOUND import { accent } from "./theme.rx" import { accent as paint } from "./other.rx" @@ -61,7 +61,7 @@ export default component App() { MO-7: a provision of `other.rx`'s `accent` is not one of `theme.rx`'s. -``` +```rx -- reject: ROW_NARROWER_THAN_INFERRED import { accent } from "./theme.rx" provide accent = await fetch("accent") @@ -75,7 +75,7 @@ RG-7e: an exported context's type is its contract — `accent: string` writes no rows, so a provision that is pending and can fail is refused at the `provide`. Its importers, on both sides, rely on the declaration. -``` +```rx -- reject: UNHANDLED_FAILURE context who: string provide who = await fetch("who") @@ -88,7 +88,7 @@ export default component App() { A context that is not exported and writes no rows takes its rows from its provisions: `use who` can fail with `Error`, so its reader needs a boundary. -``` +```rx -- reject: WRITE_TO_NON_SOURCE import { accent } from "./theme.rx" provide accent = "blue" @@ -100,7 +100,7 @@ export default component App() { O-4: a context is read beneath its provision, never written through. -``` +```rx -- reject: SOURCE_CONTEXT context picked: source number @@ -114,7 +114,7 @@ export default component App() { `context x: source T` (RG-7c) is withdrawn (ruled 2026-10-31): the provider provides the writes it allows, as functions. -``` +```rx -- reject: NOT_A_CONTEXT export default component App() { source picked := 1 @@ -124,7 +124,7 @@ export default component App() { } ``` -``` +```rx -- reject: CONTEXT_AS_VALUE import { theme } from "./theme.rx" diff --git a/scenarios/S-core-1.md b/scenarios/S-core-1.md index fa217f19..b99bac51 100644 --- a/scenarios/S-core-1.md +++ b/scenarios/S-core-1.md @@ -4,7 +4,7 @@ Rules exercised: E-1, E-2, E-4, E-6, W-1, W-2, W-3, C-2, C-2a, EF-2, EF-4, P-6. ## Program -``` +```rx export default component App() { source count := 0 source show := true @@ -29,7 +29,7 @@ export default component App() { ## Variant: no effect (`double` undemanded while `show` is false) -``` +```rx export default component App() { source count := 0 source show := true @@ -53,20 +53,20 @@ here and `prev 2` / `prev 14` at instants 2 and 4 of the main table.) ## Rejected variants -``` +```rx -- reject: W-1 source count := 0 double = count * 2 effect (count) { double := 4 } ``` -``` +```rx -- reject: W-2 source count := 0 count := 1 ``` -``` +```rx -- reject: C-1 export default component App() { source s := 0 diff --git a/scenarios/S-effect-store-1.md b/scenarios/S-effect-store-1.md index 89034d77..4521d5eb 100644 --- a/scenarios/S-effect-store-1.md +++ b/scenarios/S-effect-store-1.md @@ -4,7 +4,7 @@ Rules exercised: EF-1, EF-2, H-11, ST-4, AC-3, AC-4. ## Program -``` +```rx export default component App() { source rows key id = await fetch("l") effect (rows) { log(rows_title($0)) } diff --git a/scenarios/S-effect-store-2.md b/scenarios/S-effect-store-2.md index 21d73241..995900f8 100644 --- a/scenarios/S-effect-store-2.md +++ b/scenarios/S-effect-store-2.md @@ -4,7 +4,7 @@ Rules exercised: EF-1, EF-2, E-12, ST-4, AC-4. ## Program -``` +```rx export default component App() { source rows key id = await fetch("l") effect (rows catch (e) => null) { log($0 == null ? "none" : len($0)) } diff --git a/scenarios/S-fail-1.md b/scenarios/S-fail-1.md index 0af348e9..4d9a855a 100644 --- a/scenarios/S-fail-1.md +++ b/scenarios/S-fail-1.md @@ -4,7 +4,7 @@ Rules: R-f-1, R-f-3, R-f-4, R-f-5, H-12, D-41. ## Program -``` +```rx error BadId(id) => `bad id ${id}` error NotFound(id) => `no user ${id}` source id := 1 @@ -51,7 +51,7 @@ boundaries in one frame. ## Variant: a boundary that lists `Error` takes everything -``` +```rx error BadId(id) => `bad id ${id}` error NotFound(id) => `no user ${id}` source id := 1 @@ -76,7 +76,7 @@ failure, so `BadId` lands here although it is not listed. ## Rejected variants -``` +```rx -- reject: UNHANDLED_FAILURE error BadId(id) => `bad id ${id}` error NotFound(id) => `no user ${id}` @@ -95,7 +95,7 @@ export default component App() { R-f-5: without the root boundary, the fetch's `Error` passes the `BadId` boundary and nothing above discharges it. -``` +```rx -- reject: UNHANDLED_FAILURE error BadId(id) => `bad id ${id}` error NotFound(id) => `no user ${id}` @@ -112,7 +112,7 @@ export default component App() { Neither `NotFound` (no catch on the reader) nor `Error` is discharged. -``` +```rx -- reject: NOT_AN_ERROR_CLASS export default component App() { source id := 1 @@ -122,7 +122,7 @@ export default component App() { } ``` -``` +```rx -- reject: ROW_NARROWER_THAN_INFERRED error NotFound(id) => `no user ${id}` source id := 1 diff --git a/scenarios/S-fail-2.md b/scenarios/S-fail-2.md index 67c804dd..0f694441 100644 --- a/scenarios/S-fail-2.md +++ b/scenarios/S-fail-2.md @@ -4,7 +4,7 @@ Rules: R-f-4, R-f-5, R-f-6, R-2, RG-4c, H-4, D-41. ## Program -``` +```rx error Missing(key) => `missing ${key}` source key := "a" value = key == "" ? throw Missing(key) : await fetch("v:" + key) @@ -59,7 +59,7 @@ readers of `value` hold nothing (H-4) and recover with the answer (D-41); ## Rejected variants -``` +```rx -- reject: UNHANDLED_FAILURE error Missing(key) => `missing ${key}` source key := "a" @@ -75,7 +75,7 @@ export default component App() { R-f-5: `Safe` renders its children with no boundary above them. -``` +```rx -- reject: UNHANDLED_FAILURE error Missing(key) => `missing ${key}` source key := "a" @@ -92,7 +92,7 @@ export default component App() { Passing is not reading (R-2): the failure is found where `Panel` reads `props.body`, and followed out through this application to the root. -``` +```rx -- reject: UNHANDLED_FAILURE error Missing(key) => `missing ${key}` source key := "a" @@ -108,7 +108,7 @@ export default component App() { `Line` discharges `Missing`; the fetch's `Error` passes its catch. -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE component Btn(props) { action go() { log(props.v) } @@ -125,7 +125,7 @@ export default component App() { R-f-6, R-f-7: the action's snapshot of `props.v` throws when the argument is an error — the boundary at the caller cannot catch inside an action. -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE error Missing(key) => `missing ${key}` export default component App() { diff --git a/scenarios/S-fail-3.md b/scenarios/S-fail-3.md index 955cafd6..2969102d 100644 --- a/scenarios/S-fail-3.md +++ b/scenarios/S-fail-3.md @@ -4,7 +4,7 @@ Rules: R-f-10, R-f-3, R-f-4, R-f-5, CN-6b. ## Program -``` +```rx import pure { fail } from "./prelude" export default component App() { source raw := "ok" @@ -38,7 +38,7 @@ value replaces it and the page recovers. ## Rejected variants -``` +```rx -- reject: UNHANDLED_FAILURE export default component App() { source raw := "ok" diff --git a/scenarios/S-fail-4.md b/scenarios/S-fail-4.md index 2b700daf..fb5c80b8 100644 --- a/scenarios/S-fail-4.md +++ b/scenarios/S-fail-4.md @@ -4,7 +4,7 @@ Rules: R-f-4, R-f-5, R-6, D-41. ## Program -``` +```rx component Detail(props) { item = await fetch("item:" + props.id) heading = props.titles[props.id] catch (e) => item.title diff --git a/scenarios/S-flush-1.md b/scenarios/S-flush-1.md index 751071c3..00ad486c 100644 --- a/scenarios/S-flush-1.md +++ b/scenarios/S-flush-1.md @@ -4,7 +4,7 @@ Rules exercised: EF-8, W-3, H-2, AC-1; Solid `onFlush` (solidjs/solid#4292). ## Program -``` +```rx export default component App() { source open := true source page := 1 @@ -50,7 +50,7 @@ until the page lands. ## Rejected variants -``` +```rx -- reject: IO_IN_REACTIVE export default component App() { source open := true @@ -62,7 +62,7 @@ export default component App() { `onFlush` schedules a run; it is called from imperative scope (Solid warns with `ON_FLUSH_IN_OWNED_SCOPE`; here it is a compile error). -``` +```rx -- reject: HOOK_CALLBACK export default component App() { source open := true diff --git a/scenarios/S-guess-reask-refresh.md b/scenarios/S-guess-reask-refresh.md index 02cacb02..aaffb6bf 100644 --- a/scenarios/S-guess-reask-refresh.md +++ b/scenarios/S-guess-reask-refresh.md @@ -4,7 +4,7 @@ Rules exercised: AC-3, AC-4, H-11, D-34. ## Program -``` +```rx export default component App() { source detail = await fetch("d") action rename(t) { try { optimistic detail.title := t; await fetch("save"); refresh detail } catch (e) {} } @@ -36,7 +36,7 @@ effect's view too. ## Variant: read by an effect alone -``` +```rx export default component App() { source detail = await fetch("d") action rename(t) { try { optimistic detail.title := t; await fetch("save"); refresh detail } catch (e) {} } diff --git a/scenarios/S-hold-1.md b/scenarios/S-hold-1.md index f75912ff..bdba1afc 100644 --- a/scenarios/S-hold-1.md +++ b/scenarios/S-hold-1.md @@ -5,7 +5,7 @@ H-5, H-6, H-7, H-9, R-1, R-4, R-9, R-10, R-11, V-1. ## Program -``` +```rx export default component App() { source id := "a" product = await fetch("p:" + id) @@ -43,7 +43,7 @@ the screen keeps `A`; `latest id` shows `b` and `pending? product` shows ## Rejected variants -``` +```rx -- warn: ASYNC_OUTSIDE_LOADING_BOUNDARY export default component App() { source id := "a" diff --git a/scenarios/S-hold-2.md b/scenarios/S-hold-2.md index 90213650..b22692dd 100644 --- a/scenarios/S-hold-2.md +++ b/scenarios/S-hold-2.md @@ -5,7 +5,7 @@ H-5, H-6, H-7, R-4. ## Program -``` +```rx export default component App() { source period := "q1" summary = await fetch("s:" + period) @@ -41,7 +41,7 @@ change together (H-2). `latest period` moves at once (H-7). ## Variant: the audit panel takes its own skeleton with `on` -``` +```rx export default component App() { source period := "q1" summary = await fetch("s:" + period) @@ -79,7 +79,7 @@ belongs to the frame of the change that armed it). ## Variant: audit lands first — its skeleton is never seen -``` +```rx export default component App() { source period := "q1" summary = await fetch("s:" + period) diff --git a/scenarios/S-hold-3.md b/scenarios/S-hold-3.md index 52c3708f..d61d4b2e 100644 --- a/scenarios/S-hold-3.md +++ b/scenarios/S-hold-3.md @@ -4,7 +4,7 @@ Rules: H-2, H-3, H-4, H-10, R-4. (H-3 rewritten after Solid S-4.) ## Program -``` +```rx export default component App() { source id := "a" source n := 0 @@ -34,7 +34,7 @@ caught). Instant 4: `product` lands. ## Variant: superseded flight -``` +```rx export default component App() { source id := "a" product = await fetch("p:" + id) diff --git a/scenarios/S-hold-4.md b/scenarios/S-hold-4.md index cbe23610..f9d7b86c 100644 --- a/scenarios/S-hold-4.md +++ b/scenarios/S-hold-4.md @@ -4,7 +4,7 @@ Rules: H-7, R-9, R-10, R-4. ## Program -``` +```rx export default component App() { source id := "a" product = await fetch("p:" + id) diff --git a/scenarios/S-hold-5.md b/scenarios/S-hold-5.md index 975ff972..bebc991d 100644 --- a/scenarios/S-hold-5.md +++ b/scenarios/S-hold-5.md @@ -4,7 +4,7 @@ Rules: H-12, H-4, R-6, E-12. ## Program -``` +```rx export default component App() { source id := "a" product = await fetch("p:" + id) diff --git a/scenarios/S-hold-6.md b/scenarios/S-hold-6.md index cbbb9f71..4b55c042 100644 --- a/scenarios/S-hold-6.md +++ b/scenarios/S-hold-6.md @@ -4,7 +4,7 @@ Rules: H-12, H-6, H-5, D-41. ## Program -``` +```rx error NotFound(id) => `item ${id} not found` source sel := 4 item = await fetch("i:" + sel) diff --git a/scenarios/S-infer-1.md b/scenarios/S-infer-1.md index e8be2d96..e4747eda 100644 --- a/scenarios/S-infer-1.md +++ b/scenarios/S-infer-1.md @@ -4,7 +4,7 @@ Rules: AC-1b, AC-1, AC-3, AC-7, H-11, R-f-6. ## Program -``` +```rx export default component App() { source liked = "no" source error := "" @@ -49,7 +49,7 @@ as in S-action-1. ## Rejected variants -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE export default component App() { source liked = "no" @@ -60,7 +60,7 @@ export default component App() { An inferred action catches what its body can fail with, like a declared one (R-f-6): nothing awaits a handler. -``` +```rx -- reject: OPTIMISTIC_OUTSIDE_HOLD export default component App() { source draft := "a" diff --git a/scenarios/S-infer-2.md b/scenarios/S-infer-2.md index 5c64b21f..8fdbd96f 100644 --- a/scenarios/S-infer-2.md +++ b/scenarios/S-infer-2.md @@ -4,7 +4,7 @@ Rules: AC-1b, AC-1c, AC-1, EF-8, W-6. ## Program -``` +```rx export default component App() { source status := "" @@ -35,7 +35,7 @@ save is still out (S-flush-1). ## Variant: held on purpose -``` +```rx export default component App() { source status := "" action save() { @@ -60,7 +60,7 @@ there. ## Rejected variants -``` +```rx -- reject: HELD_WRITE export default component App() { source status := "" @@ -77,7 +77,7 @@ the body now is, `saving` would wait for the server. The fixes are named by what the write is for: `optimistic` for state that shows while the work runs, `onFlush` for a reset, a declared action to hold it on purpose. -``` +```rx -- reject: HELD_WRITE export default component App() { source saving := false diff --git a/scenarios/S-infer-3.md b/scenarios/S-infer-3.md index 9d093c72..c1f72260 100644 --- a/scenarios/S-infer-3.md +++ b/scenarios/S-infer-3.md @@ -4,7 +4,7 @@ Rules: AC-1b, AC-1 (D-7 adoption), AC-3, H-11. ## Program -``` +```rx export default component App() { source liked = "no" action like() { try { let r = await fetch("like"); liked := r } catch (e) {} } diff --git a/scenarios/S-infer-4.md b/scenarios/S-infer-4.md index ba99b6e8..88167f4d 100644 --- a/scenarios/S-infer-4.md +++ b/scenarios/S-infer-4.md @@ -4,7 +4,7 @@ Rules: AC-1b, AC-4, AC-5, D-31; the inline form of S-solid-26's `reload`. ## Program -``` +```rx export default component App() { user = await fetch("u") diff --git a/scenarios/S-infer-5.md b/scenarios/S-infer-5.md index 23c53e44..fa7f2bd0 100644 --- a/scenarios/S-infer-5.md +++ b/scenarios/S-infer-5.md @@ -4,7 +4,7 @@ Rules: AC-1d, W-4, H-10, W-6; Solid 2.0.0-rc.19: an `action()` that writes a sig ## Program -``` +```rx export default component App() { source count := 0 source seen := 0 @@ -24,7 +24,7 @@ The value written is kept in a local and read from there. ## Rejected variants -``` +```rx -- reject: STALE_OWN_READ export default component App() { source count := 0 @@ -37,7 +37,7 @@ export default component App() { made it (W-4). The checker can see the run's own writes, so this read is an error; a read of anything else is the committed snapshot it always was. -``` +```rx -- reject: STALE_OWN_READ export default component App() { source seq := 0 @@ -58,7 +58,7 @@ the same. A plain handler's change ends at its `await`, so there the read would see the committed write; but a handler that writes and awaits is now an action (AC-1b). -``` +```rx -- reject: STALE_OWN_READ export default component App() { source form := { name: "", email: "" } diff --git a/scenarios/S-infer-6.md b/scenarios/S-infer-6.md index 2e0888af..9e798c80 100644 --- a/scenarios/S-infer-6.md +++ b/scenarios/S-infer-6.md @@ -4,7 +4,7 @@ Rules: AC-1e, W-6, AC-1, H-2. ## Program -``` +```rx export default component App() { source log := "" action add(x: string) { @@ -31,7 +31,7 @@ Two adds are out at once. Each appends to `log` as it stands at its write ## Rejected variants -``` +```rx -- reject: STALE_WRITE_BACK export default component App() { source log := "" @@ -50,7 +50,7 @@ so the frames would end at `log: a`, not `log: ba`. The compiler sees the read, the `await` and the write in one body, so this is an error; Solid cannot see them and lets the lost update through. -``` +```rx -- reject: STALE_WRITE_BACK export default component App() { source items := [] @@ -68,7 +68,7 @@ The guess before the `await` is fine: it is this change's own picture. The write after it is the lost update (found by the eval's round 4: two posts at once, and a list that reloaded while a post was out). -``` +```rx -- reject: STALE_WRITE_BACK export default component App() { source detail := { id: 1, title: "a" } diff --git a/scenarios/S-latest-reask.md b/scenarios/S-latest-reask.md index d106fc0c..e0c8cb8f 100644 --- a/scenarios/S-latest-reask.md +++ b/scenarios/S-latest-reask.md @@ -4,7 +4,7 @@ Rules exercised: R-12, H-7, H-11, AC-3, AC-4, ST-4. ## Program -``` +```rx export default component App() { source rows key id = await fetch("l") action close(id) { try { optimistic rows := rows.filter(r => r.id != id); await fetch("close"); refresh rows } catch (e) {} } diff --git a/scenarios/S-module-1.md b/scenarios/S-module-1.md index e85a1372..c45c953b 100644 --- a/scenarios/S-module-1.md +++ b/scenarios/S-module-1.md @@ -4,7 +4,7 @@ Rules: MO-1, MO-1d, MO-2, MO-3, MO-4, MO-5, MO-6, R-f-5, R-f-6, RG-7b. ## Modules -``` +```rx -- module: ./store.rx export error NotFound(id) => `no user ${id}` export source selected := 1 @@ -13,7 +13,7 @@ export action select(id) { selected := id } export fn initials(name) => name.slice(0, 1) ``` -``` +```rx -- module: ./ui.rx import { NotFound, initials } from "./store.rx" export context who: string @@ -37,13 +37,13 @@ export component Pick(props) { } ``` -``` +```rx -- module: ./a.rx import { b } from "./b.rx" export a = b + 1 ``` -``` +```rx -- module: ./b.rx import { a } from "./a.rx" export b = a + 1 @@ -73,7 +73,7 @@ The same text, with no `ui.rx` beside it, is read in place of the module ## Program -``` +```rx import { selected, user, select } from "./store.rx" import { Card, Name, Badge, who } from "./ui.rx" provide who = "Zed" @@ -107,7 +107,7 @@ question holds the change. Instant 4: the rejection is an `Error`, which ## Rejected variants -``` +```rx -- reject: MO-2 import { selected } from "./store.rx" @@ -118,7 +118,7 @@ export default component App() { An imported source is read-only: the module exports `select` to write it. -``` +```rx -- reject: REGION_ESCAPE import { Pick } from "./ui.rx" @@ -134,7 +134,7 @@ export default component App() { O-3 through a signature: the row's closure would outlive the row in `ui.rx`'s `picks`. The checker sees only `retains(onPick: module)`. -``` +```rx -- reject: NOT_EXPORTED import { hidden } from "./store.rx" @@ -143,7 +143,7 @@ export default component App() { } ``` -``` +```rx -- reject: MODULE_NOT_FOUND import { x } from "./nope.rx" @@ -152,7 +152,7 @@ export default component App() { } ``` -``` +```rx -- reject: MODULE_CYCLE import { a } from "./a.rx" @@ -163,7 +163,7 @@ export default component App() { MO-5: `a.rx` and `b.rx` import each other. -``` +```rx -- reject: IMPORT_ROW_MISMATCH import pure { select } from "./store.rx" @@ -175,7 +175,7 @@ export default component App() { MO-4: `select` is an action — `io` in its signature; `pure` cannot lower an `.rx` row. -``` +```rx -- reject: CONTEXT_NOT_FOUND import { Badge } from "./ui.rx" @@ -187,7 +187,7 @@ export default component App() { RG-7b through a signature: `Badge` uses `who`, and nothing above this application provides it. -``` +```rx -- reject: UNHANDLED_FAILURE import { user } from "./store.rx" import { Name } from "./ui.rx" @@ -200,7 +200,7 @@ export default component App() { `Name` discharges `NotFound` only; the fetch's `Error` comes out at this application with nothing above it. -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE import { user } from "./store.rx" import { Save } from "./ui.rx" @@ -213,7 +213,7 @@ export default component App() { `Save`'s action reads `props.v`: an argument that can fail is refused at the application, whatever boundary is above it (R-f-6). -``` +```rx -- reject: SHADOWED_IMPORT import { initials } from "./store.rx" diff --git a/scenarios/S-module-2.md b/scenarios/S-module-2.md index 95ac991a..41e745bb 100644 --- a/scenarios/S-module-2.md +++ b/scenarios/S-module-2.md @@ -4,7 +4,7 @@ Rules: MO-8, R-io-4, R-f-8, R-f-4, R-f-6. ## Modules -``` +```rx -- module: ./api.d.rx // what ./api (a JS module) exports, in rows export error NotFound @@ -20,7 +20,7 @@ default, so it says nothing. No import restates any of this. ## Program -``` +```rx import { fetchUser, saveUser, NotFound, Offline, User } from "./api" export default component App() { source id := 1 @@ -61,7 +61,7 @@ typed boundary. ## Rejected variants -``` +```rx -- reject: NOT_EXPORTED import { deleteUser } from "./api" @@ -72,7 +72,7 @@ export default component App() { MO-8: with a declaration file, a JS module exports what it declares. -``` +```rx -- reject: IMPORT_ROW_MISMATCH import pure { saveUser } from "./api" @@ -83,7 +83,7 @@ export default component App() { `saveUser` is declared io; `pure` on the import cannot lower it. -``` +```rx -- reject: IMPORT_ROW_MISMATCH import { fetchUser } from "./api" fails NotFound @@ -94,7 +94,7 @@ export default component App() { The declaration file is the row; the import cannot restate it. -``` +```rx -- reject: IO_IN_REACTIVE import { saveUser } from "./api" export default component App() { @@ -104,7 +104,7 @@ export default component App() { } ``` -``` +```rx -- reject: UNHANDLED_FAILURE import { fetchUser, NotFound } from "./api" export default component App() { @@ -117,7 +117,7 @@ export default component App() { `Offline` is left: the declared rejections are the whole row, and nothing here discharges `Offline`. -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE import { saveUser, NotFound } from "./api" export default component App() { diff --git a/scenarios/S-module-3.md b/scenarios/S-module-3.md index 81fbb95c..b18bb0dd 100644 --- a/scenarios/S-module-3.md +++ b/scenarios/S-module-3.md @@ -4,7 +4,7 @@ Rules: MO-9, MO-3, MO-2, MO-6, R-f-5, R-f-6, RG-7b. ## Modules -``` +```rx -- module: ./store.d.rx export error NotFound(id) export source selected := … @@ -13,7 +13,7 @@ export action select export pure fn initials(name) rejects(Error) ``` -``` +```rx -- module: ./ui.d.rx export context who: string export component Card(props: { children: catches(*) }) shape(roots p div; closes-p; children-at div) @@ -33,7 +33,7 @@ module against its imports' text instead of their bodies. ## Program -``` +```rx import { selected, user, select } from "./store.rx" import { Card, Name, Badge, who } from "./ui.rx" provide who = "Zed" @@ -51,7 +51,7 @@ modules' compiled code, which a `.d.rx` does not carry. ## Rejected variants -``` +```rx -- reject: UNHANDLED_FAILURE import { user } from "./store.rx" import { Name } from "./ui.rx" @@ -63,7 +63,7 @@ export default component App() { `Name` discharges `NotFound` only; the fetch's `Error` leaves it at its application, with no boundary above (R-f-5 through the summary). -``` +```rx -- reject: CONTEXT_NOT_FOUND import { Badge } from "./ui.rx" export default component App() { @@ -73,7 +73,7 @@ export default component App() { `uses(./ui.rx#who)`: no provision above the application (RG-7b). -``` +```rx -- reject: WRITE_TO_NON_SOURCE import { selected } from "./store.rx" export default component App() { @@ -83,7 +83,7 @@ export default component App() { MO-2: an imported source is read-only. -``` +```rx -- reject: NOT_EXPORTED import { users } from "./store.rx" export default component App() { @@ -91,7 +91,7 @@ export default component App() { } ``` -``` +```rx -- reject: UNCAUGHT_ACTION_FAILURE import { user } from "./store.rx" import { Save } from "./ui.rx" @@ -103,7 +103,7 @@ export default component App() { R-f-6: `Save`'s action reads `props.v` and catches nothing; `user` can fail with `Error | NotFound`. -``` +```rx -- reject: INVALID_REFRESH_TARGET import { selected } from "./store.rx" export default component App() { diff --git a/scenarios/S-region-1.md b/scenarios/S-region-1.md index 61c17258..790d50d0 100644 --- a/scenarios/S-region-1.md +++ b/scenarios/S-region-1.md @@ -4,7 +4,7 @@ Rules exercised: RG-1a, RG-1b, E-4, O-2. ## Program -``` +```rx export default component App() { source open := true @@ -36,7 +36,7 @@ re-ran its initializer (RG-1a). Instant 4: truthy→truthy does not switch ## Rejected variants -``` +```rx -- reject: W-1 -- handler: total := 2 export default component App() { diff --git a/scenarios/S-region-2.md b/scenarios/S-region-2.md index 9ef99e70..a376490e 100644 --- a/scenarios/S-region-2.md +++ b/scenarios/S-region-2.md @@ -4,7 +4,7 @@ Rules exercised: RG-1b, RG-1c, E-11. ## Program -``` +```rx export default component App() { source user := { name: "a" } diff --git a/scenarios/S-region-3.md b/scenarios/S-region-3.md index bd28e9b4..17555811 100644 --- a/scenarios/S-region-3.md +++ b/scenarios/S-region-3.md @@ -4,7 +4,7 @@ Rules exercised: RG-2a, RG-2b, RG-2c, E-4. ## Program -``` +```rx export default component App() { source a := { id: "a" } source b := { id: "b" } diff --git a/scenarios/S-region-4.md b/scenarios/S-region-4.md index 54d9ddfa..abf2173c 100644 --- a/scenarios/S-region-4.md +++ b/scenarios/S-region-4.md @@ -4,7 +4,7 @@ Rules exercised: RG-3, EF-2, EF-4, EF-5, O-2. ## Program -``` +```rx export default component App() { source open := true source n := 0 diff --git a/scenarios/S-region-5.md b/scenarios/S-region-5.md index da139dbd..b39f4245 100644 --- a/scenarios/S-region-5.md +++ b/scenarios/S-region-5.md @@ -4,7 +4,7 @@ Rules exercised: RG-4a, RG-4b, RG-4c, RG-1a, E-6. ## Program -``` +```rx component Greeting(props) { shout = props.name + "!"

{shout} {props.children}

@@ -34,7 +34,7 @@ recreated with it (RG-4a, RG-1a). ## Rejected variants -``` +```rx -- reject: RG-4a component Greeting(props) {

{props.name}

} export default component App() { diff --git a/scenarios/S-region-6.md b/scenarios/S-region-6.md index 8b419a9b..a74af44b 100644 --- a/scenarios/S-region-6.md +++ b/scenarios/S-region-6.md @@ -4,7 +4,7 @@ Rules exercised: E-9, E-10 (diagnostic), RG-6a, RG-6b, RG-6c. ## Program -``` +```rx export default component App() { fn double(v) => v * 2 fn counter(ref base, step) { @@ -36,7 +36,7 @@ of `n` — the body did not re-run (instant 3 shows 3 + 5 + 10). ## Rejected variants -``` +```rx -- reject: SNAPSHOT_ARGUMENT export default component App() { fn watch(v) { @@ -50,7 +50,7 @@ export default component App() { } ``` -``` +```rx -- reject: E-9 export default component App() { fn counter(ref base) { diff --git a/scenarios/S-region-7.md b/scenarios/S-region-7.md index 427a906f..d5225dde 100644 --- a/scenarios/S-region-7.md +++ b/scenarios/S-region-7.md @@ -18,7 +18,7 @@ RG-7c, and a field wrote `use fields := …` with any value it liked.) ## Program -``` +```rx type Row = { ok: boolean } context fields: { add: (r: Row) => void; remove: (r: Row) => void } // RG-7: declared; it carries the writes the form allows (O-4) component Form(props) { @@ -73,7 +73,7 @@ keep `add` and `remove` in step: nothing calls one without the other. ## Rejected variants -``` +```rx -- reject: RG-7b context fields: { add: (r: unknown) => void } component Field(props) { diff --git a/scenarios/S-region-8.md b/scenarios/S-region-8.md index ba8eba0e..9642c062 100644 --- a/scenarios/S-region-8.md +++ b/scenarios/S-region-8.md @@ -4,7 +4,7 @@ Rules exercised: RG-8 (PT-1–PT-3), RG-1a, RG-7b, O-4. ## Program -``` +```rx context tone: string = "plain" source open := false source n := 0 @@ -42,7 +42,7 @@ Served, the page is `count 0`: the server renders nothing for a portal ## Rejected variants -``` +```rx -- reject: CONTENT_MODEL export default component App() { portal { x } diff --git a/scenarios/S-remount-refresh.md b/scenarios/S-remount-refresh.md index 938217ef..ad6f200e 100644 --- a/scenarios/S-remount-refresh.md +++ b/scenarios/S-remount-refresh.md @@ -4,7 +4,7 @@ Rules exercised: AC-4, H-11, ST-4, O-2. ## Program -``` +```rx component List() { source rows key id = tag(await fetch("l")) action ren() { try { optimistic rows[0].title := "x"; await fetch("save"); refresh rows } catch (e) {} } diff --git a/scenarios/S-server-1.md b/scenarios/S-server-1.md index 6e4fcb90..de0fd1c7 100644 --- a/scenarios/S-server-1.md +++ b/scenarios/S-server-1.md @@ -4,14 +4,14 @@ Rules exercised: SV-1, SV-2, SV-5; H-12, R-f-4, R-f-10. ## Modules -``` +```rx -- module: ./api.d.rx export error NotFound export pure fn fetchUser(id: number) rejects(NotFound) export pure fn fetchPosts(id: number) ``` -``` +```rx -- module: ./profile.rx import { fetchUser, fetchPosts } from "./api" export source id := 7 @@ -21,7 +21,7 @@ export posts = await fetchPosts(id) ## Program -``` +```rx import { NotFound } from "./api" import { user, posts } from "./profile.rx" export default component App() { diff --git a/scenarios/S-server-2.md b/scenarios/S-server-2.md index 60bb8171..1b53e0a9 100644 --- a/scenarios/S-server-2.md +++ b/scenarios/S-server-2.md @@ -4,7 +4,7 @@ Rules exercised: SV-3e, SV-3d; AC-1. ## Program -``` +```rx export default component App() { source n := 0 source note := "" diff --git a/scenarios/S-server-3.md b/scenarios/S-server-3.md index 71e2dfd1..0db89309 100644 --- a/scenarios/S-server-3.md +++ b/scenarios/S-server-3.md @@ -4,7 +4,7 @@ Rules exercised: SV-7b, SF-5b; SV-1, SV-3; R-7. ## Modules -``` +```rx -- module: ./api.d.rx // what only the browser knows export client pure fn viewport() @@ -13,7 +13,7 @@ export client pure fn timeZone() ## Program -``` +```rx import { viewport, timeZone } from "./api" export default component App() { width = await viewport() @@ -46,7 +46,7 @@ are the browser's, after it has taken the page over. ## Rejected variants -``` +```rx -- reject: CLIENT_QUESTION_UNHELD import { viewport } from "./api" export default component App() { @@ -59,7 +59,7 @@ export default component App() { Nothing holds it: on the server this page would never finish (Solid: `ASYNC_OUTSIDE_LOADING_BOUNDARY`, at run time). -``` +```rx -- reject: CLIENT_QUESTION_UNHELD import { viewport } from "./api" export default component App() { @@ -73,7 +73,7 @@ export default component App() { A value computed from a client question is one: its reader needs the hold. -``` +```rx -- reject: CLIENT_QUESTION_UNHELD import { viewport } from "./api" component Size(props) {

{props.w}

} @@ -86,7 +86,7 @@ export default component App() { Through a prop: the component reads it where nothing holds it. -``` +```rx -- reject: CLIENT_NOT_AWAITED import { viewport } from "./api" export default component App() { diff --git a/scenarios/S-server-4.md b/scenarios/S-server-4.md index fa5ceebc..1f8ecae1 100644 --- a/scenarios/S-server-4.md +++ b/scenarios/S-server-4.md @@ -4,14 +4,14 @@ Rules exercised: SV-7d; SV-3a; MO-3. ## Modules -``` +```rx -- module: ./row.rx export component Row(props) { {props.name} } ``` ## Program -``` +```rx import { Row } from "./row.rx" component Note(props) {

{props.children}

} export default component App() { @@ -35,7 +35,7 @@ children in a `

`; a `` is phrasing content, so it stays there. ## Rejected variants -``` +```rx -- reject: CONTENT_MODEL import { Row } from "./row.rx" export default component App() { @@ -49,7 +49,7 @@ The server's `` is parsed with a `` the client never builds (it inserts each row into the table). Solid's compiler assumes "table partials are used in the right place"; this is the place. -``` +```rx -- reject: CONTENT_MODEL import { Row } from "./row.rx" @@ -60,7 +60,7 @@ export default component App() { Outside a table the parser drops the `` and `{props.children} } @@ -84,7 +84,7 @@ export default component App() { Children land where the component puts them: here, a `` in a ``, which the parser moves out of the table. -``` +```rx -- reject: CONTENT_MODEL export default component App() { source ok := true @@ -96,7 +96,7 @@ export default component App() { A branch is its own template: Solid's compiler sees `

` and `

` apart. The checker sees them together. -``` +```rx -- reject: CONTENT_MODEL component Link(props) { {props.children} } diff --git a/scenarios/S-settled-1.md b/scenarios/S-settled-1.md index a47b2cd7..932ccf27 100644 --- a/scenarios/S-settled-1.md +++ b/scenarios/S-settled-1.md @@ -4,7 +4,7 @@ Rules exercised: EF-7, EF-4, AC-1, H-2; Solid `onSettled` (unowned form). ## Program -``` +```rx export default component App() { source status := "idle" action save() { @@ -41,7 +41,7 @@ in the same instant. ## Rejected variants -``` +```rx -- reject: IO_IN_REACTIVE export default component App() { source n := 0 @@ -52,7 +52,7 @@ export default component App() { In a component body the mount hook is `effect () { … }` (EF-4). -``` +```rx -- reject: SETTLED_CLEANUP_UNOWNED export default component App() { source n := 0 diff --git a/scenarios/S-sf-1.md b/scenarios/S-sf-1.md index 9a76e71b..b280a663 100644 --- a/scenarios/S-sf-1.md +++ b/scenarios/S-sf-1.md @@ -4,7 +4,7 @@ Rules exercised: SF-1, SF-2, SF-3, SF-4, SF-5a, SF-6; SV-5; R-io-3, R-f-5. ## Modules -``` +```rx -- module: ./api.d.rx // a database module: it runs only on the server export error NotFound @@ -19,7 +19,7 @@ function's body may call them. `findUser` is a loader; `insertNote` is io. ## Program -``` +```rx import { findUser, insertNote, NotFound } from "./api" error TooLong(n: number) => `too long: ${n}` server fn loadUser(id) { @@ -80,7 +80,7 @@ it crosses as itself. ## Rejected variants -``` +```rx -- reject: SERVER_CAPTURE source n := 1 server fn f() { return n } @@ -94,7 +94,7 @@ export default component App() { SF-3: a source, wherever it is declared — on the server it is the request's, never the client's value. Pass it: `server fn f(n)`. -``` +```rx -- reject: SERVER_CAPTURE source n := 1 fn next() => n + 1 @@ -109,7 +109,7 @@ export default component App() { A value `fn` is nameable unless it reads reactive state; this one reads `n`. -``` +```rx -- reject: SERVER_CAPTURE component Card(props) { server fn title() { return props.title } @@ -125,7 +125,7 @@ export default component App() { Capture is by kind, not position: a server function inside a component is fine, naming its props is not. -``` +```rx -- reject: SERVER_WRITE source status := "" server fn save(x) { status := "saved"; return x } @@ -137,7 +137,7 @@ export default component App() { SF-4: return the value; the action that awaited the call writes it. -``` +```rx -- reject: SERVER_ONLY import { findUser } from "./api" export default component App() { @@ -149,7 +149,7 @@ export default component App() { SF-5a: `findUser` is not in the client bundle. -``` +```rx -- reject: CLIENT_IN_SERVER import { viewport } from "./api" server fn size() { return viewport() } @@ -162,7 +162,7 @@ export default component App() { SF-5c: the browser's JS does not exist where the body runs. -``` +```rx -- reject: IMPORT_ROW_MISMATCH import client pure { findUser } from "./api" @@ -174,7 +174,7 @@ export default component App() { The declaration file says where `findUser` runs; the import cannot restate it. -``` +```rx -- reject: IO_IN_REACTIVE import { insertNote } from "./api" server fn add(id) { await insertNote(id, "x"); return 1 } @@ -189,7 +189,7 @@ SF-1: `add` is io because its body is, and an equation's `await` is a question, which may be asked again: io is called from imperative scope. The message names the call in the body that made it io. -``` +```rx -- reject: UNHANDLED_FAILURE server fn one() { return 1 } export default component App() { @@ -201,7 +201,7 @@ export default component App() { SF-6b: a call can fail in transit even when the body cannot fail. -``` +```rx -- reject: WIRE_VALUE server fn f() { return { g: (x) => x } } export default component App() { diff --git a/scenarios/S-sf-2.md b/scenarios/S-sf-2.md index eab70843..576fcac5 100644 --- a/scenarios/S-sf-2.md +++ b/scenarios/S-sf-2.md @@ -4,7 +4,7 @@ Rules exercised: SF-1d, SF-2b, SF-3, SF-7a; IO-2. ## Modules -``` +```rx -- module: ./api.d.rx export server pure fn findUser(id: number): Promise<{ id: number; name: string; secret: string }> export server pure fn now(): Date @@ -12,7 +12,7 @@ export server pure fn now(): Date ## Program -``` +```rx import pure { GET } from "@solidjs/web/server-functions" import { findUser } from "./api" export default component App() { @@ -48,7 +48,7 @@ author owns it, as an import's `pure` (IO-3). ## Rejected variants -``` +```rx -- reject: IO_IN_REACTIVE import { GET } from "@solidjs/web/server-functions" export default component App() { @@ -61,7 +61,7 @@ export default component App() { The wrapper is called when the equation is evaluated, in reactive scope: it is imported `pure` (IO-2). -``` +```rx -- reject: SERVER_CAPTURE import pure { GET } from "@solidjs/web/server-functions" export default component App() { @@ -75,7 +75,7 @@ export default component App() { Wrapped or not, the body names nothing reactive (SF-3). -``` +```rx -- reject: IO_IN_REACTIVE import pure { GET } from "@solidjs/web/server-functions" import { insert } from "./api2" @@ -90,7 +90,7 @@ export default component App() { The rows are the function's (SF-1d): this body is io, so its call in an equation is refused — `GET` does not change what the body does. -``` +```rx -- types: WIRE_VALUE import pure { GET } from "@solidjs/web/server-functions" import { now } from "./api" diff --git a/scenarios/S-solid-1.md b/scenarios/S-solid-1.md index a7bb9a88..b8c0d0c3 100644 --- a/scenarios/S-solid-1.md +++ b/scenarios/S-solid-1.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source id := 1 product = await fetch("p:" + id) diff --git a/scenarios/S-solid-10.md b/scenarios/S-solid-10.md index 2471c476..5841ad60 100644 --- a/scenarios/S-solid-10.md +++ b/scenarios/S-solid-10.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source count := 0 source show := true diff --git a/scenarios/S-solid-11.md b/scenarios/S-solid-11.md index 33b09593..c40c87a1 100644 --- a/scenarios/S-solid-11.md +++ b/scenarios/S-solid-11.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source x := 0 source y := 0 @@ -32,7 +32,7 @@ Two flights, one shared on-screen derivation: one unit. ## Variant: without `Sum` the two are independent -``` +```rx export default component App() { source x := 0 source y := 0 diff --git a/scenarios/S-solid-12.md b/scenarios/S-solid-12.md index 0d15d4aa..72461fc5 100644 --- a/scenarios/S-solid-12.md +++ b/scenarios/S-solid-12.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source fixed := false source count := 0 diff --git a/scenarios/S-solid-13.md b/scenarios/S-solid-13.md index d0f2c4bd..4c24cd88 100644 --- a/scenarios/S-solid-13.md +++ b/scenarios/S-solid-13.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source count := 0 source show := true diff --git a/scenarios/S-solid-14.md b/scenarios/S-solid-14.md index 21bdc131..20bd0efd 100644 --- a/scenarios/S-solid-14.md +++ b/scenarios/S-solid-14.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source count := 0 source open := false @@ -34,7 +34,7 @@ Instant 4: the content arrives with the hold's commit. ## Variant: a plain read beside the boundary holds the mount (2b) -``` +```rx export default component App() { source count := 0 source open := false diff --git a/scenarios/S-solid-15.md b/scenarios/S-solid-15.md index d3154989..eb22a2e0 100644 --- a/scenarios/S-solid-15.md +++ b/scenarios/S-solid-15.md @@ -4,7 +4,7 @@ Rules: AC-1, H-5, H-8, RG-1. ## Program -``` +```rx export default component App() { source x := false slow = await fetch("slow:" + str(x)) diff --git a/scenarios/S-solid-16.md b/scenarios/S-solid-16.md index c4917972..5ab22b64 100644 --- a/scenarios/S-solid-16.md +++ b/scenarios/S-solid-16.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source page := 0 source count := 0 @@ -34,7 +34,7 @@ The boundary alone waits. ## Rejected variants -``` +```rx -- reject: CN-3e export default component App() { source page := 0 diff --git a/scenarios/S-solid-17.md b/scenarios/S-solid-17.md index c31a3aa5..18293d02 100644 --- a/scenarios/S-solid-17.md +++ b/scenarios/S-solid-17.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source b := 0 source k := 0 diff --git a/scenarios/S-solid-18.md b/scenarios/S-solid-18.md index 98ba23bb..9987207d 100644 --- a/scenarios/S-solid-18.md +++ b/scenarios/S-solid-18.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source id := 1 product = await fetch("p:" + id) @@ -30,7 +30,7 @@ entered but not shown. Instant 4: it lands with `B`, not beside `A`. ## Variant: comments land first — no spinner ever -``` +```rx export default component App() { source id := 1 product = await fetch("p:" + id) @@ -50,7 +50,7 @@ export default component App() { ## Variant: nothing outside holds -``` +```rx export default component App() { source id := 1 comments = await fetch("c:" + id) diff --git a/scenarios/S-solid-19.md b/scenarios/S-solid-19.md index a6361e30..1f9b37e9 100644 --- a/scenarios/S-solid-19.md +++ b/scenarios/S-solid-19.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source id := 1 data = await fetch("d:" + id) @@ -28,7 +28,7 @@ that re-arms on the same change. ## Rejected variants -``` +```rx -- reject: CN-3e export default component App() { source id := 1 @@ -45,7 +45,7 @@ is exactly what the first boundary's fallback waits on, so the spinner is never `spinner spinner`, `A A`, then `A A` after `id := 2` until `data` resolves "B", then `B B`; Solid's dev build warns `LOADING_ON_OUTSIDE_HOLD`. The checker refuses it (CN-3e). -``` +```rx -- reject: CN-3e export default component App() { source id := 1 diff --git a/scenarios/S-solid-2.md b/scenarios/S-solid-2.md index ccb1b12d..89bdbe5c 100644 --- a/scenarios/S-solid-2.md +++ b/scenarios/S-solid-2.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source count := 0 source show := false diff --git a/scenarios/S-solid-20.md b/scenarios/S-solid-20.md index fc3b1d86..16a34424 100644 --- a/scenarios/S-solid-20.md +++ b/scenarios/S-solid-20.md @@ -4,7 +4,7 @@ Rules: AC-1, H-5, H-6. ## Program -``` +```rx export default component App() { source id := 1 comments = await fetch("c:" + id) diff --git a/scenarios/S-solid-21.md b/scenarios/S-solid-21.md index 35eb3f39..60827745 100644 --- a/scenarios/S-solid-21.md +++ b/scenarios/S-solid-21.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source id := 1 product = await fetch("p:" + id) diff --git a/scenarios/S-solid-22.md b/scenarios/S-solid-22.md index 6af8663e..29f2ed00 100644 --- a/scenarios/S-solid-22.md +++ b/scenarios/S-solid-22.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source id := 1 meta = await fetch("m:" + id) @@ -33,7 +33,7 @@ content stays until the fallback can show; the parent never drops to ## Variant: content lands first — the fallback is never seen -``` +```rx export default component App() { source id := 1 meta = await fetch("m:" + id) diff --git a/scenarios/S-solid-23.md b/scenarios/S-solid-23.md index 40210c9f..fe50fa82 100644 --- a/scenarios/S-solid-23.md +++ b/scenarios/S-solid-23.md @@ -4,7 +4,7 @@ Rules exercised: RG-8 (PT-1, PT-2), H-5. Solid scenario mirrored: S-23 (D-19). ## Program -``` +```rx export default component App() { x = await fetch("data") diff --git a/scenarios/S-solid-24.md b/scenarios/S-solid-24.md index fce325a6..10625979 100644 --- a/scenarios/S-solid-24.md +++ b/scenarios/S-solid-24.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source id := 0 details = await fetch("d:" + latest id) @@ -26,7 +26,7 @@ header reveals now. ## Variant: once the boundary has shown content, the lane holds on `details` -``` +```rx export default component App() { source id := 0 details = await fetch("d:" + latest id) diff --git a/scenarios/S-solid-25.md b/scenarios/S-solid-25.md index 71bfa2e5..41394032 100644 --- a/scenarios/S-solid-25.md +++ b/scenarios/S-solid-25.md @@ -6,7 +6,7 @@ S-core-1's multi-write instant; this scenario covers the held case. ## Program -``` +```rx export default component App() { source count := 20 doubled = count * 2 diff --git a/scenarios/S-solid-26.md b/scenarios/S-solid-26.md index 40ef162b..22309cb6 100644 --- a/scenarios/S-solid-26.md +++ b/scenarios/S-solid-26.md @@ -4,7 +4,7 @@ Rules: R-9, H-9, AC-4, AC-5, AC-3. ## Program -``` +```rx export default component App() { source id := 1 user = await fetch("u:" + id) @@ -38,7 +38,7 @@ the re-ask lands into the action's hold (D-31) and reveals at its commit. ## Variant: a guess over `user` is verdict-inert (row 7) -``` +```rx export default component App() { source id := 1 user = await fetch("u:" + id) diff --git a/scenarios/S-solid-27.md b/scenarios/S-solid-27.md index b0250e7a..430eb48a 100644 --- a/scenarios/S-solid-27.md +++ b/scenarios/S-solid-27.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source n := 0 x = await fetch("x:" + n) @@ -35,7 +35,7 @@ atomic pair shows `[true, x0]` (a landed answer awaiting reveal); the ## Variant: an equation probes `n` and reads it plainly -``` +```rx export default component App() { source n := 0 x = 1 + n + (pending? n ? 1 : 0) @@ -60,7 +60,7 @@ wrong. ## Variant: an equation probes `n` and reads another held value plainly -``` +```rx export default component App() { source n := 0 source k := 0 diff --git a/scenarios/S-solid-28.md b/scenarios/S-solid-28.md index d8257d80..d859c5e8 100644 --- a/scenarios/S-solid-28.md +++ b/scenarios/S-solid-28.md @@ -4,7 +4,7 @@ Rules: R-9, R-12, R-8; Solid D-23 (A16, A7). ## Program -``` +```rx export default component App() { source id := 1 user = await fetch("u:" + str(id)) diff --git a/scenarios/S-solid-29.md b/scenarios/S-solid-29.md index c7b24f93..4b203c21 100644 --- a/scenarios/S-solid-29.md +++ b/scenarios/S-solid-29.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source n := 0 fast = await fetch("f:" + n) diff --git a/scenarios/S-solid-3.md b/scenarios/S-solid-3.md index e921fd31..ed0395ec 100644 --- a/scenarios/S-solid-3.md +++ b/scenarios/S-solid-3.md @@ -5,7 +5,7 @@ unrelated mainline write of Solid's row 3. ## Program -``` +```rx export default component App() { source x := 0 source show := false diff --git a/scenarios/S-solid-30.md b/scenarios/S-solid-30.md index a0eb49cc..0e7ef65b 100644 --- a/scenarios/S-solid-30.md +++ b/scenarios/S-solid-30.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source v := 0 source late := false diff --git a/scenarios/S-solid-31.md b/scenarios/S-solid-31.md index 0c5da1ad..a3d7ed21 100644 --- a/scenarios/S-solid-31.md +++ b/scenarios/S-solid-31.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source x := 0 source gate := 0 diff --git a/scenarios/S-solid-32.md b/scenarios/S-solid-32.md index 14be9b55..5652150e 100644 --- a/scenarios/S-solid-32.md +++ b/scenarios/S-solid-32.md @@ -4,7 +4,7 @@ Rules: AC-1, AC-3, ST-5, H-11. ## Program -``` +```rx export default component App() { source name := "Ann" source shown = name @@ -53,7 +53,7 @@ The `effect` form, which is never an action, is still rejected (S-check-1). ## Rejected variants -``` +```rx -- reject: OPTIMISTIC_NO_QUESTION -- handler: fix() export default component App() { diff --git a/scenarios/S-solid-33.md b/scenarios/S-solid-33.md index d7fd20ed..0d5ddab6 100644 --- a/scenarios/S-solid-33.md +++ b/scenarios/S-solid-33.md @@ -4,7 +4,7 @@ Rules: AC-3, H-7, H-11. ## Program -``` +```rx export default component App() { source value := 0 source double = await fetch("d:" + str(value)) diff --git a/scenarios/S-solid-34.md b/scenarios/S-solid-34.md index 90f94f92..02d25d98 100644 --- a/scenarios/S-solid-34.md +++ b/scenarios/S-solid-34.md @@ -4,7 +4,7 @@ Rules: AC-3, R-4, H-11. ## Program -``` +```rx export default component App() { source id := 0 source cat = await fetch("cat:" + str(id)) diff --git a/scenarios/S-solid-35.md b/scenarios/S-solid-35.md index b8f3cb3f..9cadb111 100644 --- a/scenarios/S-solid-35.md +++ b/scenarios/S-solid-35.md @@ -4,7 +4,7 @@ Rules: AC-1, AC-3, H-11. ## Program -``` +```rx export default component App() { source truth := 1 source guess = truth @@ -30,7 +30,7 @@ commit) are one instant here. ## Variant: a derived flight keeps the hold open -``` +```rx export default component App() { source truth := 1 source guess = truth @@ -62,7 +62,7 @@ instant 3, and untracked `pending? guess` is `true` until the commit. ## Variant: the guess's own question re-asked holds the change -``` +```rx export default component App() { source list = await fetch("list") action add() { try { optimistic list := list + "+mine"; await fetch("save"); refresh list } catch {} } diff --git a/scenarios/S-solid-36.md b/scenarios/S-solid-36.md index 1f8728d1..6167e103 100644 --- a/scenarios/S-solid-36.md +++ b/scenarios/S-solid-36.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source id := 1 feed = await fetch("feed:" + id) -> "placeholder" diff --git a/scenarios/S-solid-37.md b/scenarios/S-solid-37.md index b5476d92..1d01aa45 100644 --- a/scenarios/S-solid-37.md +++ b/scenarios/S-solid-37.md @@ -4,7 +4,7 @@ Rules: ST-2c, ST-5, AC-4, R-7. ## Program -``` +```rx export default component App() { source id := 1 source state = await fetch("s:" + str(id)) diff --git a/scenarios/S-solid-38.md b/scenarios/S-solid-38.md index 0defe79e..95b4bbac 100644 --- a/scenarios/S-solid-38.md +++ b/scenarios/S-solid-38.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source count := 0 data = await fetch("d:" + count) diff --git a/scenarios/S-solid-39.md b/scenarios/S-solid-39.md index c25a354e..4b772b2f 100644 --- a/scenarios/S-solid-39.md +++ b/scenarios/S-solid-39.md @@ -4,7 +4,7 @@ Rules: R-11, H-5, F-4; Solid D-25 (ruled 2026-10-09). ## Program -``` +```rx export default component App() { source s := 0 source mounted := false @@ -37,7 +37,7 @@ Instant 3: `n0(1)` lands; control and `[1, 1]` reveal together. ## Variant: the other order -``` +```rx export default component App() { source s := 0 source mounted := false @@ -57,7 +57,7 @@ export default component App() { ## Variant: inside a fresh `loading` the throw is caught (row 1′) -``` +```rx export default component App() { source s := 0 source mounted := false diff --git a/scenarios/S-solid-4.md b/scenarios/S-solid-4.md index f74db4d6..8a1551e4 100644 --- a/scenarios/S-solid-4.md +++ b/scenarios/S-solid-4.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source a := 0 source b := 0 @@ -35,7 +35,7 @@ stale-but-committed `detailsA`, which is not derived from `b` (H-1 intact). ## Variant: through a shared derivation the write waits -``` +```rx export default component App() { source a := 0 source b := 0 diff --git a/scenarios/S-solid-40.md b/scenarios/S-solid-40.md index 667f8809..a29cd822 100644 --- a/scenarios/S-solid-40.md +++ b/scenarios/S-solid-40.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source s := 0 n0 = await fetch("n:" + s) diff --git a/scenarios/S-solid-41.md b/scenarios/S-solid-41.md index a38373b6..474c1221 100644 --- a/scenarios/S-solid-41.md +++ b/scenarios/S-solid-41.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source period := 1 deferred fast = await fetch("f:" + period) @@ -30,7 +30,7 @@ now; nothing holds on the panels. Each landing is its own change. ## Variant: plain async equations — one hold, gated on the slowest -``` +```rx export default component App() { source period := 1 fast = await fetch("f:" + period) @@ -50,7 +50,7 @@ export default component App() { ## Variant: `period` is held by another reader — a re-ask lands into that hold -``` +```rx export default component App() { source period := 1 gate = await fetch("g:" + period) diff --git a/scenarios/S-solid-42.md b/scenarios/S-solid-42.md index 1b11a23d..8db7f7cb 100644 --- a/scenarios/S-solid-42.md +++ b/scenarios/S-solid-42.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source count := 1 data = await fetch("d:" + count) diff --git a/scenarios/S-solid-44.md b/scenarios/S-solid-44.md index 2083e658..9f4e1e1b 100644 --- a/scenarios/S-solid-44.md +++ b/scenarios/S-solid-44.md @@ -4,7 +4,7 @@ Rules: H-9, H-11, AC-3, AC-4, ST-5. ## Program -``` +```rx export default component App() { source sel := 3 source comments = await fetch("c:" + sel) diff --git a/scenarios/S-solid-46.md b/scenarios/S-solid-46.md index f5fafc19..ab86a23a 100644 --- a/scenarios/S-solid-46.md +++ b/scenarios/S-solid-46.md @@ -4,7 +4,7 @@ Rules: H-7, H-8, RG-1. ## Program -``` +```rx export default component App() { source id := 0 detail = await fetch("d:" + id) @@ -34,7 +34,7 @@ empty). ## Variant: the content reads `latest id` -``` +```rx export default component App() { source id := 0 detail = await fetch("d:" + id) @@ -56,7 +56,7 @@ The read that asks sees ahead, at its own site. ## Variant: the content is inside a `loading` -``` +```rx export default component App() { source id := 0 detail = await fetch("d:" + id) diff --git a/scenarios/S-solid-48.md b/scenarios/S-solid-48.md index 36fe683f..d6b84e04 100644 --- a/scenarios/S-solid-48.md +++ b/scenarios/S-solid-48.md @@ -4,7 +4,7 @@ Rules: H-6, H-7, R-11. ## Program -``` +```rx export default component App() { source id := 1 product = await fetch("p:" + id) diff --git a/scenarios/S-solid-49.md b/scenarios/S-solid-49.md index ac4c59de..5bf4ac65 100644 --- a/scenarios/S-solid-49.md +++ b/scenarios/S-solid-49.md @@ -4,7 +4,7 @@ Rules: H-6, H-7, R-11. ## Program -``` +```rx export default component App() { source id := 1 source filter := 0 diff --git a/scenarios/S-solid-5.md b/scenarios/S-solid-5.md index 6bb1f464..2a332489 100644 --- a/scenarios/S-solid-5.md +++ b/scenarios/S-solid-5.md @@ -6,7 +6,7 @@ same — which hold a mount joins is decided by the instant it is made in. ## Program -``` +```rx export default component App() { source a := 0 source b := 0 @@ -59,7 +59,7 @@ change alone. ## Variant: both branches under one `errored` boundary -``` +```rx export default component App() { source a := 0 source b := 0 diff --git a/scenarios/S-solid-50.md b/scenarios/S-solid-50.md index 7bc792b3..0e3cf622 100644 --- a/scenarios/S-solid-50.md +++ b/scenarios/S-solid-50.md @@ -4,7 +4,7 @@ Rules: H-3a, H-7, R-11. ## Program -``` +```rx export default component App() { source x := 0 source k := 0 diff --git a/scenarios/S-solid-6.md b/scenarios/S-solid-6.md index 91eb486f..b80f71ea 100644 --- a/scenarios/S-solid-6.md +++ b/scenarios/S-solid-6.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { source count := 1 source child := false @@ -34,7 +34,7 @@ hold is live — the answer does not show beside the parent on the old value. ## Variant: `fast` slower than `slow` -``` +```rx export default component App() { source count := 1 source child := false diff --git a/scenarios/S-solid-7.md b/scenarios/S-solid-7.md index 0b2dee31..de72690d 100644 --- a/scenarios/S-solid-7.md +++ b/scenarios/S-solid-7.md @@ -2,7 +2,7 @@ ## Program -``` +```rx export default component App() { user = await fetch("user") @@ -21,7 +21,7 @@ export default component App() { ## Variant: with a boundary -``` +```rx export default component App() { user = await fetch("user") @@ -38,7 +38,7 @@ export default component App() { ## Rejected variants -``` +```rx -- warn: ASYNC_OUTSIDE_LOADING_BOUNDARY export default component App() { user = await fetch("user") diff --git a/scenarios/S-solid-8.md b/scenarios/S-solid-8.md index a8d22914..fbc3a834 100644 --- a/scenarios/S-solid-8.md +++ b/scenarios/S-solid-8.md @@ -4,7 +4,7 @@ Rules: AC-1, H-2, H-7, H-9, H-10. ## Program -``` +```rx export default component App() { source x := 0 action save() { try { x := 1; await fetch("save") } catch {} } diff --git a/scenarios/S-solid-9.md b/scenarios/S-solid-9.md index 0c569a70..f0ab2539 100644 --- a/scenarios/S-solid-9.md +++ b/scenarios/S-solid-9.md @@ -9,7 +9,7 @@ its return belongs to its change. ## Program -``` +```rx export default component App() { source a := 0 source b := 0 diff --git a/scenarios/S-store-1.md b/scenarios/S-store-1.md index c2f39a6b..41358a10 100644 --- a/scenarios/S-store-1.md +++ b/scenarios/S-store-1.md @@ -4,7 +4,7 @@ Rules: ST-1, ST-2, ST-2a, ST-2c, W-3. ## Program -``` +```rx export default component App() { source user := { name: "Ann", prefs: { theme: "light", size: 12 } } effect (user.prefs.theme) { log("theme", $0) } diff --git a/scenarios/S-store-2.md b/scenarios/S-store-2.md index 50edc473..64a89831 100644 --- a/scenarios/S-store-2.md +++ b/scenarios/S-store-2.md @@ -4,7 +4,7 @@ Rules: ST-3, C-2, E-6, EF-3. ## Program -``` +```rx export default component App() { source id := 1 selected = draft(pre selected -> {}) { d[str(pre id -> 0)] := false; d[str(id)] := true } @@ -30,7 +30,7 @@ equation's value is the draft. Instant 3 touches `"2"` and `"3"` only: ## Rejected variants -``` +```rx -- reject: ST-3a export default component App() { source id := 1 diff --git a/scenarios/S-store-3.md b/scenarios/S-store-3.md index f8a3d4e1..1c3e29a8 100644 --- a/scenarios/S-store-3.md +++ b/scenarios/S-store-3.md @@ -4,7 +4,7 @@ Rules: ST-4, RG-2. ## Program -``` +```rx export default component App() { source rows := [{ id: 1, name: "a" }, { id: 2, name: "b" }] view key id = map(rows, fn(r) => { id: r.id, name: r.name + "!" }) @@ -31,7 +31,7 @@ nothing is recreated. Instant 3: row 1 is removed, row 3 created. ## Rejected variants -``` +```rx -- reject: UNSTABLE_LIST_IDENTITY export default component App() { source rows := [{ id: 1, name: "a" }, { id: 2, name: "b" }] diff --git a/scenarios/S-store-4.md b/scenarios/S-store-4.md index fb0e82b8..d84585e0 100644 --- a/scenarios/S-store-4.md +++ b/scenarios/S-store-4.md @@ -4,7 +4,7 @@ Rules: ST-5, AC-4, E-6. ## Program -``` +```rx export default component App() { source base := 1 source x = base * 10 @@ -29,7 +29,7 @@ the question with unchanged inputs: the override is dropped, quietly. ## Variant: an async question, re-asked quietly -``` +```rx export default component App() { source id := 1 source profile = await fetch("p:" + str(id)) @@ -55,7 +55,7 @@ pends. Instant 5: a new question pends. ## Rejected variants -``` +```rx -- reject: INVALID_REFRESH_TARGET -- handler: refresh base export default component App() { diff --git a/scenarios/S-store-5.md b/scenarios/S-store-5.md index 2bdaa57e..bad6ad3a 100644 --- a/scenarios/S-store-5.md +++ b/scenarios/S-store-5.md @@ -8,7 +8,7 @@ with `await*` (07); a plain `await` takes the flight's first answer only. ## Program -``` +```rx export default component App() { source room := "a" msgs = await* fetch("room:" + room) diff --git a/scenarios/S-store-6.md b/scenarios/S-store-6.md index 2e29c945..90889d98 100644 --- a/scenarios/S-store-6.md +++ b/scenarios/S-store-6.md @@ -5,7 +5,7 @@ D-34 (`createOptimisticStore`). ## Program -``` +```rx export default component App() { source todos key id = await fetch("todos") action toggle(i) { @@ -61,7 +61,7 @@ corrected by the truth it was made over (D-34). ## Variant: a path guess on a record -``` +```rx export default component App() { source id := 1 source state = await fetch("s:" + str(id)) @@ -86,7 +86,7 @@ body's end the guess reverts to the truth. ## Rejected variants -``` +```rx -- reject: OPTIMISTIC_NO_QUESTION export default component App() { source todos: { done: boolean }[] := [{ done: false }] diff --git a/scenarios/S-store-7.md b/scenarios/S-store-7.md index 85039f2e..2cc997c1 100644 --- a/scenarios/S-store-7.md +++ b/scenarios/S-store-7.md @@ -4,7 +4,7 @@ Rules exercised: R-12, H-6, ST-4, AC-3, CN-3e (its `latest` exemption). ## Program -``` +```rx export default component App() { source filter := "open" source rows key id = await fetch("l:" + filter) diff --git a/scenarios/S-store-8.md b/scenarios/S-store-8.md index 29fa1123..7c9fc7e1 100644 --- a/scenarios/S-store-8.md +++ b/scenarios/S-store-8.md @@ -4,7 +4,7 @@ Rules exercised: R-12, AC-3 (path targets), ST-4, H-11. ## Program -``` +```rx export default component App() { source todos key id = await fetch("todos") shown = latest todos @@ -44,7 +44,7 @@ reading through the store, inside `latest`, and agrees with `todos` itself. ## Variant: two guesses on one key -``` +```rx export default component App() { source todos key id = await fetch("todos") shown = latest todos diff --git a/scenarios/S-surface-1.md b/scenarios/S-surface-1.md index f3bce7d1..840a278d 100644 --- a/scenarios/S-surface-1.md +++ b/scenarios/S-surface-1.md @@ -8,7 +8,7 @@ handler is an imperative closure; `===` is `==`. ## Program -``` +```rx // a module: imports, declarations, then the mounted view import pure { len, str } from "./prelude" import { log } from "./prelude" // io: callable only in imperative scope @@ -48,7 +48,7 @@ changes, the text does not. Instant 3: a functional write appends. ## Rejected variants -``` +```rx -- reject: IO-2 import { log } from "./prelude" export default component App() { @@ -61,7 +61,7 @@ export default component App() { An `io` import called in reactive scope (R-io-3). -``` +```rx -- reject: W-2 export default component App() { source n := 1 @@ -70,7 +70,7 @@ export default component App() { } ``` -``` +```rx -- reject: SNAPSHOT_INITIALIZER export default component App() { source form := { email: "a@x" } diff --git a/scenarios/S-surface-2.md b/scenarios/S-surface-2.md index 4344b17a..fa3197d8 100644 --- a/scenarios/S-surface-2.md +++ b/scenarios/S-surface-2.md @@ -4,7 +4,7 @@ Rules exercised: 07 §6b CSS-1–CSS-4. ## Program -``` +```rx component Card(props) { source open := false

x

@@ -66,7 +66,7 @@ export default component App() { A stylesheet scopes a whole view, so it is written at the view's top level. -``` +```rx -- reject: STYLE_PLACEMENT export default component App() { source ok := true @@ -78,7 +78,7 @@ export default component App() { A branch is part of its view: TSRX counts this as the view's stylesheet; here where it is written is what it scopes. -``` +```rx -- reject: STYLE_PLACEMENT export default component App() { diff --git a/scenarios/S-surface-3.md b/scenarios/S-surface-3.md index c9742aa2..b4027531 100644 --- a/scenarios/S-surface-3.md +++ b/scenarios/S-surface-3.md @@ -4,7 +4,7 @@ Rules exercised: 07 §6b CSS-5 (TSRX's style expressions). ## Program -``` +```rx component Badge(props) { {props.children} } @@ -50,7 +50,7 @@ module's top level. ## Rejected variants -``` +```rx -- types: TS2339 tones = export default component App() { @@ -60,7 +60,7 @@ export default component App() { The map's type is its classes: a misspelt class is a type error. -``` +```rx -- reject: CSS-5 export default component App() { diff --git a/scenarios/S-types-1.md b/scenarios/S-types-1.md index 948ef611..2636ccf6 100644 --- a/scenarios/S-types-1.md +++ b/scenarios/S-types-1.md @@ -4,7 +4,7 @@ Rules exercised: TY-1–TY-5 (08 §TY), 07 §2, 04 R-1a. ## Modules -``` +```rx -- module: ./api.d.rx export type User = { id: number; name: string; email: string | null } export error NotFound @@ -13,7 +13,7 @@ export pure fn fetchUser(id: number): Promise rejects(NotFound) ## Program -``` +```rx import { fetchUser, User, NotFound } from "./api" error TooShort(min: number) => `at least ${min}` context accent: string = "blue" @@ -70,7 +70,7 @@ badge shows its length. (`-- types: CODE`: refused by the type layer — TypeScript over the projection.) -``` +```rx -- types: TS2345 export default component App() { source count := 0 @@ -81,7 +81,7 @@ export default component App() { A write is checked against the source (TY-2): `0` makes it a number. -``` +```rx -- types: TS2322 component Badge(props: { label: string }) { {props.label} } @@ -92,7 +92,7 @@ export default component App() { A component's props are checked where it is applied (TY-3). -``` +```rx -- types: TS2322 component Badge(props: { label: string }) { {props.label} } @@ -105,7 +105,7 @@ A missing prop, likewise. (What a reader may insert is Solid's `JSX.Element`, which takes any object — a renderer's value — so a record shown by mistake is still Solid's `UNRECOGNIZED_INSERT_VALUE`, at run time.) -``` +```rx -- types: TS18047 import { fetchUser, NotFound } from "./api" export default component App() { @@ -118,7 +118,7 @@ export default component App() { `user` may be `null`: read it under `if user { … }`, which narrows it (RG-1c). -``` +```rx -- types: TS2339 error TooShort(min: number) => `at least ${min}` export default component App() { @@ -133,7 +133,7 @@ export default component App() { A typed catch binds its classes (R-f-4); `TooShort` has no `max`. -``` +```rx -- types: TS2345 context accent: string = "blue" component Panel(props) { @@ -148,7 +148,7 @@ export default component App() { A provision is checked against its context's type (RG-7). -``` +```rx -- types: TS2345 export default component App() { fn shout(s: string): string => s.toUpperCase() @@ -157,7 +157,7 @@ export default component App() { } ``` -``` +```rx -- types: WIRE_VALUE type Row = { id: number; at: Date } server fn rows(): Row[] { return [] } @@ -171,7 +171,7 @@ export default component App() { SF-6a, statically: a `Date` is an instance of a class, so the result is not data. (Untyped, the check is the run time's, S-sf-1.) -``` +```rx -- types: MISSING_AWAIT import { fetchUser } from "./api" export default component App() { @@ -187,7 +187,7 @@ its function returns, so `user` would be pending at run time while the source says it is a value. The value is never a promise: write `await fetchUser(id)`. -``` +```rx -- types: MISSING_AWAIT import { fetchUser } from "./api" export default component App() { diff --git a/scenarios/TEMPLATE.md b/scenarios/TEMPLATE.md index da85fe5e..18260539 100644 --- a/scenarios/TEMPLATE.md +++ b/scenarios/TEMPLATE.md @@ -4,7 +4,7 @@ Rules exercised: . Solid scenario mirrored (holds only): S-. ## Program -``` +```rx export default component App() { } diff --git a/spec/02-core.md b/spec/02-core.md index ed2db5eb..15454df1 100644 --- a/spec/02-core.md +++ b/spec/02-core.md @@ -399,7 +399,7 @@ An instant proceeds in three phases and no phase overlaps another: `scenarios/S-core-1.md` — the counter. -``` +```rx export default component App() { source count := 0 source show := true diff --git a/spec/03-regions.md b/spec/03-regions.md index 3d54ddd6..d0e35868 100644 --- a/spec/03-regions.md +++ b/spec/03-regions.md @@ -165,7 +165,7 @@ A call to a function with a `ref` parameter or a node-declaring body (E-9). Three things, in three places (ruled 2026-10-23: a context is declared): -``` +```rx context theme: Theme = defaultTheme // declared: once, at module level — what the context is (Solid: createContext) provide theme = settings.theme // provided: in a component's block — its value for the tree beneath (the Provider) palette = (use theme).palette // used: in any region beneath — the nearest provision above (useContext) diff --git a/spec/06-stores.md b/spec/06-stores.md index 21829ee6..6b0b750a 100644 --- a/spec/06-stores.md +++ b/spec/06-stores.md @@ -36,7 +36,7 @@ AC-1…AC-5 (S-store-1…5, S-solid-8/9/15/20/26/32…35/37). Optimistic path wr An equation may write only its own draft, in its own body: -``` +```rx selected = draft(pre selected -> {}) { d[id] := true; d[prevId] := false } ``` diff --git a/spec/07-surface.md b/spec/07-surface.md index 1d459b34..3784d3bc 100644 --- a/spec/07-surface.md +++ b/spec/07-surface.md @@ -23,7 +23,7 @@ A file (`.rx`) is a module. Its top level is imports, exports and declarations. A declaration at the top level lives for the module's lifetime (a module-level `source` is app state, as a module-level signal is in Solid). -``` +```rx import { fetchUser } from "./api" // an io value: callable only in imperative scope (IO-2) import pure { formatName } from "./format" // a lifted value function: callable anywhere (E-9) import { Avatar } from "./Avatar.rx" // a component; its rows come from Avatar.rx's signature (09 MO-3) @@ -62,7 +62,7 @@ export component Profile(props: { id: number }) { … } ## 2. Declarations (02 §1) -``` +```rx source count: number := 0 // E-4: assigned once, written only in imperative scope source user = await fetchUser(id) // ST-5: a source with a standing question double = count * 2 // E-1: an equation; holds for all time @@ -144,7 +144,7 @@ A reactive block is declarations, then markup. JSX elements are verbatim: attributes are equations, children are readers, components are applied as `…` (RG-4). -``` +```rx

{user.name}

{if open { @@ -189,7 +189,7 @@ attributes are equations, children are readers, components are applied as Imperative scope is: an `effect`'s apply block, an `action` body, and any arrow function written in imperative scope or as an element's event handler. -``` +```rx effect (count) { @@ -249,7 +249,7 @@ action { refresh user; affects user } // inline, one run (AC-1) In a component body the same thing is `effect () { … }` (EF-4). - The optimistic-action idiom, with a spinner: - ``` + ```rx action placeOrder() { let items = cart // a snapshot of what is being ordered optimistic cart := [] // the guess shows now (AC-3) @@ -272,7 +272,7 @@ action { refresh user; affects user } // inline, one run (AC-1) ## 6. Components (RG-4) -``` +```rx component Card(props: { title: string; children: View }) { source open := false
{ open := !open }}> @@ -288,7 +288,7 @@ component Card(props: { title: string; children: View }) { ## 6b. Scoped styles (ruled 2026-10-24: per component, as TSRX) -``` +```rx component Card(props) { source open := false
` tags. -``` +```rx -- reject: CONTENT_MODEL component Panel(props) {
{props.children}
} @@ -72,7 +72,7 @@ export default component App() { A `
` closes an open `

`: the served `

` is empty and the panel is its sibling. -``` +```rx -- reject: CONTENT_MODEL component Line(props) {