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

Explore uncurried by default #5597

Closed
15 tasks done
cristianoc opened this issue Aug 15, 2022 · 4 comments
Closed
15 tasks done

Explore uncurried by default #5597

cristianoc opened this issue Aug 15, 2022 · 4 comments
Milestone

Comments

@cristianoc
Copy link
Collaborator

cristianoc commented Aug 15, 2022

This issue is about exploring technical changes required to explore how uncurried by default would feel like in practice.

The basic idea is to have an uncurried-by-default mode, to be turned on in some way. Presumably by config to begin with. So that existing projects are not affected and one can turn on by config and start using the new mode. It could be nice to have some support to "convert" between curried and uncurried by default (a syntax change where code is parsed in curried mode and printed in uncurried mode).

@cristianoc cristianoc added this to the v10.1 milestone Aug 15, 2022
@illusionalsagacity
Copy link
Contributor

Syntax swap. The function (x, y) => x+y would be uncurried and (. x, y) => x+y curried.

I could see this swap being confusing if a library does not have the config value flipped and the user is using editor go to definition. I often use that for rescript libraries that do not have documentation websites.

Another idea would be to have the printer re-format if the config value is on:

  • (. x, y) => x + y -> (x, y) => x + y
  • (x, y) => x + y -> (? x, y) => x + y

where ? is an arbitrary character to indicate a curried function

@mununki
Copy link
Member

mununki commented Aug 17, 2022

when V4 is used, only 1 argument is used anyway so it does not really matter whether one uses the uncurried or curried convention

There is one minor exception, forwardRef. https://github.com/rescript-lang/syntax/blob/cbc5e69b5abab3e383c022b0d0f1b1e901a34644/tests/ppx/react/expected/forwardRef.res.txt#L77

@cristianoc
Copy link
Collaborator Author

True but that is super hacky and I'm sure it can be equally hacked for uncurried.

@joakin
Copy link

joakin commented Aug 17, 2022

Another idea would be to have the printer re-format if the config value is on:

Some flags to decide how to migrate a codebase would be useful, in case you want to keep all curried definitions syntax and when they become uncurried and deal with any compiler errors manually.

  • (. x, y) => x + y -> (x, y) => x + y
  • (x, y) => x + y -> (? x, y) => x + y

where ? is an arbitrary character to indicate a curried function

I'm personally against adding even more syntax, it would be nice if it was possible to apply the currying treatment to the normal curried functions like in JS:

  • (x, y) => x + y -> x => y => x + y

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

No branches or pull requests

4 participants