Can we improve somewhat on FS0001 errors of the form "The type X does not match the type Y"
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
I would like to discuss improving the errors where an expected type is not equal to a given type. My problem with such errors is, they are virtually impossible to read or understand, even after years of programming experience, unless for the most trivial of cases.
For instance, just now I hit this:

Does this mean that `Result.create` cannot understand `a -> string` as first argument, or does it mean that the type in the list is not supposed to be of type `a -> string` but should be of type `string`? Or does it mean that the part before `|>` results somehow in a `XResult` and this is not a proper type for `Result.create` which expects `Result<('a -> string), 'b>`?
It's not that it is impossible to find out, but I think the main problem is what we call in linguistics: interchangeable object/subject in a sentence, so that you cannot be certain what the message is talking about. It says _apples are not equal to pears_, but we know that, it doesn't _add_ anything.
### Suggestions
I could think of several ways of improving the error. I am not sure what kind of context information is available in the F# compiler, but here are some ideas:
* The type 'XResult<'a -> string), 'b>' cannot be used as the lh-side of this '::' operator, the rh-side is already bound to 'XResult<string>'.
* The first generic parameter for 'Result.create' is expected to be of type 'XResult&tl;string>', but given a value of type 'Result<'a -> string), 'b>'.
* The function 'Result.create' expects a parameter of type X, but the given parameter is of type Y.
I'm sure some variant can be concocted that is at least somewhat clearer than "the type X does not match the type Y", because that is just as telling as saying "42 does not equal 24": it doesn't explain anything, basically.
Contributor guide
Assessment
This issue has not been assessed yet.