Giving names to function arguments is a way of documenting our code; if there was no such need then we could give them names such as “arg1” and “arg2” and be no worse for it – but in reality this would of course make our code much harder to understand. In F# we often pass around functions as arguments to other functions, in which case their arguments are no longer named:
let foo<'T> (bar : 'T -> 'T -> float -> 'T) =
// do something
This function foo takes a “bar” as an argument, which itself takes two 'T and a float and returns a 'T, but it is hard to tell what it is supposed to do. It would become much clearer if we could name the arguments of “bar”:
let foo<'T> (bar : (startVal : 'T) -> (endVal : 'T) -> (interpolationAmt : float) -> 'T) =
// do something
Now it is obvious what “bar” is used for: It interpolates between two values of type 'T. Furthermore it also becomes clear that the order of the 'T arguments matter and in which order to apply them. But unfortunately this code doesn’t compile.
So my question is if there is a way to do this that I’ve missed, and if not how do people usually deal with this problem?