Skip to content

s2: trait and given (Ast, printer, parser, names) - #16

Merged
vic merged 1 commit into
mainfrom
s2-trait-given
Nov 9, 2026
Merged

vic merged 1 commit into
mainfrom
s2-trait-given

Conversation

@vic

@vic vic commented Nov 9, 2026

Copy link
Copy Markdown
Owner

FRONT rung 3: trait and given.

  • Ast: new declarations Ast.Trait(line, name, groups, sigs) and Ast.Given(line, groups, head, fns).
  • Printer: a trait method prints as a def without extern (Ast.fnSig, shared with Ast.fn).
  • Parser: reads both forms; handler fns use the same Parse.defs.
  • Names: a trait declares a type name; signatures, given heads and given methods are type-checked in their [] binders.

Test: a trait with three [] binders, a given with a qualified head, and a given with [] and {} groups each print back exactly as written. Parse probe over all sources: 132 of 176 parse (was 108); the rest are type decls, spec def, int and value type args, and two genuine parse errors. Local tests/run.sh: 185 ok, 0 FAIL.

… check

Ast.Trait(line, name, groups, sigs) and Ast.Given(line, groups, head, fns) are new declarations
(Ast.DTrait, Ast.DGiven). The printer writes a trait method as a def without extern (Ast.fnSig, shared
with Ast.fn). The parser reads trait Name groups: with signatures and given groups Head[args]: with
defs; handler fns use the same Parse.defs. Names declares a trait as a type name and checks the types of
its signatures and of a given head and its methods in their [] binders.

tests/s2/parse: a trait with three [] binders, a given with a qualified head, a given with [] and {}
groups print back as written. Parsing every source: 132 of 176 parse (was 108); the rest are type
decls, spec def, int and value type args, and two genuine parse errors.
@vic
vic merged commit f2b751a into main Nov 9, 2026
3 checks passed
@vic
vic deleted the s2-trait-given branch November 9, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant