|
| 1 | +{ |
| 2 | + "$schema": "../correspondence-cartridge.schema.json", |
| 3 | + "spdx": "MPL-2.0", |
| 4 | + "name": "worked-examples", |
| 5 | + "version": "0.1.0", |
| 6 | + "description": "Reference cartridge: one correspondence per CorrespondenceKind, using the canonical worked examples from docs/theory/CORRESPONDENCE-MODEL.adoc. Proves the schema covers all six grades of the Echo fibre.", |
| 7 | + "languages": ["python", "scheme", "basic", "erlang", "c", "julia", "jtv", "assembly", "rescript", "javascript"], |
| 8 | + "transitions": [ |
| 9 | + { |
| 10 | + "concept": "function-definition", |
| 11 | + "from": { "language": "python", "surface": "def f(): ..." }, |
| 12 | + "to": { "language": "scheme", "surface": "(define (f) ...)" }, |
| 13 | + "kind": "cognate", |
| 14 | + "residue": { "shape": "none" }, |
| 15 | + "strata": [ |
| 16 | + { "stratum": "surface", "holds": false }, |
| 17 | + { "stratum": "intention", "holds": true } |
| 18 | + ], |
| 19 | + "narrative": { |
| 20 | + "celebrate": "You already define functions — this is the very same idea.", |
| 21 | + "better": "`define` is just the Scheme spelling of `def`.", |
| 22 | + "safety": "Same binding intent; verify before assuming it is only a rename.", |
| 23 | + "example": "def f(): return 1 <-> (define (f) 1)" |
| 24 | + } |
| 25 | + }, |
| 26 | + { |
| 27 | + "concept": "name-binding", |
| 28 | + "from": { "language": "basic", "surface": "X = 5" }, |
| 29 | + "to": { "language": "erlang", "surface": "X = 5" }, |
| 30 | + "kind": "false-friend", |
| 31 | + "residue": { |
| 32 | + "shape": "lossy", |
| 33 | + "note": "BASIC rebinds destructively; Erlang binds once and unifies — re-`=` fails a match rather than overwriting." |
| 34 | + }, |
| 35 | + "strata": [ |
| 36 | + { "stratum": "surface", "holds": true }, |
| 37 | + { "stratum": "intention", "holds": false } |
| 38 | + ], |
| 39 | + "narrative": { |
| 40 | + "celebrate": "You have used `=` for assignment for years — that intuition is real.", |
| 41 | + "safety": "In Erlang `=` is single-assignment bind / unify, not store.", |
| 42 | + "example": "X = 5, X = 6 %% the second match FAILS" |
| 43 | + } |
| 44 | + }, |
| 45 | + { |
| 46 | + "concept": "array-indexing", |
| 47 | + "from": { "language": "c", "surface": "a[0]" }, |
| 48 | + "to": { "language": "julia", "surface": "a[1]" }, |
| 49 | + "kind": "antonym", |
| 50 | + "residue": { "shape": "inverted", "note": "0-based vs 1-based: the first element flips index." }, |
| 51 | + "strata": [ |
| 52 | + { "stratum": "surface", "holds": true }, |
| 53 | + { "stratum": "intention", "holds": true }, |
| 54 | + { "stratum": "structure", "holds": false } |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "concept": "subtraction", |
| 59 | + "from": { "language": "c", "surface": "a - b" }, |
| 60 | + "to": { "language": "jtv", "surface": "uncall add a b" }, |
| 61 | + "kind": "alien-realization", |
| 62 | + "residue": { |
| 63 | + "shape": "lossy", |
| 64 | + "note": "JTV is reversible / add-only: subtraction is `add` run backwards; divide via reversed repeated-add." |
| 65 | + }, |
| 66 | + "strata": [ |
| 67 | + { "stratum": "intention", "holds": true }, |
| 68 | + { "stratum": "structure", "holds": false } |
| 69 | + ] |
| 70 | + }, |
| 71 | + { |
| 72 | + "concept": "static-types", |
| 73 | + "from": { "language": "assembly", "surface": "(no analog)" }, |
| 74 | + "to": { "language": "rescript", "surface": "let x: int = 5" }, |
| 75 | + "kind": "novel", |
| 76 | + "residue": { |
| 77 | + "shape": "absent-source", |
| 78 | + "note": "Coming from assembly + JS there is no prior anchor for a static type system — teach de novo." |
| 79 | + }, |
| 80 | + "strata": [ |
| 81 | + { "stratum": "intention", "holds": false } |
| 82 | + ] |
| 83 | + }, |
| 84 | + { |
| 85 | + "concept": "early-return", |
| 86 | + "from": { "language": "javascript", "surface": "return x" }, |
| 87 | + "to": { "language": "rescript", "surface": "x /* last expression is the value */" }, |
| 88 | + "kind": "vanished", |
| 89 | + "residue": { |
| 90 | + "shape": "absent-target", |
| 91 | + "note": "ReScript has no `return`; a block evaluates to its last expression — re-route the habit." |
| 92 | + }, |
| 93 | + "strata": [ |
| 94 | + { "stratum": "intention", "holds": false } |
| 95 | + ] |
| 96 | + } |
| 97 | + ] |
| 98 | +} |
0 commit comments