Add support for partial application of uncurried functions #5805
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.
An instance of the normal application rule (in standard notation) for curried function is:
This PR provides an additional rule, one instance being:
One immediate consequence is that instead of having a library function such as
raise : exn => 'a
, one can provide instead an uncurried functionraise : (. exn) => 'a
.Any pre-existing client code that uses
raise(E)
still works because of the new rule.In addition, new uncurried code can call the same function with
raise(. E)
.This opens the possibility of uncurrifying libraries without affecting existing code, for the most part, and have new uncurried code written in natural style take advantage of the uncurried definitions. One case where there is no free lunch are callbacks, as in
List.map
where two versions still need to be provided if two uses are required.Now switching to uncurried by default notation. The same new rule, just written in uncurried by default notation, looks like this:
One way to read this rule is: one can opt into partial application by using the dot notation. The net effect is that no curried types are ever created if one only uses uncurried functions and partial application.