From a discussion on discord; put here because I suspect it is a common question.
This code doesn’t work:
let x: option(int) = Some(5);
let y: option(int) = Js.Option.map(x => x + 1, x);
The error message is: This expression should not be a function, the expected type is ('a -> 'b [@bs]), which is in OCaml syntax. In ReasonML, you do this to fix it:
let y: option(int) = Js.Option.map([@bs] x => x + 1, x);
There is a more up-to-date notation that also works:
let y: option(int) = Js.Option.map((. x) => x + 1, x);
From what I understand, the [@bs] makes it an uncurried function as per this page: https://bucklescript.github.io/docs/en/function.html (Why it has to be uncurried, I got no idea, but I am sure someone can explain it in a response here.)
