You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extends the --translate type-declaration translator (slice 1) to two more
fully-structural, compiler-verified forms:
type point = {x: int, y: int} -> struct Point { x: Int, y: Int }
type box<'a> = {value: 'a} -> struct Box[A] { value: A }
type option<'a> = None | Some('a) -> type Option[A] = | None | Some(A)
type id<'a> = 'a -> type Id[A] = A
- Records -> AffineScript `struct`. ReScript `mutable`/optional-`?` fields are
anonymous tokens (absent from the parse tree), so they're detected in the
field's source text and the whole record is skipped rather than silently
flattened.
- Generics: type params `'a` -> `[A]`, threaded through aliases, sums, and
records (param refs in bodies map `'a` -> `A`); nested generics like
`array<int>` still skip the decl.
- Still conservative: qualified paths, non-primitive refs, object types, GADT
returns, and variant spreads all skip (never guessed).
Qualified-path RHS stays deferred: `Belt.Map.t` now *parses* (the #228 grammar
landed) but `Belt::Map::T` would not *resolve* against a target module that
doesn't exist yet, which would break the "every translated form type-checks"
guarantee. It waits for a module-mapping story.
Every generated form verified compilable via `main.exe check` (Type checking
passed). Tests: phase3b.res fixture + 6 new gated walker cases; phase3.res
updated (its generic `box` now translates). Walker-internal only —
Walker.translate / Emitter.emit_translation signatures unchanged.
Refs #57https://claude.ai/code/session_017T8SzHr2yXav8hm4Ho76Uw
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ this project aims to follow [Semantic Versioning](https://semver.org/spec/v2.0.0
20
20
21
21
### Added
22
22
23
+
- feat(res-to-affine): Phase 3 slice 2 — `--translate` now also handles record types (→ `struct`) and generics (type params `'a` → `[A]`) across aliases / sums / records; `mutable`/optional-`?` records, qualified paths, and nested generics are still skipped (never guessed); every emitted form verified compilable via `main.exe check` (Refs #57)
23
24
- feat(res-to-affine): Phase 3 slice 1 — `--translate` renders fully-structural type declarations (primitive aliases + simple sum types) into compilable AffineScript; conservative (generics / qualified paths / records / non-primitive payloads are skipped, never guessed); walker-only (Refs #57)
0 commit comments