-
Notifications
You must be signed in to change notification settings - Fork 62
Create a new input syntax for function. #1254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
@DavidFangWJ We shouldn't actually need to modify We will need to change how patterns in let bindings are processed in the statics and elaboration to special case the situation where the top-level pattern is |
|
Regarding the type error, take a look at the definition of Regarding the function itself, you should be looking for the application of a variable, rather than a constructor. Constructors are capitalized. You also do not need to check that all arguments have type annotations -- it is okay to leave an argument unannotated, it will just get the unknown type. You also need to handle optional return type annotations (which will require changing the return type of your function overall). Please write some additional examples in your PR message to handle both functions with missing type annotations on arguments and missing return types, so make it clear these are all valid. We'll turn these into tests as well. |
…/hazel into haz3l-new-func-syntax
|
Cannot fully understand the part in |
|
@DavidFangWJ there is a small merge conflict + the following has an error on
|
|
@DavidFangWJ The ExplainThis description for function definition should say something like "Defines a function f with arguments x", not the same message as constructor binding. |
cyrus-
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DavidFangWJ functionality looks good, but take a look at my comments. please write up an explanation for how the rewriting works in general as well in the PR description.


Motivation
Add a more compact syntax to function, such that
should behave the same as below:
This new function syntax is more analogous to other programming languages with strong data types, and is therefore easier to learn.
Implementation Details
According to the current structure, there following files are modified.
Info.re, a new fieldrewrite_idis introduced, which registers the correspondence between the rewrittenExp.tand the original one.StaticsBase.re,check_annotated_functionis introduced to check whether the function is in the new specified syntax, passed asLet(Ap, ...).Statics.reandElaborator.re, additional code are introduced to process the new syntax.ExplainThis.reandAppPat.re, additional explanation categories are introduced.