reasonbucklescriptrescript

How do you call an uncurried function with unit in ReScript/ReasonML?


Say that I have an uncurried function like:

let echo(. a) = a;

I can call this funcition fine with most literals like:

echo(. 1)
echo(. "Hello")

but when I am trying to call it with void, I get an error:

echo(. ()) //This function has arity1 but was expected arity0

As a workaround, I can do this:

let myArg = ()
echo(. myArg)

Is there a way to avoid this?


Solution

  • I like this version as well:

    echo(. ignore())
    

    that way I don't need the dummy value workaround

    Edit: This version is also now part of the docs: https://rescript-lang.org/docs/manual/latest/function#uncurried-function