Skip to content
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

Uncurried mode #5796

Merged
merged 16 commits into from
Nov 12, 2022
Merged

Uncurried mode #5796

merged 16 commits into from
Nov 12, 2022

Conversation

cristianoc
Copy link
Collaborator

No description provided.

@@ -140,5 +140,5 @@ let c1 = @foo x => @bar y => x + y
let c2 = (. x) => {y => x + y}
let c3 = (. x) => {@foo y => x + y}

type t1 = (. int, string) => bool
type t1 = (. int) => string => bool
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is a fix.

@@ -9,8 +9,8 @@ type nonrec t =
type nonrec t =
(((float ->
((int)[@attr2 ]) ->
(((bool -> ((string)[@attr4 ]) -> unit) Js.Fn.arity2)[@attr3 ]))
Js.Fn.arity2)[@attr ])
(((bool -> ((string)[@attr4 ]) -> unit) Js.Fn.arity1)[@attr3 ]))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is a fix.


let cFun = (. x) => 3
let uFun = x => 3
let mixFun = (.a) => (b, c) => (.d, e, f) => (.g) => h => 4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example that cannot be written in uncurried mode by simply flipping the first dots. But it can after normalising.

The corner case has the form:
```res
(x, .y) => z => 3
```

The dot in the middle of a sequence of args does not have a corresponding form in uncurried by default, because non-dots in uncurried by defaults are the normal ways to express the argument after the first.

This means there's asymmetry between the two syntaxes.
This could be handled by declaring this syntax invalid.

Currently we instead parse to the desugaring of the syntax, which in normal mode is:
```res
x => (.y) => { z => 3 }
```

And in uncurried mode is expressed as:
```res
(.x) => y => { (. z) => 3 }
```
@cristianoc cristianoc merged commit 241b978 into master Nov 12, 2022
@cristianoc cristianoc deleted the uncurried_mode branch November 12, 2022 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant