-
Notifications
You must be signed in to change notification settings - Fork 8
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
fe: support for partial application #2265
Merged
Merged
Conversation
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
fridis
force-pushed
the
partial_application
branch
from
November 27, 2023 11:25
1ac6399
to
b43698e
Compare
`resolveSyntacticSugar`. The reason is that `checkTypes` should just perform checks and not change the state.
Now, `- 128` is no longer the same as `-128` (the former is an `prefix -` applied to a constant `i32` while the latter is a `NumLiteral` hat can be assigned to `i8`. Added constructor test cases to negative tests, removed failing tests from positive tests.
Remove old, unused code. Also, remove the ability to equip a lambda expression with a contract.
fridis
force-pushed
the
partial_application
branch
from
November 28, 2023 12:25
a403ecf
to
7a05060
Compare
…cit type Also added `AbstractType.findInChoice` to simplify code.
Expr.propagateExpectecdType2 is now AbstractLambda.propagateExpectedTypeToLambda, which is clearer on what it does.
added negative test for partial application
Also added negative tests.
michaellilltokiwa
approved these changes
Dec 4, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support for partial application of function calls.
This is an implementation of most of the missing syntax sugar for partial application that was suggested in the last table of Fuzion Design • Syntax Sugar for Lambdas.
In particular, when a call is assigned to field (via argument passing to a call or via an assignment using
:=
) and the target type is available, then partial application will be used if necessary. Then, the following transformations may occur:f x y
a,b,c -> f x y a b c
f x y
() -> f x y
++ x
a -> a ++ x
x ++
a -> x ++ a
-
a -> -a
ora -> a-
ora,b -> a-b
.as_string
a -> a.as_string
-1
a -> x - 1
Note that a single operator given as an argument to a call will be parsed as a postfix or infix operator, so it usually will have to be enclosed in parentheses as in
Additionally, this patch does some changes that are not directly related to partial application:
- 1
is no longer a numeric literal whose type will be inferred from what it is assigned to, butprefix -
applied to thei32
constant1
.findInChoice
inAbstractType
make record
now uses the jvm backend, whilemake record_int
records output using the integer backend.