Example of a record (note: the syntax is not final):
data Person: Type =
person (field name: Text) (field birth: Date): Person
jane: Person = Person.person (name = "Jane") (birth = date.ymd 1980 1 1)
jane-name: Text = Person.person.name jane-name
jack: Person = Person.person "Jane" (date.ymd 1991 1 2)
Tasks:
[x] remove the old record syntax using the keyword record (lexer, parser, lowerer)
[x] add keyword field
[ ] (optional, otherwise future work) make the keyword contextual: allowed as binder for top-level declarations, binders of let/ins, use/ins, patterns
[x] add fields to the grammar and parse them (, comes beforefield)
[x] in the lowerer, gate duplicate fields (the resolver does this out of the box in register_binding)
[x] deny unnamed fields in the lowerer (e.g. (field) -> Alpha) (impossible anyways, the parser catches that)
[ ] disallow multiple constructors when lowering if any of them has fields
[ ] in the name resolver, make constructors namespaces and add fields as functions to them
[ ] if case analysis supports deapplication by the time this gets implemented, use case analyses to implement field projections
[ ] otherwise add a temporary hack by adding a new kind of expression to the HIR like Projection (which needs extra typing rules etc.!) and elaborate to them
[ ] resolve named arguments in
[ ] expressions
[ ] patterns
[x] (optional, otherwise future work) support @shallow on constructors (not part of the language any more, see #38)
[ ] (optional, otherwise future work) have a way to make field names private: for modules with insufficient privileges, those
constructors should appear as if they weren't records: neither field projections nor named arguments are accessible
This issue describes the MVP of records and does not include named arguments outside of record declarations, re-ordering of
applications with named arguments or a record update syntax.
Example of a record (note: the syntax is not final):
Tasks:
record
(lexer, parser, lowerer)field
,
comes beforefield
)in the lowerer, gate duplicate fields(the resolver does this out of the box inregister_binding
)deny unnamed fields in the lowerer (e.g.(impossible anyways, the parser catches that)(field) -> Alpha
)Projection
(which needs extra typing rules etc.!) and elaborate to them(optional, otherwise future work) support(not part of the language any more, see #38)@shallow
on constructorsThis issue describes the MVP of records and does not include named arguments outside of record declarations, re-ordering of applications with named arguments or a record update syntax.