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

mel.uncurry only works with "first level callbacks" #752

Open
jchavarri opened this issue Oct 3, 2023 · 2 comments
Open

mel.uncurry only works with "first level callbacks" #752

jchavarri opened this issue Oct 3, 2023 · 2 comments

Comments

@jchavarri
Copy link
Member

Consider the following snippet (playground):

external map : (('a -> 'b -> 'c)[@mel.uncurry]) -> 'c array = "map"

let add x =
  let partial y = x + y in
  partial

let _ = map add

It generates the following code, with the add callback uncurried and inlined as expected:

function add(x) {
  return function (y) {
    return x + y | 0;
  };
}

map(function (param, param$1) {
      return param + param$1 | 0;
    });

Now, if we have a slightly different function (playground):

external map : ((('a -> 'b -> 'c)[@mel.uncurry]) -> unit) -> 'c array = "map"

let add f =
  f 1 2;
  ()

let _ = map add

It produces the following code:

function add(f) {
  Curry._2(f, 1, 2);
}

map(add);

I wonder if this is a fundamental limitation, or something that could be fixed? Worst case, we can document this behavior. cc @davesnx

@anmonteiro anmonteiro added this to the Melange v3 milestone Oct 19, 2023
@jchavarri
Copy link
Member Author

@anmonteiro do you have any clue what could be going on? These alerts appear constantly while working on reason-react and it's both quite annoying and also scary that the uncurrying is not working properly for the callbacks.

Added a test in #875 to showcase the problem hopefully better.

@anmonteiro
Copy link
Member

explanation why this doesn't work: https://github.com/melange-re/melange/pull/952/files#r1414511000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants