[ANN] Uncurried mode in ReScript v11

Hey folks,

We published another sneak-peak article on a new feature that is coming to ReScript v11:

Uncurried mode!

https://rescript-lang.org/blog/uncurried-mode

This feature is actually part of ReScript 11 since about half a year now. It is also the new default going forward. As the article mentions, you will still be able to use auto-currying in ReScript 11, but uncurried is a better fit for new developers with mainly JS/TS experience.

Please try out ReScript 11 in your codebases and help us with feedback, that would be really great!

How to use uncurried mode

  1. Install ReScript 11 in your project
    npm i rescript@next
    
  2. Don’t opt out from uncurried mode :slight_smile:

Happy Hacking!

15 Likes

Is the add(5, _) (or add(_, 5)) syntax discouraged? It enables some patterns that ... doesn’t, so maybe it’s worth mentioning as yet another tool for point-free programming?

3 Likes

No, it’s not discouraged at all. I forgot about it and so did my reviewers, apparently.
You are right, it needs some mention in the blogpost.

3 Likes

Ok, so to be clear, the _ syntax got a bit nerfed. If you want to partially apply everything but one parameter, it works the same. But if there are multiple parameters, you need to use the spread syntax now.

So while this works in both curried and uncurried mode:

let add = (a, b) => a + b
let addFive = add(5, _)

this only works in curried mode

let sum = (a, b, c) => a + b + c
let sumWith5 = sum(5, _)
let _ = sumWith5(1, 2)

and this only uncurried

let sum = (a, b, c) => a + b + c
let sumWith5 = sum(5, ...)
let _ = sumWith5(1, 2)

It was always the case that _ can only be used once.
Or rather, the implementation was never intended for multiple _ and replaces each one with the same value.

2 Likes

Would it be a nice addition in later versions?

I just want to say the syntax ya’ll have chosen represents currying so perfectly. Looking forward to 11, I know I’ve been burned a couple times with the let _ = forgotSecondArg(x)

2 Likes

Overal I like currying but I did experience unexpected behavior several times while writing bindings without disabling it.
I have mixed fillings about uncurried mode but on other hand partial application is still possible and annotation is more explicit… and final unit was sometimes weird.
I’m happy to give the new mode a try :smile:

3 Likes