I think I got the answer, not sure if interest you guys but I’ll leave here anyways in case someone has the same problem that I was having. I also created a minimal repro environment in this repo
The issue is:
Core__List
module has a function defined reduceReverse
:
let reduceReverse = (type a b, l: list<a>, acc: b, f) => {
let len = length(l)
if len < 1000 {
reduceReverseUnsafe(l, acc, f)
} else {
A.reduceReverseU(toArray(l), acc, f)
}
}
as you can see, the else
branch does:
A.reduceReverseU(toArray(l), acc, f)
A
is defined earlier as:
module A = {
let makeUninitializedUnsafe = Belt_Array.makeUninitializedUnsafe
let reduceReverseU = Belt_Array.reduceReverseU
let reduceReverse2U = Belt_Array.reduceReverse2U
}
So in the end, we’re calling Belt_Array.reduceReverseU
Checking Belt_Array’s definition here we can see that it calls the function with the uncurry syntax explicitly: f(. r.contents, getUnsafe(a, i))
So, the whole issue is, if uncurried
is set to false
in rescript.json
the compiler assumes that the function that the Core__List.reduceReverse
is receiving as argument is curried, but Belt_Array only accepts uncurried functions, since it’s explicitly using the uncurried syntax to call it, so the compiler throws an error.
If you change uncurried
to true
in rescript.json
, the exception goes away, because now the compiler assumes that the function passed to Core__List.reduceReverse
is already uncurried and would have no issues when Belt__Array
calls it with the uncurried syntax.
In summary, @rescript/core
is not compatible with uncurried: false
as long as we use Belt underneath.
I think this could be stated in a clearer way in the documentation.
CC: @fham @jihchi @tsnobip