dannypsnl/violet
2
8
Fork
You've already forked violet
0

Builtin record type #26

Merged
dannypsnl merged 4 commits from builtin-record into main 2026年05月16日 06:15:03 +02:00

close #20

close #20
kernel: record types
Add three new term/value constructors (RecordType, RecordIntro,
RecordProj) to Core, with custom printers for all six variants.
NbE conversion (lib/elab/unify.ml) gains an eta law for records:
when one side is a VRecordIntro and the other is a neutral,
the neutral is eta-expanded by projecting each field. Quote-back in
PartialRenaming.rename handles all three constructors with telescope
walking for VRecordType.fields. A BadProjection kernel error is added
for ill-formed projections.
surface: AST, lexer, parser, op_resolver for records
Add Record top variant and RecordLit / RecordUpdate / Proj preterms
plus PRecord pattern. Parser (lib/elab/parser.ml) adds
p_record_top mirroring p_data_top, plus a 3-way classify_lbrace
disambiguator that distinguishes record literals, copy-with-update
({ r | f = e }), and the existing pi-binder { x : T } form; field
punning ({ x } sugar for { x = x }) is resolved at parse time.
Postfix .field projection is implemented as a left-associative proj_soup
wrapping op_soup. Record patterns { f = p, ... } parse only with
explicit entries (no punning). op_resolver.ml walks all new variants
as pure pass-through. Implicit-application f {x} continues to parse;
Nat/zero qualified names continue to use /.
elab: \record top, companions, literal, projection, update, pattern, exports
Implement \record top-level elaboration via a two-phase
 GTopRecord -> KTopRecord_HaveType
continuation mirroring \data.
Each record produces five Module.t Let entries: the record
head, R/mk, one R/<field> per field, and R/elim. Companion bodies
use definitional eta to typecheck. Field-type telescope-walk uses
the Core terms from the type-checking pass (the placeholder
ctx_for_fields approach was a bug that broke dependent field types
like 'snd : B fst').
dannypsnl deleted branch builtin-record 2026年05月16日 06:15:22 +02:00
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dannypsnl/violet!26
Reference in a new issue
dannypsnl/violet
No description provided.
Delete branch "builtin-record"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?