
Hello, I don't know if I'm the only one struggeling with this GHC error message on type mismatches or it's because I'm not a full time Haskeller, or because I'm not a native english speaker. Couldn't match type `A' with `B´ Expected type: B Actual type: A My problem is with 'Expected' and 'Actual', that I'm often unsure if the compiler is "expecting" something or if I'm the expecting one and the same goes for "actual". I know that the compiler is the expecting one and that I'm given the actual thing, but it's quite often that I'm looking at this error and have to repeat this reasoning. It's strange, because normaly I can memorize such things quite good, but this one bothers me. Perhaps it would be easier for myself if 'Actual type' would be called e.g. 'Given type', I don't know, that just one of the two has a less generic meaning. Greetings, Daniel

On 2013-11-07 12:52, Daniel Trstenjak wrote:
My problem is with 'Expected' and 'Actual', that I'm often unsure if the compiler is "expecting" something or if I'm the expecting one and the same goes for "actual".
Funny you mention it; I think I just got too used to the fact that every time I see this error I have to take a step back to remember what it means exactly. Renaming it to "given" or "provided" would really help. +1 David

The motivation is this. Consider f True where f :: Int -> Char Then f *expects* an argument of type Int but the *actual* argument has type Bool Does that help? Simon | -----Original Message----- | From: Glasgow-haskell-users [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of David Luposchainsky | Sent: 07 November 2013 12:23 | To: Daniel Trstenjak; glasgow-haskell-users@haskell.org | Subject: Re: GHC error message on type mismatch | | On 2013-11-07 12:52, Daniel Trstenjak wrote: | > My problem is with 'Expected' and 'Actual', that I'm often unsure if | > the compiler is "expecting" something or if I'm the expecting one | > and the same goes for "actual". | | Funny you mention it; I think I just got too used to the fact that every | time I see this error I have to take a step back to remember what it | means exactly. Renaming it to "given" or "provided" would really help. | | +1 | | David | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

It *is* sometimes difficult to remember that my expectations and I are not
part of this equation - it might be a better prompt to say something like
type mismatch between function parameter and supplied value:
function parameter type: A
supplied value type: B
On Thu, Nov 7, 2013 at 6:02 AM, Simon Peyton-Jones
The motivation is this. Consider
f True
where f :: Int -> Char
Then f *expects* an argument of type Int but the *actual* argument has type Bool
Does that help?
Simon
| -----Original Message----- | From: Glasgow-haskell-users [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of David Luposchainsky | Sent: 07 November 2013 12:23 | To: Daniel Trstenjak; glasgow-haskell-users@haskell.org | Subject: Re: GHC error message on type mismatch | | On 2013-11-07 12:52, Daniel Trstenjak wrote: | > My problem is with 'Expected' and 'Actual', that I'm often unsure if | > the compiler is "expecting" something or if I'm the expecting one | > and the same goes for "actual". | | Funny you mention it; I think I just got too used to the fact that every | time I see this error I have to take a step back to remember what it | means exactly. Renaming it to "given" or "provided" would really help. | | +1 | | David | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Hi Simon, On Thu, Nov 07, 2013 at 02:02:06PM +0000, Simon Peyton-Jones wrote:
The motivation is this. Consider
f True
where f :: Int -> Char
Then f *expects* an argument of type Int but the *actual* argument has type Bool
Does that help?
If you would switch the meaning of 'Expected' and 'Actual', than it still could make perfectly sense and my brain seems to tend to this switched meaning. I think my main issue is the word 'Actual'. I seem to associate something more authoritative with this word and not just a wrongly given type by the user, and on the other side 'Expected' doesn't feel authoritative enough. Yes, I think the combination of the words 'Expected' and 'Actual' is irritating me and that I'm perceiving 'Actual' as the more authoritative one. Perhaps: Couldn't match type `A' with `B´ Real type: B Given type: A Or instead of 'Given', like others have suggested: 'Provided' or 'Supplied'. Greetings, Daniel

i'm not sure how change the words to synonyms helps communicate the exact same thing better, :) That said, once you start digging into really really fancy types, you'll certainly discover examples where the error messages are confusing and need some care to better communicate what is indeed the error. Point being: as you get into trying out really really fancy types, please feel welcome to share examples where the resulting error messages seem lacking / down right confusing. (though asking for help on the cafe list or #haskell on irc first is probably the first place to go, of course) On Thu, Nov 7, 2013 at 11:54 PM, Daniel Trstenjak < daniel.trstenjak@gmail.com> wrote:
Hi Simon,
On Thu, Nov 07, 2013 at 02:02:06PM +0000, Simon Peyton-Jones wrote:
The motivation is this. Consider
f True
where f :: Int -> Char
Then f *expects* an argument of type Int but the *actual* argument has type Bool
Does that help?
If you would switch the meaning of 'Expected' and 'Actual', than it still could make perfectly sense and my brain seems to tend to this switched meaning.
I think my main issue is the word 'Actual'. I seem to associate something more authoritative with this word and not just a wrongly given type by the user, and on the other side 'Expected' doesn't feel authoritative enough.
Yes, I think the combination of the words 'Expected' and 'Actual' is irritating me and that I'm perceiving 'Actual' as the more authoritative one.
Perhaps:
Couldn't match type `A' with `B´ Real type: B Given type: A
Or instead of 'Given', like others have suggested: 'Provided' or 'Supplied'.
Greetings, Daniel _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Hi everyone
On 07 Nov 2013, at 23:54, Daniel Trstenjak
wrote: Hi Simon,
On Thu, Nov 07, 2013 at 02:02:06PM +0000, Simon Peyton-Jones wrote: The motivation is this. Consider
f True
where f :: Int -> Char
Then f *expects* an argument of type Int but the *actual* argument has type Bool
Does that help?
If you would switch the meaning of 'Expected' and 'Actual', than it still could make perfectly sense and my brain seems to tend to this switched meaning.
Yeah I can see how that may happen. f's argument type is *actually* an Int, but it was used in a way that caller *expects* it to have a type Bool
I think my main issue is the word 'Actual'. I seem to associate something more authoritative with this word and not just a wrongly given type by the user, and on the other side 'Expected' doesn't feel authoritative enough.
Yes, I think the combination of the words 'Expected' and 'Actual' is irritating me and that I'm perceiving 'Actual' as the more authoritative one.
Perhaps:
Couldn't match type `A' with `B´ Real type: B Given type: A
Or instead of 'Given', like others have suggested: 'Provided' or 'Supplied'.
Greetings, Daniel _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

* Daniel Trstenjak
Perhaps:
Couldn't match type `A' with `B´ Real type: B Given type: A
Or instead of 'Given', like others have suggested: 'Provided' or 'Supplied'.
So far in this thread I haven't seen any suggestions better than status quo. E.g.: Prelude> (undefined :: Int -> Bool) (undefined :: Bool) <interactive>:2:29: Couldn't match expected type `Int' with actual type `Bool' In the first argument of `undefined :: Int -> Bool', namely `(undefined :: Bool)' In the expression: (undefined :: Int -> Bool) (undefined :: Bool) In an equation for `it': it = (undefined :: Int -> Bool) (undefined :: Bool) This one is quite clear — the compiler expected an argument of type Int, but it was of type Bool. Now replace this with Real and Given. Well, Bool for the function argument is both Real and Given (I gave it this type, and it became its real type). And calling Int either Real or Given doesn't make any sense. Roman

On Thu, Nov 7, 2013 at 4:22 AM, David Luposchainsky
On 2013-11-07 12:52, Daniel Trstenjak wrote:
My problem is with 'Expected' and 'Actual', that I'm often unsure if the compiler is "expecting" something or if I'm the expecting one and the same goes for "actual".
Funny you mention it; I think I just got too used to the fact that every time I see this error I have to take a step back to remember what it means exactly. Renaming it to "given" or "provided" would really help.
For what it's worth, I used to have the same confusion. But after a few years it went away. Now it seems obvious and I don't really understand how I was confused before, or how I got unconfused. That's the classic problem with trying to make anything intuitive. When I write my own typecheck msgs, I always write "Function expected X, but received Y." That's not too far off from expected / actual, though at least it has an explicit subject.

On Fri, Nov 08, 2013 at 12:01:13AM -0800, Evan Laforge wrote:
When I write my own typecheck msgs, I always write "Function expected X, but received Y." That's not too far off from expected / actual, though at least it has an explicit subject.
That's perfectly fine, because 'Function + expected' is pointing to the compiler side and additionally 'received' is pointing to the user side.
participants (8)
-
Carter Schonwald
-
Dan Frumin
-
Daniel Trstenjak
-
David Fox
-
David Luposchainsky
-
Evan Laforge
-
Roman Cheplyaka
-
Simon Peyton-Jones