<div dir="ltr">I think Richard is referring to "<span style="font-size:13px">The function ‘f2’ is applied to three arguments,</span><br style="font-size:13px"><span style="font-size:13px">    but its type ‘Int -> Float -> Char -> Bool’ has only three".  Note "applied to three ... but ... only three".   Here n = three.</span><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">-Brent</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 5, 2014 at 9:55 AM, Dr. ÉRDI Gergő <span dir="ltr"><<a href="mailto:gergo@erdi.hu" target="_blank">gergo@erdi.hu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">But it says `expected Char -> Bool, got Char -> m Bool', note the `m' type constructor in the second one. So it's not `n' vs. `n'.</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Dec 5, 2014 10:50 PM, "Richard Eisenberg" <<a href="mailto:eir@cis.upenn.edu" target="_blank">eir@cis.upenn.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The reason I said "That's a bug!" so confidently is because of the "expected n but got n" part. Even if everything else is OK, we need to fix that one bit.<br>
<br>
And I tend to agree about using heuristics to report better error messages in the presence of instantiating a type variable with (->). I've been caught and confused by that, too.<br>
<br>
Richard<br>
<br>
On Dec 4, 2014, at 4:23 PM, Evan Laforge <<a href="mailto:qdunkan@gmail.com" target="_blank">qdunkan@gmail.com</a>> wrote:<br>
<br>
> On Thu, Dec 4, 2014 at 12:59 PM, migmit <<a href="mailto:migmit@gmail.com" target="_blank">migmit@gmail.com</a>> wrote:<br>
>> It tries to get `m Bool` by applying f1 to three arguments: 0, 0, and 'a'. Now, since `f2` has the type `Int -> Float -> n Bool`, where `n` is of kind `* -> *` (and an instance of `Monad` class, but it's not yet the time to look for instances), we have `f2 0 :: Float -> n Bool` and `f2 0 0 :: n Bool`. Since that is applied to 'a', Haskell deduces that the last type should be something like `Char -> Something` — or, equivalently, `(->) Char Something`. Therefore, it can see that `n` is in fact `(->) Char` and `Something` is `Bool`. Therefore, `f2 0 0 'a' :: Bool`. But it is expecting `m Bool`, not `Bool` — which is exactly what an error message says.<br>
><br>
> Right, that's what I suspected was happening.  The confusion arrises<br>
> because it guesses that 'm' should be (->), and that deduction then<br>
> leads to a dead-end.  But when it reports the problem, it uses its<br>
> guessed 'm', rather that backing up to the declared value.<br>
><br>
> But surely always backing up to the declared unspecialized value is no<br>
> good either, because then you get vague errors.  All the compiler<br>
> knows is that when it simplifies as far as it can, it winds up with a<br>
> /= b, it doesn't know that I would have been surprised by its path a<br>
> few steps back.<br>
><br>
> But arity errors are common, and intentionally instantiating a prefix<br>
> type constructor like 'm a' as (->) is probably much less common.  So<br>
> perhaps there could be a heuristic that treats (->) specially and<br>
> includes an extra clause in the error if it unified a type variable to<br>
> (->)?<br>
><br>
> I suspect the "expected n but got n" error is also due to the same<br>
> thing, it counts arrows on one side but inferred arrows on the other?<br>
> Or something?  In any case, it seems like the two sides are counting<br>
> inconsistently.<br>
> _______________________________________________<br>
> Glasgow-haskell-users mailing list<br>
> <a href="mailto:Glasgow-haskell-users@haskell.org" target="_blank">Glasgow-haskell-users@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
><br>
<br>
_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org" target="_blank">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
<br></blockquote></div><br></div>