Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile PureScript function to uncurried JavaScript function

The following PureScript function:

add :: Number -> Number -> Number
add a b = a + b 

... compiles to JavaScript as follows:

var add = function (a) {
    return function (b) {
        return a + b;
    };
};

I would like to call this function on iOS using the JavaScriptCore framework and this makes it more complicated than it needs to be. Is there a way to compile to uncurried functions?

like image 798
Rudolf Adamkovič Avatar asked Dec 20 '25 03:12

Rudolf Adamkovič


1 Answers

Take a look at the functions in Data.Function.Uncurried - the mkFnN helpers will allow you to define JS multi-argument functions from the PS-curried versions.

The tradeoff is you won't be able to call these functions the normal way in PS, you'll have to use the corresponding runFnN also. Not really an issue if this module is only exposing an FFI interface though. :)

like image 189
gb. Avatar answered Dec 22 '25 18:12

gb.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!