-
Notifications
You must be signed in to change notification settings - Fork 833
Description
What
Oftentimes, you may add a curried argument to a function after the fact, or called a curried function and simply forgot the last argument. All callsites will break (correct) but the error is generally not what you would expect. Look at the following example: -
let foo a b = a + b
let c = foo 10
let d = c + 10The error returned is error FS0001: The type 'int' does not match the type 'int -> int'
Why
New developers to F# may be unfamiliar with the concept of pervasive type inference and / or of passing functions as values and / or of partially applied functions. The error message does not make entirely clear why this error is occurring.
How
This makes sense, but again, to a new developer, it's completely confusing. A preferred error may be something like: -
The value 'c' is a partially applied function with signature 'int -> int' and is not compatible with 10. Did you forget to provide all the partial arguments when creating 'c'?
If it is not easily possible from the AST to understand that this is a partially applied function (entirely possible), it should still be possible to make a clearer message saying you are trying to do something across a function and a simple value.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status