Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Js.Re.captures is recognized a curried function, whereby not compile

$
0
0

The underscore here is a placeholder that tells ReScript I need an argument but I can’t give you a variable or the compiler will yell at me.
For a more professional explanation you can read about it here:
https://rescript-lang.org/docs/manual/latest/pipe#pipe-placeholders

Basically if Option.map needs a function f(x) for the 2nd argument, you effectively gave it “f” without the “(x)”, so it complained about receiving it a curried function. But because you can’t give ReScript “x” here because it doesn’t exist, so you have to 'fake it out" with the underscore. If you look at the Javascript it produces you see that it actually replaces the Js.Re.captures with an anonymous function.


Viewing all articles
Browse latest Browse all 2592

Trending Articles