Docs / Language Manual / Uncurried Mode
Edit

Uncurried Mode

Since ReScript 11, the language compiles in "uncurried" mode by default. Before that, currying in ReScript looked like this:

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

It is shorter than having to write all remaining parameters again.

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

In ReScript 11, that would yield an error.

RESCRIPT
let add = (a, b) => a + b let addFive = add(5) // <-- Error: // This uncurried function has type (. int, int) => int // It is applied with 1 arguments but it requires 2.

To fix it, you can just state the remaining parameters explicitly.

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

Or use the new explicit syntax for partial application.

ReScriptJS Output
let add = (a, b) => a + b
let addFive = add(5, ...)

The former approach helps library authors support both ReScript 11 and earlier versions.

No final unit necessary

In Uncurried Mode, the "final unit" pattern is not necessary anymore, while optional or default parameters are still supported.

RES
// old let myFun = (~name=?, ()) // new let myFun = (~name=?)

How to switch back to curried mode

While we strongly encourage all users to switch to the new uncurried mode, it is still possible to opt out. Just add a

JSON
{ "uncurried": false }

to your rescript.json, and your project will be compiled in curried mode again.

If you have uncurried mode off and still want to try it on a per-file basis, you can turn it on via

RESCRIPT
@@uncurried

at the top of a .res file.