Currying a one parameter function inside variant argument?

Hi, I post this issue last week but it seems to be ignore, so I repost it here:

// Curry.res

type test<'a> =
  | One(('a) => bool)

  let testor = (test, a) => 
    switch test {
      | One(r) => r(a)

result in:


// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';

var Curry = require("rescript/lib/js/curry.js");

function testor(test, a) {
  return Curry._1(test._0, a);

exports.testor = testor;
/* No side effect */

In this case, no need to add a curry in the result, as it’s a one parameter function and the compiler is supose to does a best-effort job at removing those currying whenever possible, it should be removed in this case also.
Or did I miss something ?

hi @kk3 welcome!
Best effort means no guarantees. Indeed this should be removed but the compiler fails to do it, that’s the meaning of “best effort”


thank you :slight_smile:
Indeed, that’s why I though reporting it as an issue, so you can track where it fails and improve it

1 Like