Partial Application and _


#1

This code, amazingly, works:

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

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

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?)


#2

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


#3

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.


#4

Because of efficiency concerns?


#5

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


#6

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


#7

@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…