purescript-functions
purescript-functions copied to clipboard
Document when FnN is inlined
From ffi
exports.runFn3 = function (fn) {
return function (a) {
return function (b) {
return function (c) {
return fn(a, b, c);
};
};
};
};
main.purs
module Main where
import Prelude
import Data.Function.Uncurried
x :: Fn3 Int Int Int Int -> Int
x f = runFn3 f 1 2 3
output/Main/index.js
"use strict";
var Data_Function_Uncurried = require("../Data.Function.Uncurried");
var Prelude = require("../Prelude");
var x = function (f) {
return f(1, 2, 3);
};
module.exports = {
x: x
};
But just looking at this library I assume output would have been like runFn3(f)(1)(2)(3), but looks like there is some compiler optimization going on.
search for runFn in https://github.com/purescript/purescript/blob/0ebc45779ed21ee16c2fb48a3a2c42544a560512/src/Language/PureScript/CoreImp/Optimizer/Inliner.hs
Would be nice to add a bit of comment about that, note x f = let z = runFn3 f in f 1 2 3 is not optimised.