Consider the following error message:
This expression was expected to have type
'string'
but here has type
''a * 'b'
This can arise in code like this:
let g a b = "hello"
let f a b : string =
g a, b
I got some feedback from a newcomer that this was confusing for several reasons:
- They weren't used to F# parameter applications yet and accidentally used a comma
- They didn't know what the
* meant in the error message
The first confusion could potentially be made better by a code fixer.
The second one would need a better error message. I propose the following:
This expression was expected to have type:
'string'
but here is a tuple of type:
''a * 'b'
This could still be confusing, but at least it's explicitly saying that it's a tuple type.