Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document when FnN is inlined #6

Open
safareli opened this issue May 10, 2018 · 0 comments
Open

Document when FnN is inlined #6

safareli opened this issue May 10, 2018 · 0 comments
Labels
type: documentation Improvements or additions to documentation.

Comments

@safareli
Copy link

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.

@hdgarrood hdgarrood changed the title no indication of compiler optimisation Document when FnN is inlined Oct 10, 2020
@JordanMartinez JordanMartinez added the type: documentation Improvements or additions to documentation. label Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation Improvements or additions to documentation.
Projects
None yet
Development

No branches or pull requests

2 participants