Partial Application and _


This code, amazingly, works:

let doStuff = (a: int, b: int) : int => a * a + b;
let partialStuff = doStuff(_, 4);

Js.log(doStuff(3, 4));

This seems to indicate that you can use _ to specify where the missing parameter goes when “filling in” a partial application. Is this by design, or is this just an accidental misfeature that could go away in a future release of ReasonML? (I suspect this has something to do with all functions being curried, but what do I know?)


This is a recent feature that was explicitly added! like a month ago I believe.


Yes, but it’s mostly supposed to work with |. and |>. Don’t use it elsewhere; we might remove it. We don’t wanna encourage this style too much.


Because of efficiency concerns?


Thanks. Turns out that an ordinary anonymous function works better in the context that I need, anyway.


:frowning: might remove it? This could be our path forward to requiring explicit partial application!


@ncthbrt readability concern. It sucks reading a large body and then suddenly see an underscore and needing to go back and re-imagine things. Also, confusing for newcomers.

@jaredly it is yeah…