-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add term variant for ADTs This commit is a very first step toward adding structural Algebraic Data Types to Nickel. This commit adds a new node in the AST for an enum tag with an argument (a variant), and fill the blanks/compiler errors from there. A temporary syntax, choosen mostly to be obscure, ugly, easy to add and to not conflict with existing syntax has been added for further testing and experimentation: 'SomeTag..(argument). * Add typechecking capabilities for ADTs This commit extend enum row types to accept a variant, that is to handle types such as `[| 'Foo Number, 'Bar {foo : String} |]`, which are basically structural ADTs. The bulk of the work consist to extend most function operating on enum rows to now take into account the fact that enum rows can have types inside, much as record rows. That is, the code handling enum rows and record rows is much more similar than before; the main difference being that for now, enum rows have an optional type argument (the variant, which can be there or not), while a record row always have a type assignment. At this point, no elimination forms for ADTs have been introduced yet (that is, you can't match on/unwrap ADTs). This part is intentionally on the side for the time being. * Fix tests * Add syntax for ADTs enum types Add missing surface syntax to write enum rows with a variant (an argument). Fix some pretty printing shortcomings as well. * Extend mk_xxx macros for ADTs, fix rustc errors * Add error reporting for enum row mismatch Extend various typechecker internal error types with new cases for augmented (with variants) enum rows * Fix typo in code comment * Fix incorrect code documentation * Small fix to tests and compilation * Add passing tests for ADTs MVP * Adapt test infra to new type errors * Pretty printing of enum variants: match current syntax * Add test of failure cases of typechecking ADTs * Remove dead comments, minor comment rewording * Update core/src/typecheck/eq.rs * Update core/src/typecheck/mod.rs * Update core/src/typecheck/unif.rs * Update core/src/parser/grammar.lalrpop Co-authored-by: jneem <joeneeman@gmail.com> * Improve description of EnumVariant * Update obsolete description of EnumRowF * Update core/src/typecheck/unif.rs Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io> --------- Co-authored-by: jneem <joeneeman@gmail.com> Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
- Loading branch information
1 parent
2c5f2b0
commit bbc56d0
Showing
22 changed files
with
1,141 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.