Uncurried Mode
Since ReScript 11, the language compiles in "uncurried" mode by default. Before that, currying in ReScript looked like this:
It is shorter than having to write all remaining parameters again.
In ReScript 11, that would yield an error.
RESCRIPTlet 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.
Or use the new explicit syntax for partial application.
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.