One more beginner question from me for now!
So I’ve only ever used pipe-last languages, and for me piping is absolutely tied to currying. It makes perfect sense that the pipe operator has the signature (data: 'a, f: 'a => 'b) => 'b
, and that when you partially apply a function, it can be used on the right side of that operator.
I can see the advantages of pipe-first and I’m interested to try it in anger, but I need to get my head around how it fits with automatic currying. I was fully expecting currying to work in reverse as well. That is, I expected eg. data->Array.map(f)
to be equivalent to Array.map(f)(data)
, but it’s not. The thing that I find hard to reconcile is that the expression f(x)
(for a binary function f
) has a different meaning depending on whether or not it’s in a pipeline.
I wonder how useful automatic currying is, given the above issue, and the fact that most functions will be written data-first? Is it used in practice? I imagine that in most cases it would be far preferable to be explicit by using placeholder arguments. In the presence of pipe-first and placeholder arguments, is automatic currying even a useful language feature?
Would it be at all possible for the language to implement currying in reverse order, such that Array.map(f)
outside of a pipeline results in a function array<'a> => array<'b>
?